From b0653ae8ec7ccf327603734dda017e6a3ad087cf Mon Sep 17 00:00:00 2001 From: "925116093-qq.com" <925116093@qq.com> Date: Sat, 2 Aug 2025 17:43:03 +0800 Subject: [PATCH] 202507251746 --- .../api/system/GoodsOrder_20250515150559.js | 44 - .../api/system/GoodsOrder_20250522180039.js | 56 - .../system/Coupons/index_20250519120220.vue | 545 ---- .../system/Coupons/index_20250520145407.vue | 550 ---- .../system/Coupons/index_20250520145619.vue | 550 ---- .../system/Coupons/index_20250520150013.vue | 550 ---- .../system/Coupons/index_20250520152252.vue | 550 ---- .../system/Coupons/index_20250520152350.vue | 550 ---- .../system/Coupons/index_20250520152902.vue | 556 ---- .../system/Coupons/index_20250520152917.vue | 557 ---- .../system/Coupons/index_20250520153120.vue | 563 ---- .../system/Coupons/index_20250520153129.vue | 563 ---- .../system/Coupons/index_20250520153440.vue | 567 ---- .../system/Coupons/index_20250521170848.vue | 642 ---- .../system/Coupons/index_20250521171026.vue | 642 ---- .../system/Coupons/index_20250521171633.vue | 662 ---- .../system/Coupons/index_20250521171954.vue | 681 ---- .../system/Coupons/index_20250521172357.vue | 681 ---- .../system/Coupons/index_20250521172626.vue | 680 ---- .../system/Coupons/index_20250521173405.vue | 680 ---- .../system/Coupons/index_20250521173508.vue | 685 ---- .../system/Coupons/index_20250521174227.vue | 684 ---- .../system/Coupons/index_20250521174304.vue | 679 ---- .../system/Coupons/index_20250522091702.vue | 681 ---- .../system/Coupons/index_20250522091758.vue | 688 ---- .../system/Coupons/index_20250522092020.vue | 704 ---- .../system/Coupons/index_20250522092036.vue | 704 ---- .../system/Coupons/index_20250522092212.vue | 704 ---- .../system/Coupons/index_20250522092238.vue | 704 ---- .../system/Coupons/index_20250522092302.vue | 698 ---- .../GoodsOrder/index_20250520180342.vue | 561 ---- .../GoodsOrder/index_20250520180532.vue | 561 ---- .../GoodsOrder/index_20250522174956.vue | 607 ---- .../GoodsOrder/index_20250522175604.vue | 587 ---- .../GoodsOrder/index_20250522175609.vue | 587 ---- .../GoodsOrder/index_20250522175829.vue | 583 ---- .../GoodsOrder/index_20250522180420.vue | 596 ---- .../GoodsOrder/index_20250522180536.vue | 596 ---- .../GoodsOrder/index_20250522180741.vue | 597 ---- .../GoodsOrder/index_20250522180820.vue | 597 ---- .../GoodsOrder/index_20250522180840.vue | 591 ---- .../GoodsOrder/index_20250522180935.vue | 594 ---- .../GoodsOrder/index_20250522181143.vue | 591 ---- .../GoodsOrder/index_20250522181147.vue | 591 ---- .../GoodsOrder/index_20250523093847.vue | 591 ---- .../GoodsOrder/index_20250523094010.vue | 589 ---- .../GoodsOrder/index_20250523094253.vue | 589 ---- .../GoodsOrder/index_20250523094259.vue | 589 ---- .../GoodsOrder/index_20250523094302.vue | 589 ---- .../GoodsOrder/index_20250523100403.vue | 597 ---- .../common/utils/file/FileUploadUtils.java | 3 +- .../common/utils/file/MimeTypeUtils.java | 2 + ruoyi-system/pom.xml | 14 + .../controller/AppleMemberController.java | 11 + .../controller/AppleOrderController.java | 2852 ++++++++++++++--- .../system/controller/ApplePayController.java | 104 + .../system/controller/AppletController.java | 2691 +++++++++++++--- .../ruoyi/system/controller/CoursorUtil.java | 42 +- .../controller/GoodsOrderController.java | 161 +- .../controller/PayNotifyController.java | 110 +- .../controller/QuoteTypeController.java | 14 +- .../controller/WorkerMarginLogController.java | 34 +- .../java/com/ruoyi/system/controller/json.txt | 105 +- .../controllerUtil/AppletControllerUtil.java | 291 +- .../system/controllerUtil/CartOrderUtil.java | 28 +- .../system/controllerUtil/OrderUtil.java | 443 ++- .../ruoyi/system/controllerUtil/PageUtil.java | 58 +- .../system/controllerUtil/PayBeforeUtil.java | 213 +- .../system/controllerUtil/RefundUtil.java | 361 ++- .../system/controllerUtil/WechatPayUtil.java | 2 +- .../controllerUtil/WechatPayV3Util.java | 4 +- .../com/ruoyi/system/domain/GoodsOrder.java | 100 + .../java/com/ruoyi/system/domain/Order.java | 14 + .../com/ruoyi/system/domain/OrderLog.java | 16 + .../system/domain/UserUseSecondaryCard.java | 12 + .../ruoyi/system/domain/UsersPayBefor.java | 10 +- .../ruoyi/system/domain/WorkerMarginLog.java | 13 + .../ruoyi/system/domain/WorkerMoneyLog.java | 32 + .../com/ruoyi/system/mapper/OrderMapper.java | 91 + .../system/mapper/ServiceGoodsMapper.java | 10 +- .../system/mapper/WorkerMoneyLogMapper.java | 12 +- .../ruoyi/system/service/IOrderService.java | 91 + .../system/service/IServiceGoodsService.java | 8 + .../service/IWorkerMoneyLogService.java | 7 + .../system/service/impl/OrderServiceImpl.java | 93 +- .../service/impl/ServiceGoodsServiceImpl.java | 12 + .../impl/WorkerMoneyLogServiceImpl.java | 3 + .../resources/mapper/system/ContentMapper.xml | 1 + .../mapper/system/GoodsOrderMapper.xml | 62 +- .../mapper/system/OrderLogMapper.xml | 13 +- .../resources/mapper/system/OrderMapper.xml | 133 +- .../mapper/system/ServiceGoodsMapper.xml | 7 + .../mapper/system/UserBenefitPointsMapper.xml | 1 + .../system/UserUseSecondaryCardMapper.xml | 3 + .../mapper/system/UsersPayBeforMapper.xml | 8 +- .../mapper/system/WorkerMarginLogMapper.xml | 10 +- .../mapper/system/WorkerMoneyLogMapper.xml | 17 +- ruoyi-ui/src/api/system/GoodsOrder.js | 9 + ruoyi-ui/src/views/system/AdvImg/index.vue | 5 +- .../src/views/system/Coupons/index copy.vue | 4 +- ruoyi-ui/src/views/system/Coupons/index.vue | 4 +- .../src/views/system/GoodsOrder/index.vue | 492 ++- .../src/views/system/ServiceGoods/index.vue | 27 +- .../src/views/system/SiteConfig/index.vue | 746 ++++- .../src/views/system/SiteConfig/selecturl.vue | 150 + .../views/system/UserSecondaryCard/index.vue | 177 +- .../src/views/system/UsersWorker/index.vue | 57 +- .../views/system/WorkerMarginLog/index.vue | 339 -- .../workerMoneyLog/WorkerMoneyLogTable.vue | 47 +- 109 files changed, 8859 insertions(+), 31103 deletions(-) delete mode 100644 .history/ruoyi-ui/src/api/system/GoodsOrder_20250515150559.js delete mode 100644 .history/ruoyi-ui/src/api/system/GoodsOrder_20250522180039.js delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250519120220.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520145407.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520145619.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520150013.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520152252.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520152350.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520152902.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520152917.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520153120.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520153129.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250520153440.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521170848.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521171026.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521171633.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521171954.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521172357.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521172626.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521173405.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521173508.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521174227.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250521174304.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522091702.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522091758.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522092020.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522092036.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522092212.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522092238.vue delete mode 100644 .history/ruoyi-ui/src/views/system/Coupons/index_20250522092302.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180342.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180532.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522174956.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175604.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175609.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175829.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180420.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180536.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180741.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180820.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180840.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180935.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181143.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181147.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523093847.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094010.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094253.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094259.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094302.vue delete mode 100644 .history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523100403.vue create mode 100644 ruoyi-ui/src/views/system/SiteConfig/selecturl.vue delete mode 100644 ruoyi-ui/src/views/system/WorkerMarginLog/index.vue diff --git a/.history/ruoyi-ui/src/api/system/GoodsOrder_20250515150559.js b/.history/ruoyi-ui/src/api/system/GoodsOrder_20250515150559.js deleted file mode 100644 index 5ae69e7..0000000 --- a/.history/ruoyi-ui/src/api/system/GoodsOrder_20250515150559.js +++ /dev/null @@ -1,44 +0,0 @@ -import request from '@/utils/request' - -// 查询商品订单列表 -export function listGoodsOrder(query) { - return request({ - url: '/system/GoodsOrder/list', - method: 'get', - params: query - }) -} - -// 查询商品订单详细 -export function getGoodsOrder(id) { - return request({ - url: '/system/GoodsOrder/' + id, - method: 'get' - }) -} - -// 新增商品订单 -export function addGoodsOrder(data) { - return request({ - url: '/system/GoodsOrder', - method: 'post', - data: data - }) -} - -// 修改商品订单 -export function updateGoodsOrder(data) { - return request({ - url: '/system/GoodsOrder', - method: 'put', - data: data - }) -} - -// 删除商品订单 -export function delGoodsOrder(id) { - return request({ - url: '/system/GoodsOrder/' + id, - method: 'delete' - }) -} diff --git a/.history/ruoyi-ui/src/api/system/GoodsOrder_20250522180039.js b/.history/ruoyi-ui/src/api/system/GoodsOrder_20250522180039.js deleted file mode 100644 index 0921eb8..0000000 --- a/.history/ruoyi-ui/src/api/system/GoodsOrder_20250522180039.js +++ /dev/null @@ -1,56 +0,0 @@ -import request from '@/utils/request' - -// 查询商品订单列表 -export function listGoodsOrder(query) { - return request({ - url: '/system/GoodsOrder/list', - method: 'get', - params: query - }) -} - -// 查询商品订单详细 -export function getGoodsOrder(id) { - return request({ - url: '/system/GoodsOrder/' + id, - method: 'get' - }) -} -export function getGoodsDataList() { - return request({ - url: '/system/QuoteType/goodsDataList', - method: 'get' - }) -} -// 获取接单记录列表 -export function getUserDataList() { - return request({ - url: '/system/transfer/getUsersDataList', - method: 'get' - }) -} -// 新增商品订单 -export function addGoodsOrder(data) { - return request({ - url: '/system/GoodsOrder', - method: 'post', - data: data - }) -} - -// 修改商品订单 -export function updateGoodsOrder(data) { - return request({ - url: '/system/GoodsOrder', - method: 'put', - data: data - }) -} - -// 删除商品订单 -export function delGoodsOrder(id) { - return request({ - url: '/system/GoodsOrder/' + id, - method: 'delete' - }) -} diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250519120220.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250519120220.vue deleted file mode 100644 index 5ebc209..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250519120220.vue +++ /dev/null @@ -1,545 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145407.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145407.vue deleted file mode 100644 index 2b7fbbe..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145407.vue +++ /dev/null @@ -1,550 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145619.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145619.vue deleted file mode 100644 index 5206624..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520145619.vue +++ /dev/null @@ -1,550 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520150013.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520150013.vue deleted file mode 100644 index 31ff681..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520150013.vue +++ /dev/null @@ -1,550 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152252.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152252.vue deleted file mode 100644 index 7b072bd..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152252.vue +++ /dev/null @@ -1,550 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152350.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152350.vue deleted file mode 100644 index 68ef17b..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152350.vue +++ /dev/null @@ -1,550 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152902.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152902.vue deleted file mode 100644 index b21bfdc..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152902.vue +++ /dev/null @@ -1,556 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152917.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152917.vue deleted file mode 100644 index 979450f..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520152917.vue +++ /dev/null @@ -1,557 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153120.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153120.vue deleted file mode 100644 index a25c75f..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153120.vue +++ /dev/null @@ -1,563 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153129.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153129.vue deleted file mode 100644 index de6028f..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153129.vue +++ /dev/null @@ -1,563 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153440.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153440.vue deleted file mode 100644 index 0d3512c..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250520153440.vue +++ /dev/null @@ -1,567 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521170848.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521170848.vue deleted file mode 100644 index 1b6dcec..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521170848.vue +++ /dev/null @@ -1,642 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171026.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171026.vue deleted file mode 100644 index b524980..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171026.vue +++ /dev/null @@ -1,642 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171633.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171633.vue deleted file mode 100644 index 592a0cb..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171633.vue +++ /dev/null @@ -1,662 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171954.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171954.vue deleted file mode 100644 index 249604a..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521171954.vue +++ /dev/null @@ -1,681 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172357.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172357.vue deleted file mode 100644 index 249604a..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172357.vue +++ /dev/null @@ -1,681 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172626.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172626.vue deleted file mode 100644 index 3a72ad2..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521172626.vue +++ /dev/null @@ -1,680 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173405.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173405.vue deleted file mode 100644 index 3a72ad2..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173405.vue +++ /dev/null @@ -1,680 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173508.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173508.vue deleted file mode 100644 index a386916..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521173508.vue +++ /dev/null @@ -1,685 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174227.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174227.vue deleted file mode 100644 index 1e1f2fd..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174227.vue +++ /dev/null @@ -1,684 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174304.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174304.vue deleted file mode 100644 index e52519c..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250521174304.vue +++ /dev/null @@ -1,679 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091702.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091702.vue deleted file mode 100644 index f0d7a3c..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091702.vue +++ /dev/null @@ -1,681 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091758.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091758.vue deleted file mode 100644 index d670f92..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522091758.vue +++ /dev/null @@ -1,688 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092020.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092020.vue deleted file mode 100644 index c21d2b6..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092020.vue +++ /dev/null @@ -1,704 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092036.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092036.vue deleted file mode 100644 index c21d2b6..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092036.vue +++ /dev/null @@ -1,704 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092212.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092212.vue deleted file mode 100644 index c21d2b6..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092212.vue +++ /dev/null @@ -1,704 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092238.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092238.vue deleted file mode 100644 index 0705b41..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092238.vue +++ /dev/null @@ -1,704 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092302.vue b/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092302.vue deleted file mode 100644 index d8e615a..0000000 --- a/.history/ruoyi-ui/src/views/system/Coupons/index_20250522092302.vue +++ /dev/null @@ -1,698 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180342.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180342.vue deleted file mode 100644 index 5433040..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180342.vue +++ /dev/null @@ -1,561 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180532.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180532.vue deleted file mode 100644 index fafe3cd..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250520180532.vue +++ /dev/null @@ -1,561 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522174956.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522174956.vue deleted file mode 100644 index b6d5907..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522174956.vue +++ /dev/null @@ -1,607 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175604.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175604.vue deleted file mode 100644 index 17f8298..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175604.vue +++ /dev/null @@ -1,587 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175609.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175609.vue deleted file mode 100644 index 17f8298..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175609.vue +++ /dev/null @@ -1,587 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175829.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175829.vue deleted file mode 100644 index b790b3d..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522175829.vue +++ /dev/null @@ -1,583 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180420.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180420.vue deleted file mode 100644 index 65d24c2..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180420.vue +++ /dev/null @@ -1,596 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180536.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180536.vue deleted file mode 100644 index 99ffb10..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180536.vue +++ /dev/null @@ -1,596 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180741.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180741.vue deleted file mode 100644 index 24c1603..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180741.vue +++ /dev/null @@ -1,597 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180820.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180820.vue deleted file mode 100644 index 5ad9f80..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180820.vue +++ /dev/null @@ -1,597 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180840.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180840.vue deleted file mode 100644 index cef2f78..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180840.vue +++ /dev/null @@ -1,591 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180935.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180935.vue deleted file mode 100644 index bd6a122..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522180935.vue +++ /dev/null @@ -1,594 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181143.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181143.vue deleted file mode 100644 index d6a88f9..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181143.vue +++ /dev/null @@ -1,591 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181147.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181147.vue deleted file mode 100644 index d6a88f9..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250522181147.vue +++ /dev/null @@ -1,591 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523093847.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523093847.vue deleted file mode 100644 index d6a88f9..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523093847.vue +++ /dev/null @@ -1,591 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094010.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094010.vue deleted file mode 100644 index ad0bcf9..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094010.vue +++ /dev/null @@ -1,589 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094253.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094253.vue deleted file mode 100644 index befecd6..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094253.vue +++ /dev/null @@ -1,589 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094259.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094259.vue deleted file mode 100644 index befecd6..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094259.vue +++ /dev/null @@ -1,589 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094302.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094302.vue deleted file mode 100644 index befecd6..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523094302.vue +++ /dev/null @@ -1,589 +0,0 @@ - - - diff --git a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523100403.vue b/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523100403.vue deleted file mode 100644 index 1bb57ec..0000000 --- a/.history/ruoyi-ui/src/views/system/GoodsOrder/index_20250523100403.vue +++ /dev/null @@ -1,597 +0,0 @@ - - - diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index d5455c4..e5a81de 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -144,7 +144,8 @@ public class FileUploadUtils { int dirLastIndex = RuoYiConfig.getProfile().length() + 1; String currentDir = StringUtils.substring(uploadDir, dirLastIndex); - return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; + //return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; + return fileName; } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java index f968f1a..5f35b87 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java @@ -35,6 +35,8 @@ public class MimeTypeUtils "rar", "zip", "gz", "bz2", // 视频格式 "mp4", "avi", "rmvb", + //录音文件格式 + "mp3", // pdf "pdf" }; diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 4ccc12a..4d1c8fc 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -42,6 +42,20 @@ qiniu-java-sdk + + + net.bramp.ffmpeg + ffmpeg + 0.7.0 + + + + + commons-io + commons-io + 2.11.0 + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java index c49f5f2..96fcbd9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java @@ -718,6 +718,17 @@ public class AppleMemberController extends BaseController { // 保存评价 int result= orderCommentService.insertOrderComment(comment); if (result > 0) { + com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); + jsonObject.put("name", "用户已评价"); + OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "已评价", "4", jsonObject, 2L); + com.alibaba.fastjson.JSONObject jsonObject1 = new com.alibaba.fastjson.JSONObject(); + Map logContent1 = new HashMap<>(); + logContent1.put("text", content); + logContent1.put("image", params.get("images")); + logContent1.put("labels", params.get("labels")); + logContent1.put("num", num); + jsonObject1= com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(logContent1)); + OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "已完成", "5", jsonObject1, 2L); goodsOrder.setStatus(5L); // 订单状态改为已收货 goodsOrderService.updateGoodsOrder(goodsOrder); return AjaxResult.success(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java index bac3500..083e32d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java @@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.ControllerUtil.*; import com.ruoyi.system.ControllerUtil.CartOrderUtil; +import com.ruoyi.system.ControllerUtil.AppletLoginUtil; import com.ruoyi.system.domain.*; import com.ruoyi.system.service.*; import org.apache.commons.lang3.StringUtils; @@ -16,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; @@ -23,6 +25,15 @@ import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; import java.util.Calendar; +import java.util.stream.Collectors; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.io.BufferedReader; +import java.io.InputStreamReader; import com.ruoyi.system.service.IShopAddressService; import com.ruoyi.system.domain.ShopAddress; import com.ruoyi.system.domain.GoodsCart; @@ -30,6 +41,19 @@ import com.ruoyi.system.service.IGoodsCartService; import com.ruoyi.system.domain.OrderTypeCount; import com.ruoyi.system.service.IQuoteMaterialTypeService; import com.ruoyi.system.service.IQuoteMaterialService; +import com.ruoyi.system.service.IOrderSoundService; +import com.ruoyi.system.domain.OrderSound; +import com.ruoyi.system.domain.Order; +import com.ruoyi.system.service.IOrderSoundLogService; +import com.ruoyi.system.domain.OrderSoundLog; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.system.utils.QiniuUploadUtil; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.utils.FFmpegUtilsSimple; /** * 苹果订单控制器 @@ -109,6 +133,12 @@ public class AppleOrderController extends BaseController { @Autowired private IWorkerLevelService workerLevelService; + @Autowired + private IOrderSoundService orderSoundService; + + @Autowired + private IOrderSoundLogService orderSoundLogService; + // @Autowired // private IUserGroupBuyingService userGroupBuyingService; @@ -122,6 +152,9 @@ public class AppleOrderController extends BaseController { @Autowired private IWorkerMoneyLogService workerMoneyLogService; + @Autowired + private IOrderReworkService orderReworkService; + /** @@ -288,6 +321,7 @@ public class AppleOrderController extends BaseController { grouporderid=GenerateCustomCode.generCreateOrder("pt"); } if (StringUtils.isNotBlank(cikaid)){ + ordertype=2; UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(cikaid); if (userUseSecondaryCard == null){ return AjaxResult.error("此卡不存在"); @@ -471,6 +505,15 @@ public class AppleOrderController extends BaseController { // 计算服务金抵扣金额 Integer serviceFee = configJson.getInteger("servicefee"); +// if (serviceFee != null && serviceFee > 0) { +// // 查询数据库最新用户数据 +// Users userDb = usersService.selectUsersById(user.getId()); +// if (userDb != null && userDb.getServicefee() != null && userDb.getServicefee().compareTo(BigDecimal.ZERO) > 0) { +// // 服务金抵扣金额 = 用户服务金 * 服务金比例 / 100 +// BigDecimal serviceRate = BigDecimal.valueOf(serviceFee).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP); +// serviceMoney = userDb.getServicefee().multiply(serviceRate); +// } +// } if (serviceFee != null && serviceFee > 0) { // 查询数据库最新用户数据 Users userDb = usersService.selectUsersById(user.getId()); @@ -505,6 +548,7 @@ public class AppleOrderController extends BaseController { usersPayBefor.setMembermoney(memberMoney); usersPayBefor.setType(Long.valueOf(ordertype)); usersPayBefor.setSku(sku); + usersPayBefor.setNum(Long.valueOf(num)); usersPayBefor.setServiceid(productId); usersPayBefor.setGrouporderid(grouporderid); usersPayBefor.setAddressid(addressId); @@ -512,25 +556,10 @@ public class AppleOrderController extends BaseController { usersPayBefor.setAttachments(fileData); usersPayBefor.setStatus(1L); // 1=待支付 usersPayBefor.setPaytype(1L); // 默认微信支付 - int payBeforResult = usersPayBeforService.insertUsersPayBefor(usersPayBefor); if (payBeforResult <= 0) { return AppletControllerUtil.appletWarning("预支付记录创建失败"); } - - // 10. 返回预支付信息 -// Map result = new HashMap<>(); -// result.put("orderId", orderId); -// result.put("oid", oid); -// result.put("payBeforId", usersPayBefor.getId()); -// result.put("paycode", usersPayBefor.getPaycode()); -// result.put("totalAmount", totalAmount); -// result.put("wxMoney", totalAmount); -// result.put("yeMoney", BigDecimal.ZERO); -// result.put("couponMoney", BigDecimal.ZERO); -// result.put("memberMoney", BigDecimal.ZERO); -// result.put("orderType", ordertype); -// result.put("attachments", attachments); Map result1 = new HashMap<>(); if (ordertype == 4){ result1.put("type", "1"); @@ -546,318 +575,6 @@ public class AppleOrderController extends BaseController { return AppletControllerUtil.appletError("订单预支付创建失败:" + e.getMessage()); } } - - - - -// /** -// * 创建服务订单(支持多商品批量下单) -// * -// * @param params 请求参数,包含多个商品信息、地址信息和预约时间 -// * @param request HTTP请求对象 -// * @return 返回创建结果 -// */ -// @PostMapping("/api/service/create/order") -// public AjaxResult createServiceOrder(@RequestBody Map params, HttpServletRequest request) { -// try { -// // 1. 验证用户登录状态 -// String token = request.getHeader("token"); -// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); -// if (!(Boolean) userValidation.get("valid")) { -// return AppletControllerUtil.appletWarning("用户未登录或token无效"); -// } -// PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); -// // 2. 获取用户信息 -// Users user = (Users) userValidation.get("user"); -// if (user == null) { -// return AppletControllerUtil.appletWarning("用户信息获取失败"); -// } -// -// // 3. 验证订单参数 -// if (params == null || params.isEmpty()) { -// return AppletControllerUtil.appletWarning("订单参数不能为空"); -// } -// -// // 4. 生成主订单号 -// String mainOrderId = GenerateCustomCode.generCreateOrder("WXB"); -// -// // 5. 存储所有订单信息 -// List> orderList = new ArrayList<>(); -// BigDecimal totalAmount = BigDecimal.ZERO; // 总金额 -// -// // 6. 遍历所有订单项 -// for (String key : params.keySet()) { -// // 跳过非数字键 -// if (!key.matches("\\d+")) { -// continue; -// } -// -// Map orderParams = (Map) params.get(key); -// -// // 验证必要参数 -// if (orderParams.get("product_id") == null || orderParams.get("address_id") == null) { -// return AppletControllerUtil.appletWarning("商品ID或地址ID不能为空"); -// } -// -// -// Long productId = Long.valueOf(orderParams.get("product_id").toString()); -// String carid = orderParams.get("carid").toString(); -// Long addressId = Long.valueOf(orderParams.get("address_id").toString()); -// Long num = orderParams.get("num") != null ? Long.valueOf(orderParams.get("num").toString()) : 1L; -// -// // 处理SKU参数 -// String sku = AppletControllerUtil.processSkuParam(orderParams.get("sku")); -// -// // 查询商品信息 -// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); -// if (serviceGoods == null) { -// return AppletControllerUtil.appletWarning("商品ID " + productId + " 不存在"); -// } -// -// // 查询地址信息(只需要查询一次,假设所有订单使用相同地址) -// UserAddress userAddress = userAddressService.selectUserAddressById(addressId); -// if (userAddress == null) { -// return AppletControllerUtil.appletWarning("地址不存在"); -// } -// -// // 计算单个订单金额 -// BigDecimal itemPrice; -// if (serviceGoods.getType() == 2) { -// // 商品订单,判断sku -// String skuStr = sku; -// BigDecimal unitPrice = serviceGoods.getPrice(); -// if (skuStr != null && !skuStr.trim().isEmpty()) { -// try { -// JSONObject skuJson = JSONObject.parseObject(skuStr); -// if (skuJson.containsKey("price")) { -// unitPrice = new BigDecimal(skuJson.getString("price")); -// } -// } catch (Exception e) { -// // 解析失败,忽略,使用默认价格 -// } -// } -// itemPrice = unitPrice.multiply(BigDecimal.valueOf(num)); -// } else { -// // 服务订单 -// itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); -// } -// totalAmount = totalAmount.add(itemPrice); -// -// // 判断商品类型并创建相应订单 -// BigDecimal DeductionPrice = new BigDecimal("0"); -// if (serviceGoods.getType() == 2) { -// Long isself = orderParams.get("isself") != null ? Long.valueOf(orderParams.get("isself").toString()) : null;; -// // 创建服务订单 -// String coupon_id = orderParams.get("coupon_id") != null ? orderParams.get("coupon_id").toString() : ""; -// System.out.println("coupon_id:"+coupon_id); -// CouponUser coupon=null; -// if (coupon_id!=null&& !coupon_id.isEmpty()){ -// coupon = couponUserService.selectCouponUserById(Long.valueOf(coupon_id)); -// if (coupon==null){ -// return AppletControllerUtil.appletWarning("优惠券不存在"); -// } -// -// if (coupon != null) { -// DeductionPrice= new BigDecimal(coupon.getCouponPrice()).divide(new BigDecimal(params.size()),2, RoundingMode.HALF_UP); -// } -// if (coupon != null) { -// coupon.setStatus(2L); -// } -// couponUserService.updateCouponUser(coupon) ; -// } -// // 创建商品订单 -// GoodsOrder goodsOrder = new GoodsOrder(); -// goodsOrder.setType(2); -// goodsOrder.setMainOrderId(mainOrderId); -// goodsOrder.setOrderId(GenerateCustomCode.generCreateOrder("B")); // 独立订单号 -// goodsOrder.setUid(user.getId()); -// goodsOrder.setProductId(productId); -// goodsOrder.setName(userAddress.getName()); -// goodsOrder.setPhone(userAddress.getPhone()); -// goodsOrder.setAddress(userAddress.getAddressName()); -// goodsOrder.setNum(num); -// if (isself==1L){ -// goodsOrder.setShopadresssid(1L); -// -// } -// goodsOrder.setIsself(isself); -// -// -// goodsOrder.setTotalPrice(itemPrice); -// goodsOrder.setGoodPrice(serviceGoods.getPrice()); -// goodsOrder.setPayPrice(itemPrice); -// goodsOrder.setDeduction(DeductionPrice); -// if (coupon_id!=null&& !coupon_id.isEmpty()){ -// goodsOrder.setCouponId(Long.valueOf(coupon_id)); -// } -// -// goodsOrder.setStatus(1L); // 待支付状态 -// goodsOrder.setAddressId(addressId); -// goodsOrder.setSku(sku); -// // 保存商品订单 -// int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); -// if (insertResult <= 0) { -// return AppletControllerUtil.appletWarning("商品订单创建失败,请稍后重试"); -// } -// // 添加到订单列表 -// Map orderInfo = new HashMap<>(); -// orderInfo.put("type", "goods"); -// orderInfo.put("orderId", goodsOrder.getId()); -// orderInfo.put("orderNo", goodsOrder.getOrderId()); -// orderInfo.put("productName", serviceGoods.getTitle()); -// orderInfo.put("price", itemPrice.toString()); -// orderList.add(orderInfo); -// } else { -// // 创建服务订单 -// String makeTime = orderParams.get("make_time") != null ? orderParams.get("make_time").toString() : ""; -// String fileData = orderParams.get("fileData") != null ? orderParams.get("fileData").toString() : ""; -// Order order = new Order(); -// order.setType(1); // 1:服务项目 -// order.setCreateType(1); // 1:用户自主下单 -// order.setUid(user.getId()); -// order.setUname(user.getName()); -// order.setProductId(productId); -// order.setProductName(serviceGoods.getTitle()); -// order.setName(userAddress.getName()); -// order.setFileData(AppletControllerUtil.getStringFileData(fileData)); -// order.setPhone(userAddress.getPhone()); -// order.setAddress(userAddress.getAddressInfo()); -// order.setAddressId(addressId); -// order.setSku(sku); -// order.setMainOrderId(mainOrderId); -// order.setOrderId(GenerateCustomCode.generCreateOrder("B")); // 独立订单号 -// // 处理预约时间 -// if (makeTime != null && !makeTime.isEmpty()) { -// String[] makeTimeArr = makeTime.split(" "); -// if (makeTimeArr.length == 2) { -// try { -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); -// Date date = sdf.parse(makeTimeArr[0]); -// order.setMakeTime(date.getTime() / 1000); -// order.setMakeHour(makeTimeArr[1]); -// } catch (Exception e) { -// logger.warn("预约时间格式错误: " + makeTime); -// } -// } -// } -// order.setNum(num); -// order.setTotalPrice(itemPrice); -// order.setGoodPrice(serviceGoods.getPrice()); -// order.setServicePrice(BigDecimal.ZERO); -// order.setPayPrice(itemPrice); -// order.setStatus(1L); // 1:待接单 -// order.setReceiveType(1L); // 1:自由抢单 -// order.setIsAccept(0); -// order.setIsComment(0); -// order.setIsPause(1); -// order.setDeduction(new BigDecimal(0)); -// // 保存服务订单 -// int result = orderService.insertOrder(order); -// if (result <= 0) { -// return AppletControllerUtil.appletWarning("服务订单创建失败,请稍后重试"); -// } -// // 添加订单日志 -// OrderLog orderLog = new OrderLog(); -// orderLog.setOid(order.getId()); -// orderLog.setOrderId(order.getOrderId()); -// orderLog.setTitle("订单生成"); -// JSONObject jsonObject = new JSONObject(); -// jsonObject.put("name", "预约成功,将尽快为主人派单"); -// orderLog.setType(new BigDecimal(1.0)); -// orderLog.setContent(jsonObject.toString()); -// orderLogService.insertOrderLog(orderLog); -// -// // 系统派单和消息通知逻辑 -// Order orderNewData = orderService.selectOrderById(order.getId()); -// String wxsendmsg = WXsendMsgUtil.sendMsgForUserInfo(user.getOpenid(), orderNewData, serviceGoods); -// Users worker = AppletControllerUtil.creatWorkerForOrder(orderNewData); -// -// if (worker != null) { -// // 更新订单状态为已派单 -// orderNewData.setWorkerId(worker.getId()); -// orderNewData.setStatus(2l); -// orderNewData.setIsPause(1); -// orderNewData.setReceiveTime(new Date()); -// orderNewData.setReceiveType(3l); -// orderNewData.setLogStatus(9); -// JSONObject jSONObject = new JSONObject(); -// jSONObject.put("type", 9); -// orderNewData.setLogJson(jSONObject.toJSONString()); -// orderService.updateOrder(orderNewData); -// // 添加派单日志 -// OrderLog orderLognew = new OrderLog(); -// orderLognew.setOid(orderNewData.getId()); -// orderLognew.setOrderId(orderNewData.getOrderId()); -// orderLognew.setTitle("平台派单"); -// orderLognew.setType(new BigDecimal(1.1)); -// JSONObject jSONObject1 = new JSONObject(); -// jSONObject1.put("name", "师傅收到派单信息"); -// orderLognew.setContent(jSONObject1.toJSONString()); -// orderLognew.setWorkerId(worker.getId()); -// orderLognew.setWorkerLogId(worker.getId()); -// orderLogService.insertOrderLog(orderLognew); -// // 发送通知 -// WXsendMsgUtil.sendMsgForWorkerInfo(worker.getOpenid(), orderNewData, serviceGoods); -// YunXinPhoneUtilAPI.httpsAxbTransfer(worker.getPhone()); -// } -// -// // 添加到订单列表 -// Map orderInfo = new HashMap<>(); -// orderInfo.put("type", "service"); -// orderInfo.put("orderId", order.getId()); -// orderInfo.put("orderNo", order.getOrderId()); -// orderInfo.put("productName", serviceGoods.getTitle()); -// orderInfo.put("price", itemPrice.toString()); -// orderList.add(orderInfo); -// } -// } -// // 7. 如果有商品订单,需要发起微信支付 -// boolean hasGoodsOrder = orderList.stream().anyMatch(order -> "goods".equals(order.get("type"))); -// if (hasGoodsOrder && totalAmount.compareTo(BigDecimal.ZERO) > 0) { -// //插入预支付订单,随后进行支付 -// String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount, mainOrderId, null, null, 5L, null, null, null, null, null,2L); -// Map result1 = new HashMap<>(); -// result1.put("type", "2"); -// result1.put("orderid", payBeforeId); -// return AppletControllerUtil.appletSuccess(result1); -// // 使用工具类简化微信支付参数组装 -//// Map payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), mainOrderId, new BigDecimal(0.01), orderList.size(), wechatPayUtil.PAY_FH+"api/goods/pay/notify"); -//// if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) { -//// Map responseData = new HashMap<>(); -//// responseData.put("mainOrderId", mainOrderId); -//// responseData.put("orderList", orderList); -//// responseData.put("totalAmount", totalAmount.toString()); -//// responseData.put("prepayId", payResult.get("prepayId")); -//// // 直接合并所有支付参数 -//// responseData.putAll(payResult); -//// return AppletControllerUtil.appletSuccess(responseData); -//// } else { -//// String errorMsg = payResult != null ? (String) payResult.get("message") : "微信支付下单失败"; -//// return AppletControllerUtil.appletWarning("支付下单失败:" + errorMsg); -//// } -// } else { -// // 没有商品订单,只有服务订单,直接返回成功 -// Map responseData = new HashMap<>(); -// responseData.put("mainOrderId", mainOrderId); -// responseData.put("orderList", orderList); -// responseData.put("totalAmount", totalAmount.toString()); -// return AppletControllerUtil.appletSuccess(responseData); -// } -// -// } catch (Exception e) { -// logger.error("创建订单异常:", e); -// return AppletControllerUtil.appletWarning("创建订单失败:" + e.getMessage()); -// } -// } - - - - - - - - - /** * 次卡购买接口 * @param params {"id":次卡id, "goodsids":["1","2",...]} @@ -1014,7 +731,7 @@ public class AppleOrderController extends BaseController { // 查询用户全部次卡 UserUseSecondaryCard queryCard = new UserUseSecondaryCard(); queryCard.setUid(user.getId()); - queryCard.setStatus(1L); + queryCard.setNostatus("1"); List allCardList = userUseSecondaryCardService.selectUserUseSecondaryCardList(queryCard); int total = allCardList.size(); int fromIndex = Math.max(0, (pageNum - 1) * pageSize); @@ -1029,7 +746,7 @@ public class AppleOrderController extends BaseController { map.put("icon", AppletControllerUtil.buildImageUrl(cardInfo.getShowimage())); map.put("price", cardInfo.getRealMoney()); map.put("title", cardInfo.getTitle()); - if (Objects.equals(card.getNum(), cardInfo.getNum())){ + if (card.getUsenum()==0){ map.put("iscanback", "1"); }else{ map.put("iscanback", "2"); @@ -1225,6 +942,322 @@ public class AppleOrderController extends BaseController { } } + + + + /** + * 根据ID查询预支付记录并计算支付金额 + * + * @param id 预支付记录ID + * @param params 请求参数,包含paytype、coupon_id、mtcode + * @param request HTTP请求对象 + * @return 预支付记录详情和计算后的支付金额 + */ + /** + * 获取预支付信息(智能抵扣版本) + * + * 智能抵扣逻辑: + * 1. 最大可抵扣金额 = 订单总金额 - 会员优惠 + * 2. 服务金抵扣限制:不能超过最大可抵扣金额和用户服务金余额 + * 3. 购物金抵扣限制:不能超过剩余可抵扣金额和用户购物金余额 + * 4. 抵扣优先级:服务金 > 购物金 + * + * 示例: + * - 订单金额:99元 + * - 会员优惠:9.9元 + * - 最大可抵扣:89.1元 + * - 服务金抵扣:50元(用户余额50元) + * - 购物金抵扣:39.1元(剩余39.1元,用户余额100元) + * - 实际应付:0元 + */ + @PostMapping("/api/paybefor/info/{id}") + public AjaxResult getPayBeforInfo(@PathVariable("id") String id, @RequestBody Map params, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletWarning("用户未登录或token无效"); + } + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletWarning("用户信息获取失败"); + } + + // 2. 参数验证 + if (com.ruoyi.common.utils.StringUtils.isBlank(id)) { + return AppletControllerUtil.appletWarning("预支付记录ID不能为空"); + } + + // 3. 获取请求参数 + Integer paytype = params.get("paytype") != null ? Integer.parseInt(params.get("paytype").toString()) : 1; + Long couponId = params.get("coupon_id") != null ? Long.parseLong(params.get("coupon_id").toString()) : null; + String mtcode = params.get("mtcode") != null ? params.get("mtcode").toString() : null; + + // 4. 查询预支付记录 + UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(id); + if (payBefor == null) { + return AppletControllerUtil.appletWarning("预支付记录不存在"); + } + + // 5. 验证记录归属权(只能查看自己的记录) + if (!payBefor.getUid().equals(user.getId())) { + return AppletControllerUtil.appletWarning("无权查看该预支付记录"); + } + + // 6. 获取原始总金额(allmoney是固定的,永远不会改变) + BigDecimal originalAmount = payBefor.getAllmoney(); + if (originalAmount == null) { + originalAmount = BigDecimal.ZERO; + } + + // 获取会员优惠金额(固定不变) + BigDecimal memberMoney = payBefor.getMembermoney(); + if (memberMoney == null) { + memberMoney = BigDecimal.ZERO; + } + + // 获取服务金抵扣金额(需要智能限制) + BigDecimal serviceMoney = payBefor.getServicemoney(); + if (serviceMoney == null) { + serviceMoney = BigDecimal.ZERO; + } + + // 获取购物金抵扣金额(需要智能限制) + BigDecimal shopMoney = payBefor.getShopmoney(); + if (shopMoney == null) { + shopMoney = BigDecimal.ZERO; + } + + // 智能限制消费金和服务金抵扣金额 + BigDecimal maxDeductibleAmount = originalAmount.subtract(memberMoney); + if (maxDeductibleAmount.compareTo(BigDecimal.ZERO) < 0) { + maxDeductibleAmount = BigDecimal.ZERO; + } + + // 检查用户实际拥有的消费金和服务金余额 + BigDecimal userServiceBalance = user.getServicefee() != null ? user.getServicefee() : BigDecimal.ZERO; + BigDecimal userShopBalance = user.getConsumption() != null ? user.getConsumption() : BigDecimal.ZERO; + + // 限制服务金抵扣金额(不能超过用户余额和最大可抵扣金额) + BigDecimal maxServiceDeductible = userServiceBalance.compareTo(maxDeductibleAmount) > 0 ? + maxDeductibleAmount : userServiceBalance; + + if (serviceMoney.compareTo(maxServiceDeductible) > 0) { + logger.info("服务金抵扣金额 {} 超过最大可抵扣金额 {},已自动调整为 {}", + serviceMoney, maxServiceDeductible, maxServiceDeductible); + serviceMoney = maxServiceDeductible; + } + + // 限制购物金抵扣金额(在服务金抵扣后的剩余金额内,且不能超过用户余额) + BigDecimal remainingDeductible = maxDeductibleAmount.subtract(serviceMoney); + if (remainingDeductible.compareTo(BigDecimal.ZERO) < 0) { + remainingDeductible = BigDecimal.ZERO; + } + + BigDecimal maxShopDeductible = userShopBalance.compareTo(remainingDeductible) > 0 ? + remainingDeductible : userShopBalance; + + if (shopMoney.compareTo(maxShopDeductible) > 0) { + logger.info("购物金抵扣金额 {} 超过最大可抵扣金额 {},已自动调整为 {}", + shopMoney, maxShopDeductible, maxShopDeductible); + shopMoney = maxShopDeductible; + } + + // 7. 计算优惠券金额(每次重新计算) + BigDecimal couponMoney = BigDecimal.ZERO; + if (couponId != null) { + CouponUser couponUser = couponUserService.selectCouponUserById(couponId); + if (couponUser != null && couponUser.getStatus() != null && couponUser.getStatus() == 1L) { + // 验证优惠券是否属于当前用户 + if (!couponUser.getUid().equals(user.getId())) { + return AppletControllerUtil.appletWarning("优惠券不属于当前用户"); + } + + // 验证优惠券是否过期 + if (couponUser.getLoseTime() != null && !"永久有效".equals(couponUser.getLoseTime())) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date loseTime = sdf.parse(couponUser.getLoseTime()); + if (new Date().after(loseTime)) { + return AppletControllerUtil.appletWarning("优惠券已过期"); + } + } catch (Exception e) { + logger.warn("解析优惠券过期时间失败: " + e.getMessage()); + } + } + + // 验证最低消费(基于原始金额) + if (couponUser.getMinPrice() != null && originalAmount.compareTo(BigDecimal.valueOf(couponUser.getMinPrice())) < 0) { + return AppletControllerUtil.appletWarning("订单金额未达到优惠券使用条件"); + } + + couponMoney = BigDecimal.valueOf(couponUser.getCouponPrice()); + } else { + return AppletControllerUtil.appletWarning("优惠券无效或已被使用"); + } + } + + // 8. 计算美团优惠金额(每次重新计算,2至15的随机整数用于测试) + BigDecimal mtMoney = BigDecimal.ZERO; + if (mtcode != null && !mtcode.trim().isEmpty()) { + // 生成2至15的随机整数 + Random random = new Random(); + int randomDiscount = random.nextInt(14) + 2; // 2到15的随机数 + mtMoney = new BigDecimal(randomDiscount); + } + + // 9. 计算实际应付金额(基于allmoney减去所有优惠) + BigDecimal actualAmount = originalAmount + .subtract(memberMoney) // 减去会员优惠 + .subtract(serviceMoney) // 减去服务金抵扣 + .subtract(shopMoney) // 减去购物金抵扣 + .subtract(couponMoney) // 减去优惠券金额 + .subtract(mtMoney); // 减去美团优惠 + + if (actualAmount.compareTo(BigDecimal.ZERO) < 0) { + actualAmount = BigDecimal.ZERO; + } + + // 10. 根据支付方式计算各支付渠道金额 + BigDecimal wxMoney = BigDecimal.ZERO; + BigDecimal yeMoney = BigDecimal.ZERO; + + if (paytype == 1) { + // 微信支付 + wxMoney = actualAmount; + yeMoney = BigDecimal.ZERO; + } else if (paytype == 2) { + // 余额支付 + if (user.getBalance() != null && user.getBalance().compareTo(actualAmount) >= 0) { + wxMoney = BigDecimal.ZERO; + yeMoney = actualAmount; + } else { + return AppletControllerUtil.appletWarning("余额不足,无法完成支付"); + } + } else if (paytype == 3) { + // 组合支付:优先使用余额,不足部分用微信支付 + if (user.getBalance() != null && user.getBalance().compareTo(actualAmount) >= 0) { + // 余额足够,全部用余额支付 + wxMoney = BigDecimal.ZERO; + yeMoney = actualAmount; + } else if (user.getBalance() != null && user.getBalance().compareTo(BigDecimal.ZERO) > 0) { + // 余额不足,优先扣除用户所有余额,剩余部分用微信支付 + yeMoney = user.getBalance(); + wxMoney = actualAmount.subtract(yeMoney); + } else { + // 无余额,全部微信支付 + wxMoney = actualAmount; + yeMoney = BigDecimal.ZERO; + } + } else { + return AppletControllerUtil.appletWarning("无效的支付方式"); + } + + // 11. 更新预支付记录(注意:allmoney保持不变,只更新其他字段) + payBefor.setPaytype(Long.valueOf(paytype)); + payBefor.setCouponid(couponId); + payBefor.setCouponmoney(couponMoney); + payBefor.setMtcode(mtcode); + payBefor.setMtmoney(mtMoney); + payBefor.setWxmoney(wxMoney); + payBefor.setYemoney(yeMoney); + // 注意:allmoney保持不变,这是原始总金额 + + int updateResult = usersPayBeforService.updateUsersPayBefor(payBefor); + if (updateResult <= 0) { + return AppletControllerUtil.appletWarning("更新预支付记录失败"); + } + + // 12. 构建支付公式 + StringBuilder paymentFormula = new StringBuilder(); + paymentFormula.append("总金额(").append(originalAmount).append(")"); + + // 添加各种优惠项 + if (memberMoney.compareTo(BigDecimal.ZERO) > 0) { + paymentFormula.append("-会员优惠(").append(memberMoney).append(")"); + } + if (serviceMoney.compareTo(BigDecimal.ZERO) > 0) { + paymentFormula.append("-服务金抵扣(").append(serviceMoney).append(")"); + } + if (shopMoney.compareTo(BigDecimal.ZERO) > 0) { + paymentFormula.append("-购物金抵扣(").append(shopMoney).append(")"); + } + if (couponMoney.compareTo(BigDecimal.ZERO) > 0) { + paymentFormula.append("-优惠券(").append(couponMoney).append(")"); + } + if (mtMoney.compareTo(BigDecimal.ZERO) > 0) { + paymentFormula.append("-美团优惠(").append(mtMoney).append(")"); + } + + paymentFormula.append("=").append(actualAmount).append("="); + + // 添加支付方式 + if (wxMoney.compareTo(BigDecimal.ZERO) > 0 && yeMoney.compareTo(BigDecimal.ZERO) > 0) { + // 组合支付 + paymentFormula.append("微信支付(").append(wxMoney).append(")+余额支付(").append(yeMoney).append(")"); + } else if (wxMoney.compareTo(BigDecimal.ZERO) > 0) { + // 纯微信支付 + paymentFormula.append("微信支付(").append(wxMoney).append(")"); + } else if (yeMoney.compareTo(BigDecimal.ZERO) > 0) { + // 纯余额支付 + paymentFormula.append("余额支付(").append(yeMoney).append(")"); + } + + // 13. 构建返回数据 + Map result = new HashMap<>(); + result.put("id", payBefor.getId()); + result.put("orderId", payBefor.getOrderid()); + result.put("paycode", payBefor.getPaycode()); + result.put("allmoney", originalAmount); // 原始总金额(固定不变,这是您最初存储的金额) + result.put("finalAmount", actualAmount); // 实际应付金额(基于allmoney计算得出) + result.put("wxmoney", wxMoney); // 微信支付金额 + result.put("status", payBefor.getStatus()); + result.put("oid", payBefor.getOid()); + result.put("yemoney", yeMoney); // 余额支付金额 + result.put("membermoney", memberMoney); // 会员优惠金额(固定不变) + result.put("shopmoney", shopMoney); // 购物金抵扣金额(智能限制后) + result.put("servicemoney", serviceMoney); // 服务金抵扣金额(智能限制后) + result.put("couponmoney", couponMoney); // 优惠券金额(实时计算) + result.put("mtmoney", mtMoney); // 美团优惠金额(实时计算) + result.put("type", payBefor.getType()); + result.put("paytype", paytype); + result.put("usersBalance", user.getBalance()); + result.put("couponId", couponId); + result.put("mtcode", mtcode); + result.put("servicetype", payBefor.getServicetype()); + result.put("paymentFormula", paymentFormula.toString()); // 支付公式 + + // 添加抵扣限制说明 + Map deductionInfo = new HashMap<>(); + deductionInfo.put("maxDeductibleAmount", maxDeductibleAmount); // 最大可抵扣金额 + deductionInfo.put("remainingDeductible", remainingDeductible); // 剩余可抵扣金额 + deductionInfo.put("userServiceBalance", userServiceBalance); // 用户服务金余额 + deductionInfo.put("userShopBalance", userShopBalance); // 用户购物金余额 + deductionInfo.put("maxServiceDeductible", maxServiceDeductible); // 服务金最大可抵扣金额 + deductionInfo.put("maxShopDeductible", maxShopDeductible); // 购物金最大可抵扣金额 + deductionInfo.put("deductionRule", "消费金和服务金抵扣不能超过订单金额减去会员优惠后的金额,且不能超过用户实际余额"); + result.put("deductionInfo", deductionInfo); + +// // 添加计算明细,方便前端理解金额构成 +// Map calculationDetail = new HashMap<>(); +// calculationDetail.put("originalAmount", originalAmount); +// calculationDetail.put("memberDiscount", memberMoney); +// calculationDetail.put("serviceDiscount", serviceMoney); +// calculationDetail.put("shopDiscount", shopMoney); +// calculationDetail.put("couponDiscount", couponMoney); +// calculationDetail.put("mtDiscount", mtMoney); +// calculationDetail.put("finalAmount", actualAmount); +// result.put("calculationDetail", calculationDetail); + + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("查询预支付记录失败:", e); + return AppletControllerUtil.appletError("查询预支付记录失败:" + e.getMessage()); + } + } + /** * 根据订单类型创建相应的订单 */ @@ -1447,21 +1480,26 @@ public class AppleOrderController extends BaseController { BigDecimal itemPrice = totalAmount; // 生成订单号 String orderId = GenerateCustomCode.generCreateOrder("N"); - + String mainorderId = GenerateCustomCode.generCreateOrder("MYKJ"); // 创建普通预约订单(统一使用服务订单表) Order order = new Order(); order.setNum(Long.valueOf(num)); order.setType(1); // 普通预约订单 order.setCreateType(1); // 用户自主下单 order.setOrderId(orderId); + order.setMainOrderId(mainorderId); order.setUid(user.getId()); order.setReamk(reamk); order.setUname(user.getName()); order.setProductId(serviceGoods.getId()); order.setProductName(serviceGoods.getTitle()); order.setSku(sku); - order.setCartid(cikaid); order.setBigtype(serviceGoods.getServicetype()); + if(StringUtils.isNotBlank(cikaid)){ + order.setTotalPrice(serviceGoods.getFixedprice()); + order.setCartid(cikaid); + + } // order.setc if (userAddress != null) { order.setAddressId(userAddress.getId()); @@ -1486,7 +1524,7 @@ public class AppleOrderController extends BaseController { } order.setTotalPrice(itemPrice); - order.setGoodPrice(serviceGoods.getPrice()); + order.setGoodPrice(BigDecimal.ZERO); order.setServicePrice(BigDecimal.ZERO); order.setPayPrice(itemPrice); //有次卡直接形成订单 @@ -1627,12 +1665,13 @@ public class AppleOrderController extends BaseController { // 生成订单号 String orderId = GenerateCustomCode.generCreateOrder("S"); - + String mainorderId = GenerateCustomCode.generCreateOrder("MS"); // 创建秒杀订单(使用服务订单表) Order order = new Order(); order.setType(3); // 秒杀类型 order.setCreateType(1); // 用户自主下单 order.setOrderId(orderId); + order.setMainOrderId(mainorderId); order.setReamk(reamk); order.setUid(user.getId()); order.setUname(user.getName()); @@ -1664,7 +1703,7 @@ public class AppleOrderController extends BaseController { } order.setTotalPrice(itemPrice); - order.setGoodPrice(serviceGoods.getFixedprice()); + order.setGoodPrice(BigDecimal.ZERO); order.setServicePrice(BigDecimal.ZERO); order.setPayPrice(itemPrice); order.setStatus(11L); // 待待接单 @@ -1771,7 +1810,7 @@ public class AppleOrderController extends BaseController { //order.setNum(num); order.setTotalPrice(itemPrice); - order.setGoodPrice(serviceGoods.getPrice()); + order.setGoodPrice(BigDecimal.ZERO); order.setServicePrice(BigDecimal.ZERO); order.setPayPrice(itemPrice); order.setStatus(8L); // 待待报价 @@ -1860,10 +1899,44 @@ public class AppleOrderController extends BaseController { // 检查carid和address_id参数 Object carIdsObj = params.get("carid"); Object addressIdObj = params.get("address_id"); + Object isselfObj = params.get("isself"); + if (isselfObj == null) { + isselfObj=2L; + } // if (params.get("product_id") == null || params.get("num") == null) { // return AppletControllerUtil.appletWarning("单品下单参数(product_id, num, sku, mark)不能为空"); // } if (addressIdObj == null) { + if ( params.get("product_id") != null) { + long isself= Long.parseLong(params.get("isself").toString()); + if (params.get("isself")==null) { + isself=2L; + } + Long product_id=Long.valueOf(params.get("product_id").toString()); + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(product_id); + if (serviceGoods.getIsforservice()==1) { + if (serviceGoods != null||isself==1) { + int num=Integer.valueOf(params.get("num").toString()); + String sku = params.get("sku").toString(); + String mark = params.get("mark").toString(); + if (serviceGoods.getType() == 2) { + BigDecimal totalAmount2 = BigDecimal.ZERO; + Map orderResult = Map.of(); + UserAddress userAddress=new UserAddress(); + orderResult= CartOrderUtil.createGoodsOrderFromOnes(user, sku,num, mark,serviceGoods, userAddress, goodsOrderService,maincorid,isself) ; + totalAmount2 = totalAmount2.add(new BigDecimal(orderResult.get("allprice").toString())); + if (totalAmount2.compareTo(BigDecimal.ZERO) > 0) { + String orderid= orderResult.get("orderId").toString(); + String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount2, orderid, null, null, 11L, null, null, null, null, null, Long.valueOf(serviceGoods.getType()),null,null); + Map result1 = new HashMap<>(); + result1.put("type", "2"); + result1.put("orderid", payBeforeId); + return AppletControllerUtil.appletSuccess(result1); + } + } + } + } + } return AppletControllerUtil.appletWarning("address_id不能为空"); } Long addressId; @@ -1889,19 +1962,30 @@ public class AppleOrderController extends BaseController { try { product_id = Long.valueOf(params.get("product_id").toString()); } catch (Exception e) { return AppletControllerUtil.appletWarning("product_id格式错误"); } String sku = params.get("sku").toString(); String mark = params.get("mark").toString(); + String orderid=""; ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(product_id); if (serviceGoods == null) { return AppletControllerUtil.appletWarning("商品ID " + product_id + " 不存在"); } Map orderResult = Map.of(); if (serviceGoods.getType() == 2) { - orderResult= CartOrderUtil.createGoodsOrderFromOnes(user, sku,num, mark,serviceGoods, userAddress, goodsOrderService,maincorid) ; + orderResult= CartOrderUtil.createGoodsOrderFromOnes(user, sku,num, mark,serviceGoods, userAddress, goodsOrderService,maincorid,Long.parseLong(isselfObj.toString())) ; } if (!(Boolean) orderResult.getOrDefault("success", false)) { + return AppletControllerUtil.appletWarning(orderResult.getOrDefault("msg", "下单失败").toString()); } + orderid= orderResult.get("orderId").toString(); orderList.add(orderResult); totalAmount = totalAmount.add(new BigDecimal(orderResult.get("allprice").toString())); + if (totalAmount.compareTo(BigDecimal.ZERO) > 0) { + String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount, orderid, null, null, 11L, null, null, null, null, null, Long.valueOf(serviceGoods.getType()),null,null); + Map result1 = new HashMap<>(); + result1.put("type", "2"); + result1.put("orderid", payBeforeId); + return AppletControllerUtil.appletSuccess(result1); + } + }else{ List carIds; try { @@ -1921,7 +2005,7 @@ public class AppleOrderController extends BaseController { } Map orderResult; if (cart.getGoodstype() != null && cart.getGoodstype() == 2) { - orderResult = CartOrderUtil.createGoodsOrderFromCart(user, cart, serviceGoods, userAddress, goodsOrderService,maincorid); + orderResult = CartOrderUtil.createGoodsOrderFromCart(user, cart, serviceGoods, userAddress, goodsOrderService,maincorid,Long.parseLong(isselfObj.toString())); // String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount, maincorid, null, cart.getGoodId(), 6L, cart.getSku(), null, null, null, null,1L, null, null); } else { @@ -1931,16 +2015,22 @@ public class AppleOrderController extends BaseController { } if (!(Boolean) orderResult.getOrDefault("success", false)) { //删除购物车记录 - goodsCartService.deleteGoodsCartById(cart.getId()); + return AppletControllerUtil.appletWarning(orderResult.getOrDefault("msg", "下单失败").toString()); } orderList.add(orderResult); - totalAmount = totalAmount.add(new BigDecimal(orderResult.get("allprice").toString())); - if (cart.getGoodstype()==1&&cart.getOrdertype()==2){ - String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount, maincorid, null, cart.getGoodId(), 6L, cart.getSku(), null, null, null, null,1L, null, null); + goodsCartService.deleteGoodsCartById(cart.getId()); + //只有一口价服务才会有支付 + if (serviceGoods.getServicetype()==3||serviceGoods.getType()==2){ + totalAmount = totalAmount.add(new BigDecimal(orderResult.get("allprice").toString())); + } + + if (cart.getGoodstype()==1&&totalAmount.compareTo(BigDecimal.ZERO) > 0){ + String orderid= orderResult.get("orderId").toString(); + String payBeforeId = payBeforeUtil.createPayBefore(user, totalAmount, orderid, null, cart.getGoodId(), 6L, cart.getSku(), null, null, null, null,1L, null, null); Map result1 = new HashMap<>(); result1.put("type", "2"); - result1.put("orderid", maincorid); + result1.put("orderid", orderid); return AppletControllerUtil.appletSuccess(result1); } } @@ -2021,13 +2111,14 @@ public class AppleOrderController extends BaseController { queryOrder.setBaojiayh(user.getId()); }else{ if (status == 4){ - List idslist=new ArrayList<>(); - idslist.add("4"); - idslist.add("7"); - queryOrder.setIds(idslist); - +// List idslist=new ArrayList<>(); +// idslist.add("4"); +// idslist.add("7"); +// queryOrder.setIds(idslist); + queryOrder.setStatus(4L); + queryOrder.setIsComment(1); }else if (status == 13){ - queryOrder.setStatus(6L); + queryOrder.setStatus(4L); queryOrder.setIsComment(0); queryOrder.setIspay("1"); }else { @@ -2130,21 +2221,31 @@ public class AppleOrderController extends BaseController { List quotationList = getQuotationList(order.getOrderId()); orderMap.put("quoteCount", quotationList.size()); orderMap.put("quotationList", buildQuotationList(quotationList)); - // 师傅信息(如果已派单) - if (order.getWorkerId() != null) { - Users worker = usersService.selectUsersById(order.getWorkerId()); - if (worker != null) { - Map workerMap = new HashMap<>(); - workerMap.put("workerName", worker.getName()); - workerMap.put("workerAvatar", AppletControllerUtil.buildImageUrl(worker.getAvatar())); - workerMap.put("workerPhone", worker.getPhone()); - orderMap.put("workerMap", workerMap); - } - } +// // 师傅信息(如果已派单) +// if (order.getWorkerId() != null) { +// Users worker = usersService.selectUsersById(order.getWorkerId()); +// if (worker != null) { +// Map workerMap = new HashMap<>(); +// workerMap.put("workerName", worker.getName()); +// workerMap.put("workerAvatar", AppletControllerUtil.buildImageUrl(worker.getAvatar())); +// workerMap.put("workerPhone", worker.getPhone()); +// orderMap.put("workerMap", workerMap); +// } +// } } - // 师傅信息(如果已派单) if (order.getWorkerId() != null) { + Users worker = usersService.selectUsersById(order.getWorkerId()); + if (worker != null&&order.getIsAccept()==1) { + Map workerMap = new HashMap<>(); + workerMap.put("workerName", worker.getName()); + workerMap.put("workerAvatar", AppletControllerUtil.buildImageUrl(worker.getAvatar())); + workerMap.put("workerPhone", worker.getPhone()); + orderMap.put("workerMap", workerMap); + } + } + // 师傅信息(如果已派单) + if (order.getWorkerId() != null&&order.getIsAccept()==1) { Users worker = usersService.selectUsersById(order.getWorkerId()); if (worker != null) { orderMap.put("workerName", worker.getName()); @@ -2365,7 +2466,7 @@ public class AppleOrderController extends BaseController { } } - /** + /**.. * 确认报价接口 * @param params 请求参数 {"orderid": "订单号", "baojiaid": "报价ID"} * @param request HTTP请求对象 @@ -2521,6 +2622,7 @@ public class AppleOrderController extends BaseController { @RequestParam(value = "day", required = false) String day, HttpServletRequest request) { try { + Map allMap = new HashMap<>(); // 1. 验证用户登录状态 String token = request.getHeader("token"); Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); @@ -2577,52 +2679,43 @@ public class AppleOrderController extends BaseController { queryOrder.setIds(idslist); }else{ queryOrder.setStatus(Long.valueOf(status)); + } } orderList = orderService.selectOrderList(queryOrder); } - -// // 2. 查询逻辑 -// if (status != null && status == 8) { -// // 查询所有status=8的订单 -// Order queryOrder = new Order(); -// queryOrder.setStatus(8L); -// orderList = orderService.selectOrderList(queryOrder); -// } else if (status != null && status == 12) { -// // 查询当前师傅报过价且status=1的报价,查其orderid对应订单 -// UserDemandQuotation query = new UserDemandQuotation(); -// query.setWorkerid(user.getId()); -// query.setStatus(1L); // 1=已报价 -// List quoteList = userDemandQuotationService.selectUserDemandQuotationList(query); -// List orderIds = new ArrayList<>(); -// for (UserDemandQuotation q : quoteList) { -// if (q.getOrderid() != null) { -// orderIds.add(q.getOrderid()); -// } -// } -// orderList = new ArrayList<>(); -// if (!orderIds.isEmpty()) { -// for (String oid : orderIds) { -// Order o = orderService.selectOrderByOrderId(oid); -// if (o != null) orderList.add(o); -// } -// } -// } else { -// // 普通师傅订单查询 -// Order queryOrder = new Order(); -// queryOrder.setWorkerId(user.getId()); -// if (status != null) { -// queryOrder.setStatus(Long.valueOf(status)); -// } -// orderList = orderService.selectOrderList(queryOrder); -// } // 3. 分页处理 int total = orderList.size(); int fromIndex = Math.max(0, (pageNum - 1) * pageSize); int toIndex = Math.min(fromIndex + pageSize, total); List pageOrderList = fromIndex < toIndex ? orderList.subList(fromIndex, toIndex) : new ArrayList<>(); + Map dayMap = new HashMap<>(); + if(status!=null){ + + Order queryOrderday = new Order(); + queryOrderday.setStatus(Long.valueOf(status)); + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + long todayStart = cal.getTimeInMillis() / 1000; + long tomorrowStart = todayStart + 24 * 60 * 60; + queryOrderday.setMakeTimeStart(todayStart); + + queryOrderday.setMakeTimeEnd(tomorrowStart); + List dayOrderList = orderService.selectOrderList(queryOrderday); + dayMap.put("today", dayOrderList.size()); + queryOrder.setMakeTimeStart(tomorrowStart); + queryOrder.setMakeTimeEnd(tomorrowStart + 24 * 60 * 60); + List tomorrowOrderList1 = orderService.selectOrderList(queryOrderday); + dayMap.put("tomorrow", tomorrowOrderList1.size()); + } + + // 4. 构建返回数据(与/api/service/order/list一致) List> resultList = new ArrayList<>(); + //resultList.add(dayMap); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd"); for (Order order : pageOrderList) { @@ -2640,6 +2733,16 @@ public class AppleOrderController extends BaseController { // 订单类型 orderMap.put("bigtype", getOrderBigType(order.getBigtype())); orderMap.put("bigtypeText", getOrderBigTypeText(order.getBigtype())); + if (order.getWorkerId() != null) { + Users worker = usersService.selectUsersById(order.getWorkerId()); + if (worker != null) { + Map workerMap = new HashMap<>(); + workerMap.put("workerName", worker.getName()); + workerMap.put("workerAvatar", AppletControllerUtil.buildImageUrl(worker.getAvatar())); + workerMap.put("workerPhone", worker.getPhone()); + orderMap.put("workerMap", workerMap); + } + } // 商品信息 ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); if (serviceGoods != null) { @@ -2706,11 +2809,23 @@ public class AppleOrderController extends BaseController { resultList.add(orderMap); } Map pageResult = new HashMap<>(); - pageResult.put("total", total); +// pageResult.put("total", total); +// +// pageResult.put("pageNum", pageNum); +// pageResult.put("pageSize", pageSize); +// pageResult.put("data", resultList); +// return AppletControllerUtil.appletSuccess(pageResult); + + pageResult.put("pageNum", pageNum); pageResult.put("pageSize", pageSize); pageResult.put("data", resultList); - return AppletControllerUtil.appletSuccess(pageResult); + Map pageResult1 = new HashMap<>(); + + pageResult1.put("data", pageResult); + pageResult1.put("total", dayMap); + return AppletControllerUtil.appletSuccess(pageResult1); + } catch (Exception e) { logger.error("查询师傅订单列表失败:", e); return AppletControllerUtil.appletError("查询师傅订单列表失败:" + e.getMessage()); @@ -2884,44 +2999,163 @@ public class AppleOrderController extends BaseController { @RequestParam(value = "pageSize", defaultValue = "10") int pageSize ) { try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); OrderComment query = new OrderComment(); - if (orderId != null && !orderId.trim().isEmpty()) query.setOrderId(orderId); - if (productId != null) query.setProductId(productId); - if (uid != null) query.setUid(uid); - if (workerId != null) query.setWorkerId(workerId); - if (numType != null) query.setNumType(numType); - List allList = orderCommentService.selectOrderCommentList(query); - int total = allList.size(); - int fromIndex = Math.max(0, (pageNum - 1) * pageSize); - int toIndex = Math.min(fromIndex + pageSize, total); - List pageList = fromIndex < toIndex ? allList.subList(fromIndex, toIndex) : new ArrayList<>(); - List> resultList = new ArrayList<>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - for (OrderComment c : pageList) { - Map cMap = new HashMap<>(); - Users usersdata = usersService.selectUsersById(c.getUid()); - cMap.put("userName", usersdata != null ? usersdata.getName() : ""); - cMap.put("userAvatar", usersdata != null ? AppletControllerUtil.buildImageUrl(usersdata.getAvatar()) : ""); - cMap.put("score", c.getNum()); - cMap.put("labels", c.getLabels() != null ? JSONArray.parseArray(c.getLabels()) : null); - cMap.put("images",c.getImages() != null ? JSONArray.parseArray(c.getImages()): null ); - cMap.put("numType", c.getNumType()); - cMap.put("content", c.getContent()); - cMap.put("date", c.getCreatedAt() != null ? sdf.format(c.getCreatedAt()) : ""); - resultList.add(cMap); + if (orderId != null && !orderId.isEmpty()) { + query.setOrderId(orderId); } - Map pageResult = new HashMap<>(); - pageResult.put("total", total); - pageResult.put("pageNum", pageNum); - pageResult.put("pageSize", pageSize); - pageResult.put("data", resultList); - return AppletControllerUtil.appletSuccess(pageResult); + if (productId != null) { + query.setProductId(productId); + } + if (uid != null) { + query.setUid(uid); + } + if (workerId != null) { + query.setWorkerId(workerId); + } + if (numType != null) { + query.setNumType(numType); + } + + // 设置分页参数 + PageHelper.startPage(pageNum, pageSize); + List commentList = orderCommentService.selectOrderCommentList(query); + PageInfo pageInfo = new PageInfo<>(commentList); + + // 构建返回数据 + List> resultList = new ArrayList<>(); + for (OrderComment comment : commentList) { + Map commentData = new HashMap<>(); + commentData.put("id", comment.getId()); + commentData.put("orderId", comment.getOrderId()); + commentData.put("productId", comment.getProductId()); + commentData.put("uid", comment.getUid()); + commentData.put("workerId", comment.getWorkerId()); + commentData.put("numType", comment.getNumType()); + commentData.put("content", comment.getContent()); + commentData.put("createdAt",comment.getCreatedAt() != null ? sdf.format(comment.getCreatedAt()) : ""); + if (comment.getImages()!=null){ + commentData.put("image",JSONArray.parseArray(comment.getImages())); + }else{ + commentData.put("image",JSONArray.parseArray("[]")); + } + if (comment.getLabels()!=null){ + commentData.put("labels",JSONArray.parseArray(comment.getLabels())); + }else{ + commentData.put("labels",JSONArray.parseArray("[]")); + } + // 获取用户信息 + if (comment.getUid() != null) { + Users user = usersService.selectUsersById(comment.getUid()); + if (user != null) { + Map userData = new HashMap<>(); + userData.put("id", user.getId()); + userData.put("nickname", user.getName()); + userData.put("avatar", AppletControllerUtil.buildImageUrl(user.getAvatar())); + commentData.put("user", userData); + } + } + + resultList.add(commentData); + } + + Map result = new HashMap<>(); + result.put("data", resultList); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("pageSize", pageInfo.getPageSize()); + result.put("pages", pageInfo.getPages()); + + return AppletControllerUtil.appletSuccess(result); } catch (Exception e) { logger.error("查询评价列表失败:", e); return AppletControllerUtil.appletError("查询评价列表失败:" + e.getMessage()); } } + + + /** + * 首页推荐栏目接口 + * 返回树状结构的一级目录和二级目录数据 + * 一级目录来自IServiceCateService,二级目录来自IServiceGoodsService + * + * @return 推荐栏目树状数据 + */ + @GetMapping("/api/home/recommend/categories") + public AjaxResult getHomeRecommendCategories() { + try { + // 1. 查询所有启用的一级分类 + ServiceCate queryCate = new ServiceCate(); + queryCate.setStatus(1L); // 启用状态 + queryCate.setType(1L); // 服务类型 + queryCate.setParentId(0L); // 一级分类 + List firstCategories = serviceCateService.selectServiceCateList(queryCate); + + // 2. 查询销量排名前50的服务 + List topSalesGoods = serviceGoodsService.selectServiceGoodsListBySales(100); + + // 3. 按一级分类ID分组服务 + Map> goodsByFirstCate = topSalesGoods.stream() + .filter(goods -> goods.getFirstCateId() != null) + .collect(Collectors.groupingBy(ServiceGoods::getFirstCateId)); + + // 4. 构建树状结构 + List> treeData = new ArrayList<>(); + + for (ServiceCate firstCate : firstCategories) { + // 检查该一级分类是否有热门服务 + List relatedGoods = goodsByFirstCate.get(firstCate.getId()); + if (relatedGoods != null && !relatedGoods.isEmpty()) { + Map firstCateData = new HashMap<>(); + firstCateData.put("id", firstCate.getId()); + firstCateData.put("title", firstCate.getTitle()); + firstCateData.put("type", "category"); // 标识为分类 + + // 构建二级服务列表 + List> secondLevel = new ArrayList<>(); + for (ServiceGoods goods : relatedGoods) { + Map goodsData = new HashMap<>(); + goodsData.put("id", goods.getId()); + goodsData.put("title", goods.getTitle()); + goodsData.put("price", goods.getPrice()); + goodsData.put("sales", goods.getSales()); + goodsData.put("type", "service"); // 标识为服务 + secondLevel.add(goodsData); + } + + firstCateData.put("children", secondLevel); + treeData.add(firstCateData); + } + } + + // 5. 按一级分类下的服务数量排序 + treeData.sort((a, b) -> { + List> childrenA = (List>) a.get("children"); + List> childrenB = (List>) b.get("children"); + return Integer.compare(childrenB.size(), childrenA.size()); + }); + + // 6. 限制返回数量(前10个一级分类) + if (treeData.size() > 10) { + treeData = treeData.subList(0, 10); + } + + // 7. 限制每个一级分类下的服务数量(最多5个) + for (Map firstCateData : treeData) { + List> children = (List>) firstCateData.get("children"); + if (children.size() > 5) { + firstCateData.put("children", children.subList(0, 5)); + } + } + + return AppletControllerUtil.appletSuccess(treeData); + } catch (Exception e) { + logger.error("获取首页推荐栏目失败:", e); + return AppletControllerUtil.appletError("获取首页推荐栏目失败:" + e.getMessage()); + } + } + /** * 报价查看接口 * 查询指定订单下的所有报价,支持价格和时间共存排序 @@ -2944,6 +3178,7 @@ public class AppleOrderController extends BaseController { @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, HttpServletRequest request) { try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 1. 验证用户登录状态 String token = request.getHeader("token"); Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); @@ -3076,7 +3311,7 @@ public class AppleOrderController extends BaseController { // 6. 构建返回数据 List> resultList = new ArrayList<>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); for (UserDemandQuotation quotation : pageQuotations) { @@ -3879,11 +4114,26 @@ public class AppleOrderController extends BaseController { /** * 协议类型接口,返回写死的数据 */ - @GetMapping("/api/public/getusertest/{id}") - public AjaxResult getusertest(@PathVariable("id") Long id) { + @GetMapping("/api/user/logout") + public AjaxResult getusertest(HttpServletRequest request) { + // 1. 校验用户登录 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + user.setLoginStatus(1); + int count = usersService.updateUsers(user); + if (count > 0) { + return AppletControllerUtil.appletSuccess("用户登出成功"); + }else{ + return AppletControllerUtil.appletWarning("用户登出失败"); + } - List data = OrderUtil.getDispatchWorkerList(id); - return AjaxResult.success(data); } /** @@ -4191,4 +4441,1740 @@ public class AppleOrderController extends BaseController { } } + /** + * 商品确认收货接口 + * @param id 商品订单ID + * @param request HTTP请求对象 + * @return 确认收货结果 + */ + @GetMapping("/api/goods/order/confirm/receipt") + public AjaxResult confirmGoodsOrderReceipt(@RequestParam("id") Long id, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取商品订单ID + Long orderId = id; + if (orderId == null) { + return AppletControllerUtil.appletError("商品订单ID不能为空"); + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } + +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权操作此订单"); +// } + + // 5. 验证订单状态(只有已发货状态才能确认收货) + if (goodsOrder.getStatus() != 3L) { + return AppletControllerUtil.appletError("订单状态不正确,无法确认收货"); + } + + // 6. 更新订单状态为已收货 + goodsOrder.setStatus(4L); + int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder); + + if (updateResult > 0) { + // 7. 添加订单日志 + com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); + jsonObject.put("name", "用户确认收货"); + OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "确认收货", "3", jsonObject, 2L); + + Map result = new HashMap<>(); + result.put("message", "确认收货成功"); + result.put("orderId", goodsOrder.getOrderId()); + result.put("status", goodsOrder.getStatus()); + + return AppletControllerUtil.appletSuccess(result); + } else { + return AppletControllerUtil.appletError("确认收货失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("商品确认收货失败:", e); + return AppletControllerUtil.appletError("确认收货失败:" + e.getMessage()); + } + } + + /** + * 查询商品订单详情接口 + * @param id 订单ID + * @param request HTTP请求对象 + * @return 商品订单详情 + */ + @GetMapping("/api/goods/order/detail") + public AjaxResult getGoodsOrderDetail(@RequestParam("id") Long id, HttpServletRequest request) { + try { + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取订单ID + Long orderId = id; + if (orderId == null) { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + // 3. 查询商品订单基本信息 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } + +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权查看此订单"); +// } + + // 5. 查询商品基本信息 + ServiceGoods serviceGoods = null; + if (goodsOrder.getProductId() != null) { + serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsOrder.getProductId()); + } + +// // 6. 查询订单日志 +// List orderLogs = orderLogService.selectOrderLogByOrderId(goodsOrder.getOrderId()); + // 6. 查询订单日志 + OrderLog logQuery = new OrderLog(); + logQuery.setOid(goodsOrder.getId()); + logQuery.setOrdertype(2L); + List logList = orderLogService.selectOrderLogList(logQuery); + List> logArr = new ArrayList<>(); + for (OrderLog log : logList) { + Map logMap = new HashMap<>(); + logMap.put("id", log.getId()); + logMap.put("oid", log.getOid()); + logMap.put("order_id", log.getOrderId()); + logMap.put("log_order_id", log.getLogOrderId()); + logMap.put("title", log.getTitle()); + logMap.put("type", log.getType()); + Object contentObj = null; + // content字段为json字符串,需转为对象 + if (log.getTitle().equals("已完成")) { + OrderComment comment = new OrderComment(); + comment.setOid(log.getOid()); + List commentList = orderCommentService.selectOrderCommentList(comment); + if(!commentList.isEmpty()){ + OrderComment commentDATA = commentList.getFirst(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("num",commentDATA.getNum()); + jsonObject.put("status",commentDATA.getStatus()); + jsonObject.put("text",commentDATA.getContent()); + if (commentDATA.getImages()!=null){ + jsonObject.put("image",JSONArray.parseArray(commentDATA.getImages())); + } + if (commentDATA.getLabels()!=null){ + jsonObject.put("labels",JSONArray.parseArray(commentDATA.getLabels())); + } + + contentObj=jsonObject; + }else{ + JSONObject jsonObject = new JSONObject(); + + jsonObject.put("status",0); + contentObj=jsonObject; + } + }else if (log.getTitle().equals("订单已发货")){ + + contentObj = JSONObject.parse(log.getContent()); + }else{ + try { + if (log.getContent() != null) { + contentObj = JSONObject.parse(log.getContent()); + } + } catch (Exception e) { + + if (AppletControllerUtil.canParseToJSONArray(log.getContent())) { + contentObj = JSONArray.parseArray(log.getContent()); + } else { + contentObj = log.getContent(); + } + + } + } + + + logMap.put("content", contentObj); + + logMap.put("deposit", log.getDeposit()); + logMap.put("dep_paid", log.getDepPaid()); + logMap.put("dep_pay_time", log.getDepPayTime()); + logMap.put("dep_log_id", log.getDepLogId()); + logMap.put("cj_money", log.getCjMoney()); + logMap.put("cj_paid", log.getCjPaid()); + logMap.put("price", log.getPrice()); + logMap.put("paid", log.getPaid()); + logMap.put("pay_time", log.getPayTime()); + logMap.put("log_id", log.getLogId()); + logMap.put("worker_id", log.getWorkerId()); + + logMap.put("first_worker_id", log.getFirstWorkerId()); + logMap.put("give_up", log.getGiveUp()); + logMap.put("worker_cost", log.getWorkerCost()); + logMap.put("reduction_price", log.getReductionPrice()); + logMap.put("is_pause", log.getIsPause()); + logMap.put("coupon_id", log.getCouponId()); + logMap.put("deduction", log.getDeduction()); + logMap.put("worker_log_id", log.getWorkerLogId()); + logMap.put("created_at", log.getCreatedAt() != null ? dateFormat.format(log.getCreatedAt()) : null); + logMap.put("updated_at", log.getUpdatedAt() != null ? dateFormat.format(log.getUpdatedAt()) : null); + logMap.put("deleted_at", log.getDeletedAt()); + //报价倒计时 + logMap.put("orderstatus", goodsOrder.getStatus()); + logMap.put("ordertype", goodsOrder.getType()); + logArr.add(logMap); +// if (!log.getTitle().equals("师傅跟单")) { +// +// } + + } +// // 7. 构建订单状态时间线 +// List> timeline = buildOrderTimeline(goodsOrder, orderLogs); + + // 8. 构建商品信息 + Map productInfo = buildProductInfo(goodsOrder, serviceGoods); + + // 9. 构建订单信息 + Map orderInfo = buildOrderInfo(goodsOrder); + + + ShopAddress shopAddress = shopAddressService.selectShopAddressById(1L); + + // 10. 构建返回结果 + Map result = new HashMap<>(); + result.put("orderId", goodsOrder.getOrderId()); + result.put("shopAddress", shopAddress); + result.put("status", goodsOrder.getStatus()); + result.put("timeline", logArr); + result.put("product", productInfo); + result.put("orderInfo", orderInfo); + + // 11. 添加退货数据(如果有退货信息) + if (goodsOrder.getReturntype() != null || goodsOrder.getReturnreason() != null || goodsOrder.getReturnjson() != null) { + Map returnInfo = new HashMap<>(); + returnInfo.put("returntype", goodsOrder.getReturntype()); + returnInfo.put("returnreason", goodsOrder.getReturnreason()); + if (goodsOrder.getReturnfiledata() != null){ + returnInfo.put("returnfiledata",JSONArray.parseArray(goodsOrder.getReturnfiledata())); + }else{ + returnInfo.put("returnfiledata", JSONArray.parseArray("[]")); + } + + returnInfo.put("returntime", goodsOrder.getReturntime() != null ? dateFormat.format(goodsOrder.getReturntime() ) : null); + if (goodsOrder.getReturnshow() != null){ + returnInfo.put("returnshow", com.alibaba.fastjson2.JSONObject.parseObject(goodsOrder.getReturnshow())); + }else{ + JSONObject returnJsonObject2 = new JSONObject(); + returnJsonObject2.put("title","售后"); + returnJsonObject2.put("content","售后处理中,请耐心等待!"); + returnInfo.put("returnshow", returnJsonObject2.toJSONString()); + } + //returnInfo.put("returnshow", goodsOrder.getReturnshow()); + returnInfo.put("returnmoney", goodsOrder.getReturnmoney()); + returnInfo.put("returnfinshtime", goodsOrder.getReturnfinshtime()!= null ? dateFormat.format(goodsOrder.getReturnfinshtime() ) : null); + returnInfo.put("returnstatus", goodsOrder.getReturnstatus()); + returnInfo.put("returnlogistics", goodsOrder.getReturnlogistics()); + returnInfo.put("returnlogisticscode", goodsOrder.getReturnlogisticscode()); + + // 解析退货流程JSON + if (goodsOrder.getReturnjson() != null && !goodsOrder.getReturnjson().trim().isEmpty()) { + try { + JSONArray returnJsonArray = JSONArray.parseArray(goodsOrder.getReturnjson()); + returnInfo.put("returnjson", returnJsonArray); + } catch (Exception e) { + logger.error("解析退货JSON失败:", e); + } + } else { + } + result.put("returnInfo", returnInfo); + } + + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("查询商品订单详情失败:", e); + return AppletControllerUtil.appletError("查询订单详情失败:" + e.getMessage()); + } + } + + + + /** + * 构建商品信息 + */ + private Map buildProductInfo(GoodsOrder goodsOrder, ServiceGoods serviceGoods) { + Map productInfo = new HashMap<>(); + + if (serviceGoods != null) { + productInfo.put("id", serviceGoods.getId()); + productInfo.put("title", serviceGoods.getTitle()); + productInfo.put("icon",AppletControllerUtil.buildImageUrl(serviceGoods.getIcon())); + productInfo.put("price", serviceGoods.getPrice()); + } else { + productInfo.put("id", goodsOrder.getProductId()); + productInfo.put("title", goodsOrder.getProductName()); + productInfo.put("icon", ""); + productInfo.put("price", goodsOrder.getGoodPrice()); + } + + productInfo.put("num", goodsOrder.getNum()); + productInfo.put("sku", AppletControllerUtil.parseSkuStringToObject(goodsOrder.getSku())); + + return productInfo; + } + + /** + * 构建订单信息 + */ + private Map buildOrderInfo(GoodsOrder goodsOrder) { + Map orderInfo = new HashMap<>(); + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrder.getOrderId()); + if (usersPayBefor == null){ + usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrder.getMainOrderId()); + } + if (usersPayBefor != null){ + orderInfo.put("totalPrice", usersPayBefor.getAllmoney()); + orderInfo.put("payPrice", usersPayBefor.getAllmoney()); + orderInfo.put("deduction", usersPayBefor.getCouponmoney()); + orderInfo.put("membermoney", usersPayBefor.getMembermoney()); + orderInfo.put("mtmoney", usersPayBefor.getMtmoney()); + orderInfo.put("paytype", usersPayBefor.getPaytype()); + orderInfo.put("shopmoney", usersPayBefor.getShopmoney()); + orderInfo.put("wxmoney", usersPayBefor.getWxmoney()); + orderInfo.put("yemoney", usersPayBefor.getYemoney()); + + } + //orderInfo.put("sku", AppletControllerUtil.parseSkuStringToObject(goodsOrder.getSku())); + orderInfo.put("orderId", goodsOrder.getOrderId()); + orderInfo.put("postage", goodsOrder.getPostage() != null ? goodsOrder.getPostage() : BigDecimal.ZERO); + // logMap.put("created_at", log.getCreatedAt() != null ? dateFormat.format(log.getCreatedAt()) : null); + orderInfo.put("createdAt", goodsOrder.getCreatedAt() != null ? dateFormat.format(goodsOrder.getCreatedAt()) : null); + orderInfo.put("payTime", goodsOrder.getPayTime() != null ? dateFormat.format( goodsOrder.getPayTime()) : null); + orderInfo.put("transactionId", goodsOrder.getTransactionId()); + orderInfo.put("name", goodsOrder.getName()); + orderInfo.put("status", goodsOrder.getStatus()); + orderInfo.put("phone", goodsOrder.getPhone()); + orderInfo.put("address", goodsOrder.getAddress()); + orderInfo.put("isself", goodsOrder.getIsself()); + orderInfo.put("mark", goodsOrder.getMark()); + UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrder.getAddressId()); + if (userAddress != null){ + orderInfo.put("latitude", userAddress.getLatitude()); + orderInfo.put("longitude", userAddress.getLongitude()); + }else{ + orderInfo.put("latitude", null); + orderInfo.put("longitude", null); + } + +// // 计算优惠金额 +// BigDecimal totalPrice = goodsOrder.getTotalPrice() != null ? goodsOrder.getTotalPrice() : BigDecimal.ZERO; +// BigDecimal payPrice = goodsOrder.getPayPrice() != null ? goodsOrder.getPayPrice() : BigDecimal.ZERO; +// BigDecimal deduction = goodsOrder.getDeduction() != null ? goodsOrder.getDeduction() : BigDecimal.ZERO; +// +// BigDecimal discountAmount = totalPrice.subtract(payPrice).subtract(deduction); +// orderInfo.put("discountAmount", discountAmount); + + return orderInfo; + } + + // 辅助方法:解析JSON数组字符串为List + + /** + * 退货接口 + * @param params 请求参数 {"orderId": "订单ID", "refundAmount": "退款金额", "refundType": "退款类别", "refundReason": "退款原因", "voucher": "凭证"} + * @param request HTTP请求对象 + * @return 退货处理结果 + */ + @PostMapping("/api/goods/order/return") + public AjaxResult returnGoodsOrder(@RequestBody Map params, HttpServletRequest request) { + try { + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取请求参数 + Long orderId = null; + BigDecimal refundAmount = null; + Integer refundType = null; + String refundReason = null; + + if (params.get("orderId") != null) { + try { + orderId = Long.valueOf(params.get("orderId").toString()); + } catch (NumberFormatException e) { + return AppletControllerUtil.appletError("订单ID格式错误"); + } + } else { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + if (params.get("refundAmount") != null) { + try { + refundAmount = new BigDecimal(params.get("refundAmount").toString()); + } catch (NumberFormatException e) { + return AppletControllerUtil.appletError("退款金额格式错误"); + } + } else { + return AppletControllerUtil.appletError("退款金额不能为空"); + } + + if (params.get("refundType") != null) { + try { + refundType = Integer.valueOf(params.get("refundType").toString()); + if (refundType != 1 && refundType != 2) { + return AppletControllerUtil.appletError("退款类别只能是1(仅退款)或2(退货退款)"); + } + } catch (NumberFormatException e) { + return AppletControllerUtil.appletError("退款类别格式错误"); + } + } else { + return AppletControllerUtil.appletError("退款类别不能为空"); + } + + refundReason = (String) params.get("refundReason"); + if (refundReason == null || refundReason.trim().isEmpty()) { + return AppletControllerUtil.appletError("退款原因不能为空"); + } + + // 处理附件voucher,支持数组格式 + Object voucherObj = params.get("voucher"); + String voucher = null; + if (voucherObj != null) { + if (voucherObj instanceof String) { + // 如果是字符串,直接使用 + voucher = (String) voucherObj; + } else if (voucherObj instanceof List) { + // 如果是List,转换为JSON字符串 + voucher = JSONArray.toJSONString(voucherObj); + } else { + // 其他情况,转换为字符串 + voucher = voucherObj.toString(); + } + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } + +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权操作此订单"); +// } + + // 5. 验证订单状态(只有已收货状态才能申请退货) +// if (goodsOrder.getStatus() != 5L) { +// return AppletControllerUtil.appletError("订单状态不正确,无法申请退货"); +// } + + // 6. 验证退款金额不能超过支付金额 + BigDecimal payPrice = goodsOrder.getPayPrice() != null ? goodsOrder.getPayPrice() : BigDecimal.ZERO; + if (refundAmount.compareTo(payPrice) > 0) { + return AppletControllerUtil.appletError("退款金额不能超过支付金额"); + } + + // 7. 更新订单退货信息 + goodsOrder.setReturntype(Long.valueOf(refundType)); + goodsOrder.setReturnreason(refundReason); + goodsOrder.setReturnfiledata(voucher); + goodsOrder.setStatus(20L); // 设置为退货状态 + goodsOrder.setReturntime(new Date()); + goodsOrder.setReturnstatus(1L); + goodsOrder.setReturnmoney(refundAmount); + // 构建退货日志JSON数组 + JSONArray returnJsonArray = new JSONArray(); + JSONObject returnJsonObject = new JSONObject(); + // returnJsonObject.put("title", refundType == 1 ? "申请仅退款" : "申请退货退款"); + returnJsonObject.put("title", "申请退款"); + returnJsonObject.put("time",dateFormat.format(new Date())); + returnJsonObject.put("desc", 1); + returnJsonArray.add(returnJsonObject); + JSONObject returnJsonObject2 = new JSONObject(); + returnJsonObject2.put("title","退款中"); + returnJsonObject2.put("content","平台将在72小时为您处理,请耐心等待!"); + goodsOrder.setReturnshow(returnJsonObject2.toJSONString()); + goodsOrder.setReturnjson(returnJsonArray.toJSONString()); + + // 8. 更新订单 + int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder); + + if (updateResult > 0) { +// // 9. 添加订单日志 +// com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); +// jsonObject.put("name", refundType == 1 ? "申请仅退款" : "申请退货退款"); +// jsonObject.put("refundAmount", refundAmount); +// jsonObject.put("refundReason", refundReason); +// jsonObject.put("voucher", voucher); +// +// OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), +// refundType == 1 ? "申请仅退款" : "申请退货退款", "6", jsonObject, 2L); +// +// Map result = new HashMap<>(); +// result.put("message", "退货申请提交成功"); +// result.put("orderId", goodsOrder.getOrderId()); +// result.put("status", goodsOrder.getStatus()); +// result.put("refundAmount", refundAmount); +// result.put("refundType", refundType); + + return AppletControllerUtil.appletSuccess("操作成功"); + } else { + return AppletControllerUtil.appletError("退货申请提交失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("退货申请失败:", e); + return AppletControllerUtil.appletError("退货申请失败:" + e.getMessage()); + } + } + + // 辅助方法:解析JSON数组字符串为List + + /** + * 撤销售后接口 + * @param id 订单ID + * @param request HTTP请求对象 + * @return 撤销售后结果 + */ + @GetMapping("/api/goods/order/cancel/return") + public AjaxResult cancelReturnGoodsOrder(@RequestParam("id") Long id, HttpServletRequest request) { + try { + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取订单ID + Long orderId = id; + if (orderId == null) { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } + + // 7. 更新订单状态为已完成 + goodsOrder.setReturnstatus(7L); + goodsOrder.setStatus(5L); + JSONArray returnfiledataArray = JSON.parseArray(goodsOrder.getReturnjson()); + JSONObject returnfiledataObject = new JSONObject(); + returnfiledataObject.put("time",dateFormat.format(new Date())); + returnfiledataObject.put("desc",returnfiledataArray.size()+1); + returnfiledataObject.put("title","撤销"); + returnfiledataArray.add(returnfiledataObject); + goodsOrder.setReturnjson(returnfiledataArray.toJSONString()); + JSONObject returnJsonObject2 = new JSONObject(); + returnJsonObject2.put("title","撤销退款"); + returnJsonObject2.put("content","撤销退款,平台此条售后记录将不再进行!"); + goodsOrder.setReturnshow(returnJsonObject2.toJSONString()); + + int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder); + + if (updateResult > 0) { + + + return AppletControllerUtil.appletSuccess("操作成功"); + } else { + return AppletControllerUtil.appletError("撤销售后失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("撤销售后失败:", e); + return AppletControllerUtil.appletError("撤销售后失败:" + e.getMessage()); + } + } + + // 辅助方法:解析JSON数组字符串为List + + /** + * 退货添加物流信息接口 + * @param params 请求参数 {"id": "订单ID", "logistics": "物流公司", "logisticsCode": "物流单号"} + * @param request HTTP请求对象 + * @return 添加物流信息结果 + */ + @PostMapping("/api/goods/order/return/logistics") + public AjaxResult addReturnLogistics(@RequestBody Map params, HttpServletRequest request) { + try { + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取请求参数 + Long orderId = null; + String logistics = null; + String logisticsCode = null; + + if (params.get("id") != null) { + try { + orderId = Long.valueOf(params.get("id").toString()); + } catch (NumberFormatException e) { + return AppletControllerUtil.appletError("订单ID格式错误"); + } + } else { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + logistics = (String) params.get("logistics"); + if (logistics == null || logistics.trim().isEmpty()) { + return AppletControllerUtil.appletError("物流公司不能为空"); + } + + logisticsCode = (String) params.get("logisticsCode"); + if (logisticsCode == null || logisticsCode.trim().isEmpty()) { + return AppletControllerUtil.appletError("物流单号不能为空"); + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } +// +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权操作此订单"); +// } + + // 5. 验证订单状态(只有退货状态才能添加物流信息) +// if (goodsOrder.getStatus() != 6L) { +// return AppletControllerUtil.appletError("订单状态不正确,无法添加物流信息"); +// } + +// // 6. 验证是否有退货数据 +// if (goodsOrder.getReturntype() == null && goodsOrder.getReturnreason() == null) { +// return AppletControllerUtil.appletError("该订单没有售后申请,无法添加物流信息"); +// } + + // 7. 更新退货物流信息 + goodsOrder.setReturnlogistics(logistics); + goodsOrder.setReturnlogisticscode(logisticsCode); + goodsOrder.setReturnstatus(4L); + JSONArray returnfiledataArray = JSON.parseArray(goodsOrder.getReturnjson()); + JSONObject returnfiledataObject = new JSONObject(); + returnfiledataObject.put("time",dateFormat.format(new Date())); + returnfiledataObject.put("desc",returnfiledataArray.size()+1); + returnfiledataObject.put("title","待收货"); + returnfiledataArray.add(returnfiledataObject); + goodsOrder.setReturnjson(returnfiledataArray.toJSONString()); + int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder); + + if (updateResult > 0) { +// // 9. 添加订单日志 +// com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); +// jsonObject.put("name", "添加退货物流信息"); +// jsonObject.put("logistics", logistics); +// jsonObject.put("logisticsCode", logisticsCode); +// jsonObject.put("logisticsTime", new Date()); +// +// OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "添加退货物流", "6", jsonObject, 2L); +// +// Map result = new HashMap<>(); +// result.put("message", "退货物流信息添加成功"); +// result.put("orderId", goodsOrder.getOrderId()); +// result.put("logistics", logistics); +// result.put("logisticsCode", logisticsCode); + + return AppletControllerUtil.appletSuccess("操作成功"); + } else { + return AppletControllerUtil.appletError("退货物流信息添加失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("退货物流信息添加失败:", e); + return AppletControllerUtil.appletError("退货物流信息添加失败:" + e.getMessage()); + } + } + + // 辅助方法:解析JSON数组字符串为List + + /** + * 评价删除接口 + * @param id 订单ID + * @param request HTTP请求对象 + * @return 评价删除结果 + */ + @GetMapping("/api/goods/order/delete/comment") + public AjaxResult deleteOrderComment(@RequestParam("id") Long id, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 获取订单ID + Long orderId = id; + if (orderId == null) { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(orderId); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } +// +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权操作此订单"); +// } +// + // 5. 查询评价数据 + OrderComment commentQuery = new OrderComment(); + commentQuery.setOid(orderId); + List commentList = orderCommentService.selectOrderCommentList(commentQuery); + + if (commentList == null || commentList.isEmpty()) { + return AppletControllerUtil.appletError("该订单没有评价数据"); + } + + // 6. 更新评价状态为删除 + int updateCount = 0; + for (OrderComment comment : commentList) { + comment.setStatus(0); // 设置为删除状态 + int updateResult = orderCommentService.updateOrderComment(comment); + if (updateResult > 0) { + updateCount++; + } + } + + if (updateCount > 0) { + // 7. 添加订单日志 + com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); + jsonObject.put("name", "用户删除评价"); + jsonObject.put("deleteTime", new Date()); + jsonObject.put("deleteCount", updateCount); + + OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "删除评价", "5", jsonObject, 2L); + + Map result = new HashMap<>(); + result.put("message", "评价删除成功"); + result.put("orderId", goodsOrder.getOrderId()); + result.put("deleteCount", updateCount); + + return AppletControllerUtil.appletSuccess(result); + } else { + return AppletControllerUtil.appletError("评价删除失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("评价删除失败:", e); + return AppletControllerUtil.appletError("评价删除失败:" + e.getMessage()); + } + } + + // 辅助方法:解析JSON数组字符串为List + + /** + * 删除商品订单接口 + * @param id 订单ID + * @param request HTTP请求对象 + * @return 删除结果 + */ + @GetMapping("/api/goods/order/delete") + public AjaxResult deleteGoodsOrder(@RequestParam("id") Long id, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 2. 验证订单ID + if (id == null) { + return AppletControllerUtil.appletError("订单ID不能为空"); + } + + // 3. 查询商品订单 + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(id); + if (goodsOrder == null) { + return AppletControllerUtil.appletError("商品订单不存在"); + } + +// // 4. 验证订单所属用户 +// if (!goodsOrder.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletError("无权删除此订单"); +// } + + // 5. 检查订单状态,防止删除已支付或进行中的订单 + if (goodsOrder.getStatus() != null && goodsOrder.getStatus() >= 2) { + return AppletControllerUtil.appletError("已支付或进行中的订单不能删除"); + } + + // 6. 删除订单 + int deleteResult = goodsOrderService.deleteGoodsOrderById(id); + + if (deleteResult > 0) { + Map result = new HashMap<>(); + result.put("message", "订单删除成功"); + result.put("orderId", goodsOrder.getOrderId()); + result.put("deleteTime", new Date()); + + return AppletControllerUtil.appletSuccess(result); + } else { + return AppletControllerUtil.appletError("订单删除失败,请稍后重试"); + } + + } catch (Exception e) { + logger.error("删除商品订单失败:", e); + return AppletControllerUtil.appletError("删除商品订单失败:" + e.getMessage()); + } + } + + /** + * 获取弹窗列表 + * @return 弹窗列表数据 + */ + @GetMapping("/api/popup/list") + public AjaxResult getPopupList() { + try { + // 查询config_shiyi配置 + SiteConfig siteConfig = siteConfigService.selectSiteConfigByName("config_shiyi"); + + if (siteConfig == null || StringUtils.isEmpty(siteConfig.getValue())) { + // 如果没有配置或值为空,返回空的弹窗列表 + Map result = new HashMap<>(); + result.put("popups", new ArrayList<>()); + return AppletControllerUtil.appletSuccess(result); + } + + // 解析JSON数据 + ObjectMapper objectMapper = new ObjectMapper(); + Map configData = objectMapper.readValue(siteConfig.getValue(), Map.class); + + // 获取弹窗列表 + List> popups = (List>) configData.get("popups"); + if (popups == null) { + popups = new ArrayList<>(); + } + + // 过滤掉已下线的弹窗 + List> activePopups = popups.stream() + .filter(popup -> { + Object status = popup.get("status"); + return status != null && Integer.valueOf(status.toString()) == 1; + }) + .collect(Collectors.toList()); + + // 按排序字段排序 + activePopups.sort((a, b) -> { + Object sortA = a.get("sort"); + Object sortB = b.get("sort"); + int sortAValue = sortA != null ? Integer.valueOf(sortA.toString()) : 0; + int sortBValue = sortB != null ? Integer.valueOf(sortB.toString()) : 0; + return Integer.compare(sortAValue, sortBValue); + }); + + Map result = new HashMap<>(); + result.put("popups", activePopups); + + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("获取弹窗列表失败:", e); + return AppletControllerUtil.appletError("获取弹窗列表失败:" + e.getMessage()); + } + } + + /** + * 师傅申请退回 + * 将师傅的质保金提现给师傅,并关闭师傅账户 + */ + @PostMapping("/api/worker/apply/refund") + public AjaxResult applyWorkerRefund(HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users worker = (Users) userValidation.get("user"); + if (worker == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } +// // 查询师傅信息 +// Users worker = usersService.selectUsersById(userId); +// if (worker == null) { +// return AppletControllerUtil.appletError("师傅信息不存在"); +// } + + // 检查师傅状态 + if (worker.getStatus() == 0) { + return AppletControllerUtil.appletError("师傅账户已被关闭"); + } + +// // 查询师傅质保金总额 +// BigDecimal totalMargin = worker.getMargin(); +// if (totalMargin == null || totalMargin.compareTo(BigDecimal.ZERO) <= 0) { +// return AppletControllerUtil.appletError("师傅质保金余额不足"); +// } + +// // 记录质保金提现日志 +// WorkerMarginLog marginLog = new WorkerMarginLog(); +// marginLog.setUid(userId); +// marginLog.setPrice(totalMargin.negate()); // 负数表示扣减 +// marginLog.setReamk("师傅申请退回,质保金提现"); +// marginLog.setCreatedAt(new Date()); +// marginLog.setUpdatedAt(new Date()); +// +// // 插入质保金变动记录 +// workerMarginLogService.insertWorkerMarginLog(marginLog); +// +// // 更新师傅质保金为0 + worker.setMargin(BigDecimal.ZERO); +// +// // 关闭师傅账户 + // worker.setStatus(0); + worker.setType("1"); + // 更新师傅信息 + int updateResult = usersService.updateUsers(worker); + if (updateResult <= 0) { + return AppletControllerUtil.appletError("更新师傅信息失败"); + } + + Map result = new HashMap<>(); + + result.put("message", "申请退回成功,质保金已提现"); + + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("师傅申请退回失败", e); + return AppletControllerUtil.appletError("申请退回失败: " + e.getMessage()); + } + } + + @PostMapping("/api/worker/grab") + public AjaxResult workerGrabOrder(@RequestBody Map params, HttpServletRequest request) { + try { + + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users currentUser = (Users) userValidation.get("user"); + if (currentUser == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + + // 获取订单ID + Long orderId = null; + if (params.get("id") != null) { + if (params.get("id") instanceof Integer) { + orderId = ((Integer) params.get("id")).longValue(); + } else if (params.get("id") instanceof Long) { + orderId = (Long) params.get("id"); + } else { + orderId = Long.parseLong(params.get("id").toString()); + } + } + + if (orderId == null) { + return AppletControllerUtil.appletWarning("订单ID不能为空"); + } + + // 查询订单数据 + Order order = orderService.selectOrderById(orderId); + if (order == null) { + return AppletControllerUtil.appletWarning("订单不存在"); + } + + // 检查订单状态是否为1(待接单) + if (order.getStatus() == null || order.getStatus() != 1L) { + return AppletControllerUtil.appletWarning("订单状态不正确,无法接单"); + } + +// // 获取当前登录用户(师傅) +// String token = request.getHeader("token"); +// if (StringUtils.isEmpty(token)) { +// return AppletControllerUtil.appletdengluWarning("用户未登录"); +// } +// +//// Users currentUser = AppletLoginUtil.getUserByToken(token); +//// if (currentUser == null) { +//// return AppletControllerUtil.appletdengluWarning("用户未登录或token无效"); +//// } +// Users currentUser = (Users) userValidation.get("user"); +// if (currentUser == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } + + +// // 检查用户是否为师傅 +// if (!"2".equals(currentUser.getType()) || currentUser.getIsWork() != 1) { +// return AppletControllerUtil.appletWarning("只有师傅才能接单"); +// } + + // 检查订单是否已被其他师傅接单 + if (order.getWorkerId() != null && order.getWorkerId() > 0) { + return AppletControllerUtil.appletWarning("该订单已被其他师傅接单"); + } + + // 更新订单状态为2(待服务)并分配师傅 + order.setStatus(2L); + order.setWorkerId(currentUser.getId()); + order.setReceiveTime(new Date()); + order.setReceiveType(1L); // 1:自由抢单 + order.setIsAccept(1); // 1:已经接单 + + // 如果是第一次接单,设置firstWorkerId + if (order.getFirstWorkerId() == null) { + order.setFirstWorkerId(currentUser.getId()); + } + + // 更新订单 + int updateResult = orderService.updateOrder(order); + if (updateResult <= 0) { + return AppletControllerUtil.appletError("订单状态更新失败"); + } + + // 添加订单日志 + OrderLog orderLog = new OrderLog(); + orderLog.setOid(orderId); + orderLog.setOrderId(order.getOrderId()); + orderLog.setLogOrderId(order.getOrderId()); + orderLog.setTitle("师傅接单"); + orderLog.setType(new BigDecimal("2")); // 2:接单 + JSONObject content = new JSONObject(); + content.put("name", "师傅" + currentUser.getName() + "接单成功"); + orderLog.setContent(content.toJSONString()); + orderLog.setWorkerId(currentUser.getId()); + orderLog.setWorkerName(currentUser.getName()); + orderLog.setFirstWorkerId(currentUser.getId()); + orderLog.setOrdertype(1L); + + int logResult = orderLogService.insertOrderLog(orderLog); + if (logResult <= 0) { + logger.warn("订单日志添加失败,订单ID:{}", orderId); + } + + return AppletControllerUtil.appletSuccess("接单成功"); + + } catch (Exception e) { + logger.error("师傅接单失败:", e); + return AppletControllerUtil.appletError("接单失败:" + e.getMessage()); + } + } + + @PostMapping("/api/public/get/article/cate") + public AjaxResult getArticleByCate(@RequestBody Map params) { + try { + logger.info("=== 开始获取分类文章 ==="); + logger.info("请求参数: {}", params); + + // 获取参数 + String cate = null; + if (params.get("cate") != null) { + cate = params.get("cate").toString(); + } + + Boolean strip = false; + if (params.get("strip") != null) { + if (params.get("strip") instanceof Boolean) { + strip = (Boolean) params.get("strip"); + } else if (params.get("strip") instanceof String) { + strip = Boolean.parseBoolean((String) params.get("strip")); + } else if (params.get("strip") instanceof Integer) { + strip = ((Integer) params.get("strip")) == 1; + } + } + + logger.info("分类参数: {}, 是否去除标签: {}", cate, strip); + + // 参数验证 + if (cate == null || cate.trim().isEmpty()) { + logger.warn("分类参数为空"); + return AppletControllerUtil.appletWarning("分类参数不能为空"); + } + + // 查询文章内容 + Content queryContent = new Content(); + queryContent.setId(Long.valueOf(cate)); + + List contentList = contentService.selectContentList(queryContent); + + if (contentList == null || contentList.isEmpty()) { + logger.warn("未找到分类为 {} 的文章", cate); + return AppletControllerUtil.appletWarning("未找到相关文章"); + } + + // 按sort排序,获取第一条记录 + Content content = contentList.stream() + .sorted((c1, c2) -> { + Integer sort1 = Math.toIntExact(c1.getSort() != null ? c1.getSort() : 0); + Integer sort2 = Math.toIntExact(c2.getSort() != null ? c2.getSort() : 0); + return sort1.compareTo(sort2); + }) + .findFirst() + .orElse(null); + + if (content == null) { + logger.warn("未找到有效的文章内容"); + return AppletControllerUtil.appletWarning("未找到相关文章"); + } + + logger.info("找到文章: ID={}, 标题={}", content.getId(), content.getTitle()); + + // 构建返回数据 + Map result = new HashMap<>(); + result.put("id", content.getId()); + result.put("title", content.getTitle()); + + String contentText = content.getContent(); + if (contentText != null && !contentText.trim().isEmpty()) { + if (strip) { + // 去除富文本标签并截取前130个字符 + String strippedContent = AppletControllerUtil.stripHtmlTags(contentText); + if (strippedContent.length() > 130) { + contentText = strippedContent.substring(0, 130) + " ......"; + } else { + contentText = strippedContent; + } + logger.info("已去除HTML标签,截取后内容长度: {}", contentText.length()); + } + result.put("content", contentText); + } else { + result.put("content", ""); + } + + logger.info("=== 获取分类文章完成 ==="); + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("获取分类文章异常", e); + return AppletControllerUtil.appletError("获取文章失败:" + e.getMessage()); + } + } + + + + @PostMapping("/api/service/order/rework/lst") + public AjaxResult getReworkList(@RequestBody Map params, HttpServletRequest request) { + try { + logger.info("=== 开始获取售后返修列表 ==="); + logger.info("请求参数: {}", params); + + // 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + Users currentUser = (Users) userValidation.get("user"); + if (currentUser == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + logger.info("当前用户ID: {}", currentUser.getId()); + + // 获取分页参数 + int pageNum = 1; + int pageSize = 10; + + if (params.get("limit") != null) { + try { + pageSize = Integer.parseInt(params.get("limit").toString()); + if (pageSize <= 0) { + pageSize = 10; + } + } catch (NumberFormatException e) { + logger.warn("limit参数格式错误,使用默认值10"); + pageSize = 10; + } + } + + logger.info("分页参数 - 页码: {}, 每页大小: {}", pageNum, pageSize); + + // 构建查询条件 + OrderRework queryRework = new OrderRework(); + queryRework.setUid(currentUser.getId()); + + // 状态筛选 + if (params.get("status") != null) { + try { + Integer status = Integer.parseInt(params.get("status").toString()); + if (status == 0 || status == 1) { + queryRework.setStatus(status); + logger.info("状态筛选: {}", status); + } else { + logger.warn("状态参数无效: {}, 不进行状态筛选", status); + } + } catch (NumberFormatException e) { + logger.warn("status参数格式错误,不进行状态筛选"); + } + } + + // 设置分页 + PageHelper.startPage(pageNum, pageSize); + + // 查询数据 + List reworkList = orderReworkService.selectOrderReworkList(queryRework); + PageInfo pageInfo = new PageInfo<>(reworkList); + + logger.info("查询到售后返修记录数量: {}", pageInfo.getTotal()); + + // 构建返回数据 + Map result = new HashMap<>(); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("pageSize", pageInfo.getPageSize()); + result.put("pages", pageInfo.getPages()); + result.put("data", AppletControllerUtil.buildReworkList(reworkList)); + + logger.info("=== 获取售后返修列表完成 ==="); + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("获取售后返修列表异常", e); + return AppletControllerUtil.appletError("获取售后返修列表失败:" + e.getMessage()); + } + } + + + + /** + * 录音上传接口 + * + * @param file 录音文件 + * @param id 订单ID + * @param request HTTP请求对象 + * @return 上传结果 + */ + @PostMapping("/api/worker/order/sound") + public AjaxResult uploadOrderSound(@RequestParam("file") MultipartFile file, + @RequestParam("id") Long id, + HttpServletRequest request) { + try { + logger.info("=== 开始录音上传,订单ID: {} ===", id); + + // 1. 验证文件是否为空 + if (file == null || file.isEmpty()) { + logger.warn("录音文件为空"); + return AppletControllerUtil.appletWarning("录音文件不能为空"); + } + + // 2. 验证文件格式(只允许音频格式) + String[] allowedTypes = { + "mp3", "wav", "aac", "m4a", "ogg", "flac", "wma", "amr" + }; + + String originalFilename = file.getOriginalFilename(); + if (originalFilename == null || !isValidAudioFile(originalFilename, allowedTypes)) { + logger.warn("录音文件格式不支持: {}", originalFilename); + return AppletControllerUtil.appletWarning("只允许上传音频文件格式:mp3, wav, aac, m4a, ogg, flac, wma, amr"); + } + + // 3. 验证文件大小(50MB) + long maxSize = 50 * 1024 * 1024; + if (file.getSize() > maxSize) { + logger.warn("录音文件大小超过限制: {} bytes", file.getSize()); + return AppletControllerUtil.appletWarning("录音文件大小不能超过50MB"); + } + + // 4. 验证订单是否存在 + Order order = orderService.selectOrderById(id); + if (order == null) { + logger.warn("订单不存在,订单ID: {}", id); + return AppletControllerUtil.appletWarning("订单不存在"); + } + + // 5. 获取当前用户信息 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + logger.warn("用户未登录"); + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + Users currentUser = (Users) userValidation.get("user"); + if (currentUser == null) { + logger.warn("用户信息获取失败"); + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 6. 上传文件到本地 + String uploadPath = RuoYiConfig.getUploadPath() + "/sound/" + id; + String fileName = FileUploadUtils.upload(uploadPath, file); + String fileUrl = "/sound/" + id + "/" + fileName; + logger.info("uploadPath录音文件上传成功,文件路径: {}", uploadPath); + logger.info("fileUrl录音文件上传成功,文件路径: {}", fileUrl); + +// // 7. 保存录音记录到数据库 +// OrderSoundLog orderSound = new OrderSoundLog(); +// orderSound.setOid(id); +// orderSound.setOcode(order.getOrderId()); +// orderSound.setFile(fileUrl); +// orderSound.setWorkerUid(currentUser.getId()); +// orderSound.setWorkerName(currentUser.getNickname()); +// orderSound.setCreatedAt(new Date()); +// orderSound.setUpdatedAt(new Date()); + +// int result = orderSoundService.insertOrderSound(orderSound); +// if (result <= 0) { +// logger.error("保存录音记录失败"); +// return AppletControllerUtil.appletError("保存录音记录失败"); +// } + OrderSoundLog orderSound = new OrderSoundLog(); + orderSound.setOid(id); + orderSound.setFile(fileUrl); + orderSound.setIsMerge(1); + logger.info("录音记录保存成功,记录ID: {}", System.currentTimeMillis()/1000); + orderSound.setCreatedAt(System.currentTimeMillis()/1000); + int result= orderSoundLogService.insertOrderSoundLog(orderSound); + logger.info("录音记录保存成功,记录ID: {}", orderSound.getId()); + // int result = orderSoundService.insertOrderSound(orderSound); + if (result <= 0) { + logger.error("保存录音记录失败"); + return AppletControllerUtil.appletError("保存录音记录失败"); + } + // 8. 构建返回数据 + Map resultData = new HashMap<>(); + resultData.put("id", orderSound.getId()); + resultData.put("file", fileUrl); + resultData.put("fileName", fileName); + resultData.put("originalFilename", originalFilename); + resultData.put("size", file.getSize()); + resultData.put("uploadTime", new Date()); + + logger.info("=== 录音上传完成 ==="); + return AppletControllerUtil.appletSuccess(resultData); + + } catch (Exception e) { + logger.error("录音上传异常", e); + return AppletControllerUtil.appletError("录音上传失败:" + e.getMessage()); + } + } + + /** + * 验证音频文件格式 + * + * @param filename 文件名 + * @param allowedTypes 允许的文件类型 + * @return 是否有效 + */ + private boolean isValidAudioFile(String filename, String[] allowedTypes) { + if (filename == null || filename.isEmpty()) { + return false; + } + + String extension = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase(); + for (String type : allowedTypes) { + if (type.equalsIgnoreCase(extension)) { + return true; + } + } + return false; + } + + /** + * 合并录音MP3文件接口 + * 专门处理查询到的录音MP3文件,进行合并并插入数据库 + * + * @param oid 订单ID + * @param request HTTP请求对象 + * @return 合并结果 + */ + @PostMapping("/api/worker/order/sound/merge") + public AjaxResult mergeOrderSound(@RequestParam("oid") Long oid, HttpServletRequest request) { + try { + logger.info("=== 开始合并录音MP3文件,订单ID: {} ===", oid); + + // 1. 验证订单是否存在 + Order order = orderService.selectOrderById(oid); + if (order == null) { + logger.warn("订单不存在,订单ID: {}", oid); + return AppletControllerUtil.appletWarning("订单不存在"); + } + + // 2. 获取当前用户信息 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + logger.warn("用户未登录"); + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + Users currentUser = (Users) userValidation.get("user"); + if (currentUser == null) { + logger.warn("用户信息获取失败"); + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + + // 3. 查询需要合并的录音MP3文件 + OrderSoundLog queryLog = new OrderSoundLog(); + queryLog.setOid(oid); + queryLog.setIsMerge(1); // 1表示未合并 + List soundLogs = orderSoundLogService.selectOrderSoundLogList(queryLog); + + if (soundLogs == null || soundLogs.isEmpty()) { + logger.warn("没有需要合并的录音MP3文件,订单ID: {}", oid); + return AppletControllerUtil.appletWarning("没有需要合并的录音MP3文件"); + } + + logger.info("找到 {} 个需要合并的录音MP3文件", soundLogs.size()); + + // 4. 构建MP3文件路径并验证文件存在性 + List validMp3Files = new ArrayList<>(); + for (OrderSoundLog soundLog : soundLogs) { + String dbFilePath = soundLog.getFile(); + logger.info("数据库中的MP3文件路径: {}", dbFilePath); + + // 验证文件格式是否为MP3 + if (!dbFilePath.toLowerCase().endsWith(".mp3")) { + logger.warn("跳过非MP3文件: {}", dbFilePath); + continue; + } + + // 使用与录音上传接口相同的路径构建逻辑 + String fullFilePath = buildFullFilePath(dbFilePath); + if (fullFilePath != null) { + validMp3Files.add(fullFilePath); + logger.info("成功添加MP3文件: {}", fullFilePath); + } else { + logger.warn("无法找到MP3文件: {}", dbFilePath); + } + } + + if (validMp3Files.isEmpty()) { + logger.warn("所有MP3文件都不存在,订单ID: {}", oid); + return AppletControllerUtil.appletWarning("所有MP3文件都不存在"); + } + + // 5. 检查FFmpeg是否可用 + if (!FFmpegUtilsSimple.isFFmpegAvailable()) { + logger.error("FFmpeg不可用,无法进行MP3文件合并"); + String errorMsg = "FFmpeg不可用,请按以下步骤安装FFmpeg:\n" + + "1. 下载FFmpeg: https://ffmpeg.org/download.html\n" + + "2. 解压到 C:\\ffmpeg\\ 目录\n" + + "3. 将 C:\\ffmpeg\\bin\\ 添加到系统PATH环境变量\n" + + "4. 重启应用程序"; + return AppletControllerUtil.appletError(errorMsg); + } + + // 6. 创建临时目录 + String tempDir = RuoYiConfig.getUploadPath() + "/temp_merge_mp3/"; + File tempDirFile = new File(tempDir); + if (!tempDirFile.exists()) { + tempDirFile.mkdirs(); + } + logger.info("临时目录: {}", tempDir); + + // 7. 生成唯一MP3文件名 + String fileName = "merged_" + System.currentTimeMillis() + "_" + oid + ".mp3"; + String tempOutputPath = tempDir + fileName; + + // 8. 创建FFmpeg输入列表文件 + String inputListFile =AppletControllerUtil.createInputListFile(validMp3Files); + + try { + // 9. 执行FFmpeg合并MP3命令 + boolean mergeSuccess =AppletControllerUtil.executeFFmpegMerge(inputListFile, tempOutputPath); + if (!mergeSuccess) { + throw new Exception("MP3文件合并失败"); + } + + // 10. 验证合并后的MP3文件 + File mergedFile = new File(tempOutputPath); + if (!mergedFile.exists()) { + throw new Exception("合并后的MP3文件未生成"); + } + + // 11. 上传到七牛云 + String qiniuPath = "files/merge_mp3/" + DateUtils.getDate() + "/" + fileName; + String fileUrl = AppletControllerUtil.uploadToQiniu(tempOutputPath, qiniuPath); + + // 12. 保存到数据库 + OrderSound orderSound = new OrderSound(); + orderSound.setOid(oid); + orderSound.setOcode(order.getOrderId()); + orderSound.setFile(qiniuPath); + orderSound.setWorkerUid(currentUser.getId()); + orderSound.setWorkerName(currentUser.getNickname()); + orderSound.setCreatedAt(new Date()); + orderSound.setUpdatedAt(new Date()); + + int result = orderSoundService.insertOrderSound(orderSound); + if (result <= 0) { + throw new Exception("保存录音记录失败"); + } + + // 13. 更新临时文件状态为已合并 + for (OrderSoundLog soundLog : soundLogs) { + soundLog.setIsMerge(2); // 2表示已合并 + orderSoundLogService.updateOrderSoundLog(soundLog); + } + + // 14. 清理临时文件 + AppletControllerUtil.cleanupTempFiles(tempOutputPath, inputListFile); + + // 15. 构建返回数据 + Map resultData = new HashMap<>(); + resultData.put("message", "录音MP3文件合并并上传七牛云成功"); + resultData.put("file_url", fileUrl); + resultData.put("file_path", qiniuPath); + resultData.put("merged_count", validMp3Files.size()); + resultData.put("file_format", "mp3"); + resultData.put("order_id", order.getOrderId()); + resultData.put("worker_name", currentUser.getNickname()); + resultData.put("merge_time", new Date()); + + logger.info("=== 录音MP3文件合并完成,合并了 {} 个文件 ===", validMp3Files.size()); + return AppletControllerUtil.appletSuccess(resultData); + + } catch (Exception e) { + // 清理临时文件 + AppletControllerUtil.cleanupTempFiles(tempOutputPath, inputListFile); + throw e; + } + + } catch (Exception e) { + logger.error("合并录音MP3文件异常", e); + return AppletControllerUtil.appletError("合并录音MP3文件失败:" + e.getMessage()); + } + } + + + + @GetMapping("/api/worker/sound/current/order") + public AjaxResult getCurrentOrder(HttpServletRequest request) { + try { + // 获取token + String token = request.getHeader("token"); + if (StringUtils.isEmpty(token)) { + return AjaxResult.error("token不能为空"); + } + + // 验证用户token + Map userInfo = AppletLoginUtil.validateUserToken(token, usersService); + if (userInfo == null) { + return AjaxResult.error("token验证失败"); + } + + Users user = (Users) userInfo.get("user"); + Long workerId = user.getId(); + + // 初始化返回信息 + Map info = new HashMap<>(); + info.put("oid", null); + info.put("order_id", null); + + // 查询工人待服务的订单(status=2) + Order queryOrder = new Order(); + queryOrder.setWorkerId(workerId); + queryOrder.setStatus(2L); + List orderList = orderService.selectOrderList(queryOrder); + + // 按ID升序排序 + orderList.sort(Comparator.comparing(Order::getId)); + + // 遍历每个订单 + for (Order order : orderList) { + // 查询该订单的日志记录 + OrderLog queryLog = new OrderLog(); + queryLog.setWorkerId(workerId); + queryLog.setOid(order.getId()); + queryLog.setGiveUp(null); // whereNull('give_up') + queryLog.setIsPause(null); // whereNull('is_pause') + + List logList = orderLogService.selectOrderLogList(queryLog); + + // 查找符合条件的日志记录(type为4或5) + OrderLog foundLog = null; + OrderLog stopLog = null; + + for (OrderLog log : logList) { + BigDecimal type = log.getType(); + if (type != null) { + int typeValue = type.intValue(); + + // 查找type为4或5的记录 + if ((typeValue == 4 || typeValue == 5) && foundLog == null) { + foundLog = log; + } + + // 查找停止录音的记录(type > 5) + if (typeValue > 5 && stopLog == null) { + stopLog = log; + } + } + } + + // 如果找到停止录音的记录,跳过该订单 + if (stopLog != null) { + continue; + } + + // 如果找到符合条件的记录,返回该订单信息 + if (foundLog != null) { + info.put("oid", order.getId()); + info.put("order_id", order.getOrderId()); + break; + } + } + + return AjaxResult.success(info); + } catch (Exception e) { + logger.error("获取当前正在进行的单子失败", e); + return AjaxResult.error("获取当前正在进行的单子失败:" + e.getMessage()); + } + } + + /** + * 根据数据库中的相对路径构建完整的文件路径 + * + * @param dbFilePath 数据库中的文件路径(如 /sound/123/filename.mp3) + * @return 完整的文件路径 + */ + private String buildFullFilePath(String dbFilePath) { + if (dbFilePath == null || dbFilePath.isEmpty()) { + return null; + } + + logger.info("构建文件路径,数据库路径: {}", dbFilePath); + + // 方法1:使用与录音上传接口相同的路径构建逻辑 + if (dbFilePath.startsWith("/sound/")) { + // 从 /sound/{id}/{fileName} 提取 id 和 fileName + String[] pathParts = dbFilePath.split("/"); + if (pathParts.length >= 4) { + String orderId = pathParts[2]; + String fileName = pathParts[3]; + String fullPath = RuoYiConfig.getUploadPath() + "/sound/" + orderId + "/" + fileName; + logger.info("方法1构建的完整路径: {}", fullPath); + + File file = new File(fullPath); + if (file.exists() && file.isFile()) { + logger.info("方法1成功找到文件: {}", fullPath); + return fullPath; + } else { + logger.warn("方法1文件不存在: {}", fullPath); + } + } + } + + // 方法2:尝试其他路径组合 + List possiblePaths = new ArrayList<>(); + + // 2.1 使用UploadPath + 数据库路径 + String uploadPath = RuoYiConfig.getUploadPath() + dbFilePath; + possiblePaths.add(uploadPath); + + // 2.2 使用Profile + 数据库路径 + String profilePath = RuoYiConfig.getProfile() + dbFilePath; + possiblePaths.add(profilePath); + + // 2.3 直接使用数据库路径(如果是绝对路径) + possiblePaths.add(dbFilePath); + + // 2.4 如果数据库路径是相对路径,尝试在当前工作目录下查找 + if (dbFilePath.startsWith("/")) { + String currentDirPath = System.getProperty("user.dir") + dbFilePath; + possiblePaths.add(currentDirPath); + } + + // 尝试所有可能的路径 + for (String path : possiblePaths) { + File file = new File(path); + if (file.exists() && file.isFile()) { + logger.info("方法2成功找到文件: {}", path); + return path; + } else { + logger.debug("方法2文件不存在: {}", path); + } + } + + logger.warn("所有方法都无法找到文件: {}", dbFilePath); + return null; + } + + + + /** + * 获取文件扩展名 + * + * @param filePath 文件路径 + * @return 文件扩展名 + */ + private String getFileExtension(String filePath) { + if (filePath == null || filePath.isEmpty()) { + return "mp3"; // 默认格式 + } + + int lastDotIndex = filePath.lastIndexOf("."); + if (lastDotIndex > 0) { + return filePath.substring(lastDotIndex + 1).toLowerCase(); + } + return "mp3"; // 默认格式 + } } + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java index 9e9aec7..51073b9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.ControllerUtil.*; import com.ruoyi.system.domain.*; import com.ruoyi.system.service.*; @@ -1198,6 +1199,7 @@ public class ApplePayController extends BaseController { payBefor.setPaytime(new Date()); usersPayBeforService.updateUsersPayBefor(payBefor); OrderUtil.prepayCallback(payBefor, user); + IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); payResult.put("istowx", 2); return AppletControllerUtil.appletSuccess("支付成功"); } @@ -1213,6 +1215,8 @@ public class ApplePayController extends BaseController { payBefor.setPaytime(new Date()); usersPayBeforService.updateUsersPayBefor(payBefor); OrderUtil.prepayCallback(payBefor, user); + IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId()); + IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); payResult.put("istowx", 2); return AppletControllerUtil.appletSuccess(payResult); } else { @@ -1227,6 +1231,7 @@ public class ApplePayController extends BaseController { payBefor.setPaytime(new Date()); usersPayBeforService.updateUsersPayBefor(payBefor); OrderUtil.prepayCallback(payBefor, user); + IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); payResult.put("istowx", 1); return AppletControllerUtil.appletSuccess("支付成功"); } @@ -1270,6 +1275,8 @@ public class ApplePayController extends BaseController { payBefor.setStatus(2L); // 已支付 usersPayBeforService.updateUsersPayBefor(payBefor); OrderUtil.prepayCallback(payBefor, user); + IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId()); + IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); payResult.put("istowx", 2); return AppletControllerUtil.appletSuccess("余额支付成功"); } else { @@ -1459,4 +1466,101 @@ public class ApplePayController extends BaseController { return AppletControllerUtil.appletError("好友代付失败:" + e.getMessage()); } } + + /** + * 次卡退款接口 + * @param params {"id":次卡使用记录ID} + * @param request HTTP请求对象 + * @return 退款结果 + */ + @PostMapping("/secondary/card/refund") + public AjaxResult secondaryCardRefund(@RequestBody Map params, HttpServletRequest request) { + try { + // 1. 校验参数 + if (params == null || params.get("id") == null) { + return AppletControllerUtil.appletWarning("参数id不能为空"); + } + Long useCardId = Long.valueOf(params.get("id").toString()); + + // 2. 获取用户 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletWarning("用户未登录或token无效"); + } + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletWarning("用户信息获取失败"); + } + + // 3. 查询次卡使用记录详情 + UserUseSecondaryCard useCard = userUseSecondaryCardService.selectUserUseSecondaryCardById(useCardId); + if (useCard == null) { + return AppletControllerUtil.appletWarning("次卡使用记录不存在"); + } + +// // 4. 验证权限(只能退款自己的次卡) +// if (!useCard.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletWarning("无权操作该次卡记录"); +// } + +// // 5. 验证退款状态 +// if (useCard.getStatus() == null || useCard.getStatus() != 2L) { +// return AppletControllerUtil.appletWarning("该次卡记录状态不允许退款,只有已支付的次卡才能退款"); +// } + + // 6. 验证是否已有退款记录 + if (useCard.getStatus() == 3L) { + return AppletControllerUtil.appletWarning("该次卡已申请退款,请勿重复操作"); + } + // 7. 调用微信退款接口 + Map refundResult = wechatPayV3Util.refund(useCard.getOrderid(), + "cika000001", + 1, + 1, + "次卡退款", + WechatPayUtil.PAY_FH + "/api/secondary/card/refund/notify" + ); + // 7. 调用微信退款接口 +// Map refundResult = wechatPayV3Util.refund( +// useCard.getOrderid(), // 原订单号 +// useCard.getPaymoney(), // 退款金额 +// "次卡退款" // 退款原因 +// ); + + // 8. 处理退款结果 + if (refundResult != null && Boolean.TRUE.equals(refundResult.get("success"))) { + // 9. 更新次卡使用记录状态为退款状态 + useCard.setStatus(3L); // 3=退款状态 + useCard.setRemark("退款成功,退款时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + + int updateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(useCard); + if (updateResult > 0) { + Map responseData = new HashMap<>(); + responseData.put("orderid", useCard.getOrderid()); + responseData.put("refundAmount", useCard.getPaymoney()); + responseData.put("refundTime", new Date()); + responseData.put("message", "退款申请成功"); + + logger.info("次卡退款成功 - 用户ID: {}, 次卡使用记录ID: {}, 退款金额: {}", + user.getId(), useCardId, useCard.getPaymoney()); + + return AppletControllerUtil.appletSuccess(responseData); + } else { + return AppletControllerUtil.appletWarning("退款状态更新失败"); + } + } else { + String errorMsg = refundResult != null ? (String) refundResult.get("message") : "微信退款失败"; + logger.error("次卡退款失败 - 用户ID: {}, 次卡使用记录ID: {}, 错误信息: {}", + user.getId(), useCardId, errorMsg); + return AppletControllerUtil.appletWarning("退款申请失败:" + errorMsg); + } + + } catch (Exception e) { + logger.error("次卡退款异常 - 用户ID: {}, 参数: {}, 异常: {}", + request.getHeader("token"), params, e.getMessage()); + return AppletControllerUtil.appletError("次卡退款失败:" + e.getMessage()); + } + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java index 545910c..70b9d90 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java @@ -126,6 +126,1684 @@ public class AppletController extends BaseController { +// +// /** +// * 获取服务分类列表 +// * 功能说明: +// * - 获取状态为启用的服务分类 +// * - 支持二级分类树形结构 +// * - 将二级分类组装在一级分类下的children字段 +// * - 只返回title和icon字段 +// * - 自动添加图片CDN前缀 +// * - 支持用户登录状态验证(可选) +// * +// * @param request HTTP请求对象 +// * @return 分类树形列表数据(只包含title和icon) +// */ +// @GetMapping(value = "/api/service/cate") +// public AjaxResult getServiceCategories(HttpServletRequest request) { +// try { +// // 验证用户登录状态(可选) +// AppletControllerUtil.getUserData(request.getHeader("token"), usersService); +// +// // 1. 查询所有启用状态的服务分类 +// ServiceCate serviceCateQuery = new ServiceCate(); +// serviceCateQuery.setStatus(1L); +// serviceCateQuery.setType(1L); +// List allCategoryList = serviceCateService.selectServiceCateList(serviceCateQuery); +// +// // 2. 分离一级分类和二级分类 +// List firstLevelCategories = new ArrayList<>(); +// Map> secondLevelMap = new HashMap<>(); +// +// for (ServiceCate category : allCategoryList) { +// if (category.getParentId() == null || category.getParentId() == 0L) { +// // 一级分类 +// firstLevelCategories.add(category); +// } else { +// // 二级分类,按父级ID分组 +// secondLevelMap.computeIfAbsent(category.getParentId(), k -> new ArrayList<>()).add(category); +// } +// } +// +// // 3. 构建简化的分类数据(只包含title和icon) +// List> resultList = new ArrayList<>(); +// +// for (ServiceCate firstLevel : firstLevelCategories) { +// Map firstLevelData = new HashMap<>(); +// firstLevelData.put("id", firstLevel.getId()); +// firstLevelData.put("title", firstLevel.getTitle()); +// firstLevelData.put("icon", AppletControllerUtil.buildImageUrl(firstLevel.getIcon())); +// +// // 4. 处理二级分类 +// List> childrenList = new ArrayList<>(); +// List children = secondLevelMap.get(firstLevel.getId()); +// if (children != null && !children.isEmpty()) { +// for (ServiceCate child : children) { +// Map childData = new HashMap<>(); +// childData.put("id", child.getId()); +// childData.put("title", child.getTitle()); +// childData.put("icon", AppletControllerUtil.buildImageUrl(child.getIcon())); +// childrenList.add(childData); +// } +// } +// firstLevelData.put("children", childrenList); +// +// resultList.add(firstLevelData); +// } +// +// return AppletControllerUtil.appletSuccess(resultList); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取服务分类列表失败:" + e.getMessage()); +// } +// } +// /** +// * 获取系统配置信息 +// * 功能说明: +// * - 根据配置名称获取对应的配置值 +// * - 配置值以JSON格式返回 +// * - 支持动态配置管理 +// * +// * @param name 配置项名称 +// * @param request HTTP请求对象 +// * @return 配置信息数据 +// */ +// @GetMapping(value = "/api/public/config/{name}") +// public AjaxResult getConfig(@PathVariable("name") String name, HttpServletRequest request) { +// try { +// // 参数验证 +// if (StringUtils.isEmpty(name)) { +// return AppletControllerUtil.appletWarning("配置名称不能为空"); +// } +// // 查询配置信息 +// SiteConfig config = AppletControllerUtil.getSiteConfig(name, siteConfigService); +// if (config == null) { +// return AppletControllerUtil.appletWarning("未找到指定的配置项:" + name); +// } +// // 解析配置值为JSON对象 +// JSONObject configJson = AppletControllerUtil.parseConfigValue(config.getValue()); +// return AppletControllerUtil.appletSuccess(configJson); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取配置信息失败:" + e.getMessage()); +// } +// } +// /** +// * 获取默认配置信息 +// * +// * @param request HTTP请求对象 +// * @return 返回config_one配置的JSON对象 +// *

+// * 功能说明: +// * - 获取名为"config_one"的系统配置 +// * - 将配置值解析为JSON对象并返回 +// * - 用于小程序获取基础配置信息 +// */ +// @GetMapping(value = "/api/public/get/config") +// public AjaxResult getconfig(HttpServletRequest request) { +// try { +// SiteConfig configQuery = new SiteConfig(); +// configQuery.setName("config_one"); +// List list = siteConfigService.selectSiteConfigList(configQuery); +// if (list != null && !list.isEmpty()) { +// JSONObject jsonObject = JSONObject.parseObject(list.get(0).getValue()); +// return AppletControllerUtil.appletSuccess(jsonObject); +// } else { +// return AppletControllerUtil.appletWarning("未找到默认配置信息"); +// } +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取配置信息失败:" + e.getMessage()); +// } +// } +// /** +// * 查询用户收货地址列表 +// * +// * @param limit 每页显示数量 +// * @param page 页码 +// * @param request HTTP请求对象 +// * @return 分页地址列表 +// *

+// * 请求参数: +// * - limit: 每页显示数量,默认15 +// * - page: 页码,默认1 +// *

+// */ +// @GetMapping("/api/user/address/list") +// public AjaxResult getaddresslist( +// @RequestParam(value = "limit", defaultValue = "15") int limit, +// @RequestParam(value = "page", defaultValue = "1") int page, +// HttpServletRequest request) { +// try { +// // 1. 验证分页参数 +// Map pageValidation = PageUtil.validatePageParams(page, limit); +// if (!(Boolean) pageValidation.get("valid")) { +// return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 4. 设置分页参数 +// PageHelper.startPage(page, limit); +// // 5. 查询用户地址列表 +// UserAddress userAddressQuery = new UserAddress(); +// userAddressQuery.setUid(user.getId()); +// List addressList = userAddressService.selectUserAddressList(userAddressQuery); +// // 6. 获取分页信息并构建响应 +// TableDataInfo tableDataInfo = getDataTable(addressList); +// // 7. 构建符合要求的分页响应格式 +// Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); +// return AppletControllerUtil.appletSuccess(pageData); +// } catch (Exception e) { +// System.err.println("查询用户地址列表异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("查询地址列表失败:" + e.getMessage()); +// } +// } +// /** +// * 根据地址ID查询用户收货地址详情 +// * +// * @param id 地址ID +// * @param request HTTP请求对象 +// * @return 地址详细信息 +// *

+// * 接口说明: +// * - 根据地址ID获取单个地址的详细信息 +// * - 验证用户登录状态和地址归属权 +// * - 返回AddressApple格式的地址数据,用于前端修改页面 +// *

+// */ +// @GetMapping("/api/user/address/info/{id}") +// public AjaxResult getAddressInfo(@PathVariable("id") Long id, HttpServletRequest request) { +// try { +// // 1. 参数验证 +// if (id == null || id <= 0) { +// return AppletControllerUtil.appletWarning("地址ID无效"); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 4. 查询地址信息 +// UserAddress userAddress = userAddressService.selectUserAddressById(id); +// if (userAddress == null) { +// return AppletControllerUtil.appletWarning("地址不存在"); +// } +// // 5. 验证地址归属权 +// if (!userAddress.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletWarning("无权访问该地址信息"); +// } +// // 6. 转换为AddressApple格式并返回 +// AddressApple addressApple = AddressApple.fromUserAddress(userAddress); +// return AppletControllerUtil.appletSuccess(addressApple); +// } catch (Exception e) { +// System.err.println("查询用户地址详情异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("查询地址详情失败:" + e.getMessage()); +// } +// } +// /** +// * 修改用户收货地址 +// * +// * @param params 地址修改参数 +// * @param request HTTP请求对象 +// * @return 修改结果 +// * 接口说明: +// * - 验证用户登录状态和地址归属权 +// * - 支持修改地址的所有字段 +// * - 自动处理默认地址逻辑(设为默认时会取消其他默认地址) +// * - 返回修改后的地址信息 +// */ +// @PostMapping("/api/user/address/edit") +// public AjaxResult editAddress(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 参数验证 +// if (params == null || params.get("id") == null) { +// return AppletControllerUtil.appletWarning("地址ID不能为空"); +// } +// Long addressId; +// try { +// addressId = Long.valueOf(params.get("id").toString()); +// if (addressId <= 0) { +// return AppletControllerUtil.appletWarning("地址ID无效"); +// } +// } catch (NumberFormatException e) { +// return AppletControllerUtil.appletWarning("地址ID格式错误"); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 4. 查询原地址信息并验证归属权 +// UserAddress existingAddress = userAddressService.selectUserAddressById(addressId); +// if (existingAddress == null) { +// return AppletControllerUtil.appletWarning("地址不存在"); +// } +// if (!existingAddress.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletWarning("无权修改该地址"); +// } +// // 5. 构建更新的地址对象 +// UserAddress updateAddress = AppletControllerUtil.buildUpdateAddress(params, addressId, user.getId()); +// // 6. 验证必填字段 +// String validationResult = AppletControllerUtil.validateAddressParams(updateAddress); +// if (validationResult != null) { +// return AppletControllerUtil.appletWarning(validationResult); +// } +// // 7. 处理默认地址逻辑 +// if (updateAddress.getIsDefault() != null && updateAddress.getIsDefault() == 1L) { +// // 如果设置为默认地址,先将该用户的所有地址设为非默认 +// userAddressService.updateUserAddressDefault(user.getId()); +// } +// // 8. 执行地址更新 +// int updateResult = userAddressService.updateUserAddress(updateAddress); +// if (updateResult > 0) { +// return AppletControllerUtil.appletSuccess("地址修改成功"); +// } else { +// return AppletControllerUtil.appletWarning("地址修改失败"); +// } +// } catch (Exception e) { +// System.err.println("修改用户地址异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("修改地址失败:" + e.getMessage()); +// } +// } +// /** +// * 新增用户收货地址 +// * +// * @param params 地址新增参数 +// * @param request HTTP请求对象 +// * @return 新增结果 +// * 接口说明: +// * - 验证用户登录状态 +// * - 支持新增地址的所有字段 +// * - 自动处理默认地址逻辑(设为默认时会取消其他默认地址) +// * - 返回新增后的地址信息 +// */ +// @PostMapping("/api/user/address/add") +// public AjaxResult addAddress(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 构建新增的地址对象 +// UserAddress newAddress = AppletControllerUtil.buildNewAddress(params, user.getId()); +// // 4. 验证必填字段 +// String validationResult = AppletControllerUtil.validateAddressParams(newAddress); +// if (validationResult != null) { +// return AppletControllerUtil.appletWarning(validationResult); +// } +// // 5. 处理默认地址逻辑 +// if (newAddress.getIsDefault() != null && newAddress.getIsDefault() == 1L) { +// // 如果设置为默认地址,先将该用户的所有地址设为非默认 +// userAddressService.updateUserAddressDefault(user.getId()); +// } +// // 6. 执行地址新增 +// int insertResult = userAddressService.insertUserAddress(newAddress); +// if (insertResult > 0) { +// return AppletControllerUtil.appletSuccess("地址新增成功"); +// } else { +// return AppletControllerUtil.appletWarning("地址新增失败"); +// } +// } catch (Exception e) { +// System.err.println("新增用户地址异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("新增地址失败:" + e.getMessage()); +// } +// } +// /** +// * 售后返修申请接口 +// * +// * @param params 请求参数 包含order_id(订单ID)、phone(联系电话)、mark(返修原因备注) +// * @param request HTTP请求对象 +// * @return 返修申请结果 +// *

+// * 功能说明: +// * - 验证用户登录状态和订单归属权 +// * - 检查订单状态是否允许申请售后 +// * - 处理售后返修申请逻辑 +// * - 更新订单状态为售后处理中 +// * - 记录返修申请信息和联系方式 +// *

+// * 请求参数: +// * - order_id: 订单ID +// * - phone: 联系电话 +// * - mark: 返修原因备注 +// */ +// @PostMapping("/api/service/order/rework") +// public AjaxResult serviceOrderRework(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 参数验证 +// if (params == null) { +// return AppletControllerUtil.appletWarning("请求参数不能为空"); +// } +// String orderId = (String) params.get("order_id"); +// String phone = (String) params.get("phone"); +// String mark = (String) params.get("mark"); +// if (StringUtils.isEmpty(orderId)) { +// return AppletControllerUtil.appletWarning("订单ID不能为空"); +// } +// if (StringUtils.isEmpty(phone)) { +// return AppletControllerUtil.appletWarning("联系电话不能为空"); +// } +// // 验证手机号格式 +// if (!phone.matches("^1[3-9]\\d{9}$")) { +// return AppletControllerUtil.appletWarning("联系电话格式不正确"); +// } +// if (StringUtils.isEmpty(mark)) { +// return AppletControllerUtil.appletWarning("返修原因不能为空"); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 4. 查询订单信息并验证归属权 +// Order order = orderService.selectOrderByOrderId(orderId); +// if (order == null) { +// return AppletControllerUtil.appletWarning("订单不存在"); +// } +// if (!order.getUid().equals(user.getId())) { +// return AppletControllerUtil.appletWarning("无权操作此订单"); +// } +// // 5. 验证订单状态是否允许申请售后 +// if (!AppletControllerUtil.isOrderAllowRework(order.getStatus())) { +// return AppletControllerUtil.appletWarning("当前订单状态不允许申请售后"); +// } +// // 6. 处理售后返修申请 +// boolean reworkResult = AppletControllerUtil.processReworkApplication(order, phone, mark, user, orderReworkService, orderService); +// if (reworkResult) { +// return AppletControllerUtil.appletSuccess("售后返修申请已提交,我们会尽快联系您处理"); +// } else { +// return AppletControllerUtil.appletWarning("售后申请提交失败,请稍后重试"); +// } +// } catch (Exception e) { +// System.err.println("售后返修申请异常:" + e.getMessage()); +// return AppletControllerUtil.appletWarning("售后申请失败:" + e.getMessage()); +// } +// } +// /** +// * 获取用户服务订单列表 +// * +// * @param params 请求参数 包含page(页码)、limit(每页数量)、status(订单状态) +// * @param request HTTP请求对象 +// * @return 返回分页的服务订单列表 +// *

+// * 功能说明: +// * - 获取当前登录用户的服务类订单(type=1) +// * - 支持按订单状态筛选 +// * - 返回带分页信息的订单列表 +// * - 自动填充商品信息(标题、图标、价格等) +// */ +// @PostMapping("api/service/order/lst") +// public AjaxResult getserviceorderlst(@RequestBody Map params, +// HttpServletRequest request) { +// int page = (int) params.get("page"); +// int limit = (int) params.get("limit"); +// String status = (String) params.get("status"); +// // 1. 验证分页参数 +// Map pageValidation = PageUtil.validatePageParams(page, limit); +// if (!(Boolean) pageValidation.get("valid")) { +// return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// // 4. 设置分页参数 +// PageHelper.startPage(page, limit); +// // 5. 查询用户地址列表 +// OrderApple order = new OrderApple(); +// // order.setType(1); +// order.setUid(user.getId()); +// if (StringUtils.isNotNull(status) && !"".equals(status)) { +// order.setStatus(Long.valueOf(status)); +// } +// List orderList = orderService.selectOrderAppleList(order); +// for (OrderApple orderdata : orderList) { +// Map jsonObject = new HashMap<>(); +// if (orderdata.getProduct_id() != null) { +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(orderdata.getProduct_id()); +// if (serviceGoods != null) { +// jsonObject.put("title", serviceGoods.getTitle()); +// jsonObject.put("icon", "https://img.huafurenjia.cn/" + serviceGoods.getIcon()); +// jsonObject.put("id", serviceGoods.getId()); +// jsonObject.put("price_zn", serviceGoods.getPriceZn()); +// jsonObject.put("sub_title", serviceGoods.getSubTitle()); +// orderdata.setProduct(jsonObject); +// } +// } +// } +// // 6. 获取分页信息并构建响应 +// TableDataInfo tableDataInfo = getDataTable(orderList); +// // 7. 构建符合要求的分页响应格式 +// Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); +// return AppletControllerUtil.appletSuccess(pageData); +// } +// /** +// * 获取用户商品订单列表 +// * +// * @param params 请求参数 包含page(页码)、limit(每页数量)、status(订单状态) +// * @param request HTTP请求对象 +// * @return 返回分页的商品订单列表 +// *

+// * 功能说明: +// * - 获取当前登录用户的商品类订单 +// * - 支持按订单状态筛选 +// * - 返回带分页信息的订单列表 +// * - 包含完整的商品信息和订单状态文本 +// */ +// @PostMapping("/api/goods/order/lst") +// public AjaxResult getgoodsorderlst(@RequestBody Map params, +// HttpServletRequest request) { +// try { +// int page = (int) params.get("page"); +// int limit = (int) params.get("limit"); +// String status = (String) params.get("status"); +// // 1. 验证分页参数 +// Map pageValidation = PageUtil.validatePageParams(page, limit); +// if (!(Boolean) pageValidation.get("valid")) { +// return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); +// } +// // 2. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 3. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 4. 设置分页参数 +// PageHelper.startPage(page, limit); +// +// // 5. 构建查询条件 +// GoodsOrder queryOrder = new GoodsOrder(); +// queryOrder.setUid(user.getId()); +// +// if (StringUtils.isNotNull(status) && !status.isEmpty()) { +// if ("7".equals(status)){ +// queryOrder.setReturnstatus(7L); +// }else{ +// queryOrder.setStatus(Long.valueOf(status)); +// } +// +// } +// +// // 6. 查询商品订单列表 +// List orderList = goodsOrderService.selectGoodsOrderList(queryOrder); +// +// // 7. 为每个订单填充商品信息 +// List> resultList = new ArrayList<>(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// +// for (GoodsOrder order : orderList) { +// Map orderData = new HashMap<>(); +// +// // 订单基本信息 +// orderData.put("id", order.getId()); +// orderData.put("order_id", order.getOrderId()); +// orderData.put("order_no", order.getOrderId()); // 小程序常用字段 +// orderData.put("status", order.getStatus()); +// orderData.put("status_text", getOrderStatusText(order.getStatus())); // 状态文本 +// orderData.put("total_price", order.getTotalPrice() != null ? order.getTotalPrice().toString() : "0.00"); +// orderData.put("num", order.getNum()); +// if (order.getSku() != null) { +// orderData.put("sku",AppletControllerUtil.parseSkuStringToObject(order.getSku())); +// } else { +// orderData.put("sku", null); +// } +// +// +// // 时间字段格式化 +// if (order.getPayTime() != null) { +// orderData.put("pay_time", sdf.format(order.getPayTime())); +// } else { +// orderData.put("pay_time", null); +// } +// +// if (order.getCreatedAt() != null) { +// orderData.put("created_at", sdf.format(order.getCreatedAt())); +// } else { +// orderData.put("created_at", null); +// } +// +// // 查询并添加商品详细信息 +// if (order.getProductId() != null) { +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); +// if (serviceGoods != null) { +// Map productInfo = new HashMap<>(); +// productInfo.put("id", serviceGoods.getId()); +// productInfo.put("title", serviceGoods.getTitle()); +// productInfo.put("sub_title", serviceGoods.getSubTitle()); +// productInfo.put("icon", AppletControllerUtil.buildImageUrl(serviceGoods.getIcon())); +// productInfo.put("price", order.getTotalPrice() != null ? order.getTotalPrice().toString() : "0.00"); +// productInfo.put("num", order.getNum()); +// +// orderData.put("product", productInfo); +// } +// } +// resultList.add(orderData); +// } +// // 8. 构建分页信息 +// PageInfo pageInfo = new PageInfo<>(orderList); +// // 9. 构建返回数据格式(简化版本,更适合小程序) +// Map responseData = new HashMap<>(); +// responseData.put("current_page", pageInfo.getPageNum()); +// responseData.put("data", resultList); +// responseData.put("total", pageInfo.getTotal()); +// responseData.put("per_page", pageInfo.getPageSize()); +// responseData.put("last_page", pageInfo.getPages()); +// +// return AppletControllerUtil.appletSuccess(responseData); +// +// } catch (Exception e) { +// System.err.println("查询商品订单列表异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("查询商品订单列表失败:" + e.getMessage()); +// } +// } +// +// /** +// * 获取订单状态文本 +// * +// * @param status 订单状态 +// * @return 状态文本 +// */ +// private String getOrderStatusText(Long status) { +// if (status == null) { +// return "未知状态"; +// } +// switch (status.intValue()) { +// case 1: +// return "待付款"; +// case 2: +// return "待发货"; +// case 3: +// return "待收货"; +// case 4: +// return "待评价"; +// case 5: +// return "已完成"; +// case 6: +// return "已取消"; +// case 7: +// return "售后中"; +// case 8: +// return "已退款"; +// default: +// return "未知状态"; +// } +// } +// +// +// /** +// * 用户登录验证接口 +// * +// * @param request HTTP请求对象 +// * @return 返回用户信息或错误信息 +// *

+// * 功能说明: +// * - 通过请求头中的token验证用户身份 +// * - 查询用户基本信息并返回 +// * - 设置remember_token字段用于前端使用 +// */ +// @PostMapping(value = "/api/user/login") +// public AjaxResult getuserlogin(HttpServletRequest request) { +// String token = request.getHeader("token"); +// Users users = usersService.selectUsersByRememberToken(token); +// if (users != null) { +// users.setRemember_token(users.getRememberToken()); +// return AppletControllerUtil.appletSuccess(users); +// } else { +// return AppletControllerUtil.appletWarning("用户不存在"); +// } +// +// } +// /** +// * 获取服务商品列表 +// * 前端参数格式:{cate_id: 18} +// * 业务逻辑: +// * - 如果cate_id为空或null:返回所有分类的服务分组 +// * - 如果是一级分类:返回该一级分类下的服务分组 + 该一级分类下所有二级分类的服务分组 +// * - 如果是二级分类:返回该二级分类下的服务分组 +// * 返回格式:分类title + [服务列表] 的分组结构 +// */ +// @PostMapping(value = "/api/service/lst") +// public AjaxResult getServiceGoodsList(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 获取分类ID参数 +// Long cateId = null; +// if (params.get("cate_id") != null) { +// Object cateIdObj = params.get("cate_id"); +// try { +// if (cateIdObj instanceof Integer) { +// cateId = ((Integer) cateIdObj).longValue(); +// } else if (cateIdObj instanceof String) { +// String cateIdStr = cateIdObj.toString().trim(); +// if (!cateIdStr.isEmpty()) { +// cateId = Long.parseLong(cateIdStr); +// } +// } else { +// cateId = Long.parseLong(cateIdObj.toString()); +// } +// } catch (NumberFormatException e) { +// return AppletControllerUtil.appletkaifaWarning("分类ID格式错误"); +// } +// } +// +// // 2. 如果cate_id为空,查询默认的服务分类 +// if (cateId == null) { +// // 查询启用状态、类型为服务、排序第一的分类 +// ServiceCate defaultCateQuery = new ServiceCate(); +// defaultCateQuery.setStatus(1L); // 启用状态 +// defaultCateQuery.setType(1L); // 类型为服务(假设1为服务类型) +// List defaultCateList = serviceCateService.selectServiceCateList(defaultCateQuery); +// +// if (defaultCateList.isEmpty()) { +// return AppletControllerUtil.appletkaifaWarning("未找到默认服务分类"); +// } +// +// // 按排序字段升序排列,取第一个 +// defaultCateList.sort((a, b) -> { +// Long sortA = a.getSort() != null ? a.getSort() : Long.MAX_VALUE; +// Long sortB = b.getSort() != null ? b.getSort() : Long.MAX_VALUE; +// return sortA.compareTo(sortB); +// }); +// +// // 给cate_id赋值为排序第一的分类ID +// cateId = defaultCateList.get(0).getId(); +// } +// +// // 3. 构建返回数据 +// List> resultList = new ArrayList<>(); +// +// // 3. 查询分类信息,判断是一级还是二级分类 +// ServiceCate category = serviceCateService.selectServiceCateById(cateId); +// if (category == null) { +// return AppletControllerUtil.appletkaifaWarning("分类不存在"); +// } +// +// if (category.getParentId() == null || category.getParentId() == 0L) { +// // 一级分类:返回该一级分类的服务分组 + 所有二级分类的服务分组 +// +// // 先添加一级分类本身的服务 +// List> firstLevelServices = getServicesByCategory(cateId); +// if (!firstLevelServices.isEmpty()) { +// Map firstLevelGroup = new HashMap<>(); +// firstLevelGroup.put("id", category.getId()); +// firstLevelGroup.put("title", category.getTitle()); +// firstLevelGroup.put("services", firstLevelServices); +// resultList.add(firstLevelGroup); +// } +// +// // 再添加该一级分类下所有二级分类的服务分组 +// ServiceCate childQuery = new ServiceCate(); +// childQuery.setParentId(cateId); +// childQuery.setStatus(1L); +// List childCategories = serviceCateService.selectServiceCateList(childQuery); +// +// for (ServiceCate child : childCategories) { +// List> childServices = getServicesByCategory(child.getId()); +// if (!childServices.isEmpty()) { +// Map childGroup = new HashMap<>(); +// childGroup.put("id", category.getId()); +// childGroup.put("title", child.getTitle()); +// childGroup.put("services", childServices); +// resultList.add(childGroup); +// } +// } +// +// } else { +// // 二级分类:只返回该二级分类的服务分组 +// List> services = getServicesByCategory(cateId); +// if (!services.isEmpty()) { +// Map group = new HashMap<>(); +// group.put("id", category.getId()); +// group.put("title", category.getTitle()); +// group.put("services", services); +// resultList.add(group); +// } +// } +// +// return AppletControllerUtil.appletSuccess(resultList); +// } catch (Exception e) { +// return AppletControllerUtil.appletkaifaWarning("查询服务商品列表失败:" + e.getMessage()); +// } +// } +// +// +// /** +// * 根据分类ID查询该分类下的服务列表 +// * @param categoryId 分类ID +// * @return 服务列表(只包含id、title、icon) +// */ +// private List> getServicesByCategory(Long categoryId) { +// List> serviceList = new ArrayList<>(); +// +// ServiceGoods queryGoods = new ServiceGoods(); +// queryGoods.setCateId(categoryId); +// queryGoods.setStatus("1"); // 只查询启用状态的商品 +// +// List goodsList = serviceGoodsService.selectServiceGoodsList(queryGoods); +// +// for (ServiceGoods goods : goodsList) { +// Map serviceData = new HashMap<>(); +// serviceData.put("id", goods.getId()); +// serviceData.put("title", goods.getTitle()); +// serviceData.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); +// serviceList.add(serviceData); +// } +// +// return serviceList; +// } +// /** +// * 获取服务商品详细信息 +// * +// * @param id 商品ID +// * @param request HTTP请求对象 +// * @return 商品详细信息 +// *

+// * 接口说明: +// * - 根据商品ID获取详细信息 +// * - type=1时返回ServiceGoodsResponse格式 +// * - type=2时返回json.txt中的商品格式 +// * - 包含图片、基础信息等数组数据 +// */ +// @GetMapping(value = "/api/service/info/id/{id}") +// public AjaxResult serviceGoodsQuery(@PathVariable("id") long id, +// @RequestParam(value = "type", required = false) Integer type, +// HttpServletRequest request) { +// try { +// // 参数验证 +// if (id <= 0) { +// return AppletControllerUtil.appletError("商品ID无效"); +// } +// +// // 查询商品信息 +// ServiceGoods serviceGoodsData = serviceGoodsService.selectServiceGoodsById(id); +// if (serviceGoodsData == null) { +// return AppletControllerUtil.appletError("商品不存在或已下架"); +// } +// if (type != null && type == 1) { +// if (serviceGoodsData.getIsgroup()!=1){ +// return AppletControllerUtil.appletError("改服务不是拼团服务"); +// } +// } +// //次卡详情 +// if (type != null && type == 2) { +// UserSecondaryCard goods = userSecondaryCardService.selectUserSecondaryCardById(id); +// Map map = new HashMap<>(); +// map.put("isyikoujia", 1); +// map.put("id", goods.getId()); +// map.put("allsellnum", 10); +// map.put("orderid", goods.getOrderid()); +// map.put("title", goods.getTitle()); +// map.put("goodsids", goods.getGoodsids()); +// map.put("show_money", goods.getShowMoney()); +// map.put("real_money", goods.getRealMoney()); +// map.put("showimage", AppletControllerUtil.buildImageUrl(goods.getShowimage())); +// map.put("carouselImage", AppletControllerUtil.parseImagesStringToArray(goods.getCarouselImage())); +// map.put("status", goods.getStatus()); +// map.put("creattime", goods.getCreattime()); +// map.put("type", goods.getType()); +// map.put("num", goods.getNum()); +// map.put("allnum", goods.getAllnum()); +// map.put("introduction", goods.getIntroduction()); +// List idsList = JSONArray.parseArray(goods.getGoodsids(), String.class); +// List serviceGoodsList = serviceGoodsService.selectServiceGoodsfrocikaList(idsList); +// List> serviceDetail = new ArrayList<>(); +// if(serviceGoodsList != null && !serviceGoodsList.isEmpty()) { +// for(ServiceGoods serviceGoods : serviceGoodsList) { +// Map card = new HashMap<>(); +// card.put("icon", AppletControllerUtil.buildImageUrl(serviceGoods.getIcon())); +// card.put("title", serviceGoods.getTitle()); +// card.put("price", serviceGoods.getPrice()); +// card.put("id", serviceGoods.getId()); +// serviceDetail.add( card); +// } +// } +// map.put("serviceDetail", serviceDetail); +// // card.setServiceDetail(serviceGoodsService.selectServiceGoodsfrocikaList(idsList)); +// return AppletControllerUtil.appletSuccess(map); +// } +// //拼团详情 +// +// +// +// // 原有逻辑:普通服务详情 +// if (serviceGoodsData.getType() != null && serviceGoodsData.getType() == 2) { +// // type=2时返回json.txt格式 +// Map goodsData = AppletControllerUtil.buildType2ServiceGoodsResponse(serviceGoodsData); +// return AppletControllerUtil.appletSuccess(goodsData); +// } else { +// // type=1时返回ServiceGoodsResponse格式 +// Map goodsData = AppletControllerUtil.buildType2ServiceGoodsResponse(serviceGoodsData); +// //根据需求就要添加拼团相关数据 +// if (type != null) { +// //拼团独有数据 +// if (type == 1) { +// // 拼团服务详情 +// goodsData.put("isyikoujia", 1); +// goodsData.put("allsellnum", 10); +// goodsData.put("isgroup", serviceGoodsData.getIsgroup()); +// goodsData.put("groupnum", serviceGoodsData.getGroupnum()); +// goodsData.put("groupprice", serviceGoodsData.getGroupprice()); +// List> groupBuyingList = userGroupBuyingService.selectGroupBuyingGroupByProductAndOrder(Math.toIntExact(serviceGoodsData.getId())); +// for (Map groupBuying : groupBuyingList) { +// //还差几人成团 +// JSONArray groupBuyingArray = JSONArray.parseArray(groupBuying.get("name").toString()); +// // JSONArray groupBuyingArray =new JSONArray(); +// groupBuying.put("neednum", serviceGoodsData.getGroupnum() - groupBuyingArray.size()); +// groupBuying.put("image", AppletControllerUtil.parseImagesStringToArray(groupBuying.get("image").toString())); +// //parseImagesStringToArray(goods.getImgs()) +// //groupBuying.put("neednum", AppletControllerUtil.buildImageUrl(groupBuying.get("image").toString())); +// } +// goodsData.put("groupBuyData", groupBuyingList); +// } +// //秒杀独有数据 +// if (type == 3) { +// +// // 获取秒杀相关数据 +// long msdata = 0L; +// try { +// // 获取config_one配置中的秒杀结束时间 +// SiteConfig configQuery = new SiteConfig(); +// configQuery.setName("config_one"); +// List configList = siteConfigService.selectSiteConfigList(configQuery); +// +// if (configList != null && !configList.isEmpty()) { +// String configValue = configList.get(0).getValue(); +// if (configValue != null && !configValue.trim().isEmpty()) { +// JSONObject configJson = JSONObject.parseObject(configValue); +// String mstime = configJson.getString("mstime"); +// +// if (mstime != null && !mstime.trim().isEmpty()) { +// // 解析秒杀结束时间 +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// Date endTime = sdf.parse(mstime); +// msdata = endTime.getTime(); // 返回结束时间的毫秒数 +// } +// } +// } +// } catch (Exception e) { +// // 解析异常时设置为0 +// msdata = 0L; +// } +// +// +// // 秒杀服务详情 +// goodsData.put("isyikoujia", 1); +// goodsData.put("msdata", msdata); +// goodsData.put("allsellnum", 10); +// goodsData.put("isfixed", serviceGoodsData.getIsfixed()); +// goodsData.put("fixedprice", serviceGoodsData.getFixedprice()); +// } +// //报价数据下师傅的报价详情 +// if (type == 4) { +// goodsData.put("isyikoujia", 2); +// // 秒杀服务详情 +//// List> quoteList = new List>() ; +//// +//// goodsData.put("isfixed", serviceGoodsData.getIsfixed()); +//// goodsData.put("fixedprice", serviceGoodsData.getFixedprice()); +// } +// }else{ +// goodsData.put("isyikoujia", 2); +// } +// return AppletControllerUtil.appletSuccess(goodsData); +// } +// } catch (Exception e) { +// return AppletControllerUtil.appletError("查询商品详情失败:" + e.getMessage()); +// } +// } +// /** +// * 获取广告图片列表 +// * +// * @param type 广告类型 +// * @param request HTTP请求对象 +// * @return 广告图片列表 +// *

+// * 接口说明: +// * - 根据广告类型获取对应的图片列表 +// * - 自动添加图片CDN前缀 +// * - 支持多种广告位配置 +// */ +// @GetMapping(value = "/api/public/adv/lst/{type}") +// public AjaxResult getAdvImgData(@PathVariable("type") long type, HttpServletRequest request) { +// try { +// // 参数验证 +// if (type < 0) { +// return AppletControllerUtil.appletWarning("广告类型无效"); +// } +// +// // 构建查询条件 +// AdvImg advImgQuery = new AdvImg(); +// advImgQuery.setType(type); +// advImgQuery.setStatus(1L); +// +// // 查询广告图片列表 +// List advImgList = advImgService.selectAdvImgList(advImgQuery); +// +// // 为每张图片添加CDN前缀 +// for (AdvImg advImg : advImgList) { +// advImg.setImage(AppletControllerUtil.buildImageUrl(advImg.getImage())); +// } +// +// return AppletControllerUtil.appletSuccess(advImgList); +// } catch (Exception e) { +// return AppletControllerUtil.appletWarning("获取广告图片失败:" + e.getMessage()); +// } +// } +// +// /** +// * 获取商城分类列表 +// * +// * @param request HTTP请求对象 +// * @return 商城分类列表 +// *

+// * 接口说明: +// * - 查询类型为商品且状态为启用的分类数据 +// * - 只返回title和icon字段 +// * - 自动添加图片CDN前缀 +// * - 保持原有排序不变 +// * - 无需用户登录验证 +// */ +// @GetMapping(value = "/api/mall/cate/lst/{type}") +// public AjaxResult getMallCategoryList(@PathVariable("type") int type, HttpServletRequest request) { +// try { +// // 构建查询条件 +// ServiceCate serviceCateQuery = new ServiceCate(); +// serviceCateQuery.setStatus(1L); // 状态为启用 +// serviceCateQuery.setType(2L); // 类型为商品(假设2为商品类型,请根据实际业务调整) +// +// // 查询商城分类列表 +// List categoryList = serviceCateService.selectServiceCateList(serviceCateQuery); +// +// // 构建返回数据(只包含title和icon) +// List> resultList = new ArrayList<>(); +// for (ServiceCate category : categoryList) { +// Map categoryData = new HashMap<>(); +// categoryData.put("id", category.getId()); +// categoryData.put("title", category.getTitle()); +// categoryData.put("icon", AppletControllerUtil.buildImageUrl(category.getIcon())); +// resultList.add(categoryData); +// } +// +// return AppletControllerUtil.appletSuccess(resultList); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取商城分类列表失败:" + e.getMessage()); +// } +// } +// +// /** +// * 获取热门推荐商品 +// * +// * @param request HTTP请求对象 +// * @return 热门推荐商品列表(销量前6个) +// *

+// * 接口说明: +// * - 查询type=2的商品 +// * - 按销量降序排列,取前6个 +// * - 返回id、title、icon、price、sales字段 +// * - 自动添加图片CDN前缀 +// * - 无需用户登录验证 +// */ +// @GetMapping(value = "/api/hot/recommend") +// public AjaxResult getHotRecommendGoods(HttpServletRequest request) { +// try { +// // 构建查询条件 +// ServiceGoods queryGoods = new ServiceGoods(); +// queryGoods.setType(2); // 查询type=2的商品 +// queryGoods.setStatus("1"); // 只查询启用状态的商品 +// +// // 查询符合条件的商品列表 +// List goodsList = serviceGoodsService.selectServiceGoodsList(queryGoods); +// +// // 按销量降序排序 +// goodsList.sort((a, b) -> { +// Long salesA = a.getSales() != null ? a.getSales() : 0L; +// Long salesB = b.getSales() != null ? b.getSales() : 0L; +// return salesB.compareTo(salesA); +// }); +// +// // 取前6个 +// if (goodsList.size() > 6) { +// goodsList = goodsList.subList(0, 6); +// } +// +// // 构建返回数据 +// List> resultList = new ArrayList<>(); +// for (ServiceGoods goods : goodsList) { +// Map goodsData = new HashMap<>(); +// goodsData.put("id", goods.getId()); +// goodsData.put("title", goods.getTitle()); +// goodsData.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); +// goodsData.put("price", goods.getPrice() != null ? goods.getPrice().toString() : "0.00"); +// goodsData.put("sales", goods.getSales() != null ? goods.getSales() : 0L); +// resultList.add(goodsData); +// } +// +// return AppletControllerUtil.appletSuccess(resultList); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取热门推荐商品失败:" + e.getMessage()); +// } +// } +// +// /** +// * 根据分类ID查询商品列表 +// * +// * @param request HTTP请求对象 +// * @return 该分类下的商品列表 +// *

+// * 接口说明: +// * - 根据分类ID查询商品 +// * - 只查询启用状态的商品 +// * - 返回id、title、icon、price、sales字段 +// * - 自动添加图片CDN前缀 +// * - 无需用户登录验证 +// */ +// @PostMapping(value = "/api/goods/cate") +// public AjaxResult getGoodsByCategory(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 获取分页参数 +// int page = params.get("page") != null ? (Integer) params.get("page") : 1; +// int limit = params.get("limit") != null ? (Integer) params.get("limit") : 15; +// String cateId = params.get("cateId").toString(); +// +// // 验证分页参数 +// if (page < 1) page = 1; +// if (limit < 1) limit = 15; +//// if (limit > 100) limit = 100; // 限制最大每页数量 +// +// // 2. 设置分页参数 +// PageHelper.startPage(page, limit); +// +// // 3. 构建查询条件 +// ServiceGoods queryGoods = new ServiceGoods(); +// queryGoods.setStatus("1"); // 只查询启用状态的商品 +// +// // 判断是否查询全部商品 +// boolean queryAll = "00".equals(cateId.trim()) || cateId.trim().isEmpty(); +// +// if (!queryAll) { +// // 验证分类ID格式 +// Long categoryId; +// try { +// categoryId = Long.parseLong(cateId); +// if (categoryId <= 0) { +// return AppletControllerUtil.appletWarning("分类ID无效"); +// } +// } catch (NumberFormatException e) { +// return AppletControllerUtil.appletWarning("分类ID格式错误"); +// } +// +// // 验证分类是否存在 +// ServiceCate category = serviceCateService.selectServiceCateById(categoryId); +// if (category == null) { +// return AppletControllerUtil.appletWarning("分类不存在"); +// } +// +// queryGoods.setCateId(categoryId); // 根据分类ID查询 +// } +// +// // 4. 查询商品列表 +// List goodsList = serviceGoodsService.selectServiceGoodsList(queryGoods); +// +// // 5. 构建返回数据 +// List> resultList = new ArrayList<>(); +// for (ServiceGoods goods : goodsList) { +// Map goodsData = new HashMap<>(); +// goodsData.put("id", goods.getId()); +// goodsData.put("title", goods.getTitle()); +// goodsData.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); +// goodsData.put("price", goods.getPrice() != null ? goods.getPrice().toString() : "0.00"); +// goodsData.put("sales", goods.getSales() != null ? goods.getSales() : 0L); +// goodsData.put("cate_id", goods.getCateId()); +// resultList.add(goodsData); +// } +// +// // 6. 构建分页信息 +// PageInfo pageInfo = new PageInfo<>(goodsList); +// +// // 7. 构建返回数据格式 +// Map responseData = new HashMap<>(); +// responseData.put("current_page", pageInfo.getPageNum()); +// responseData.put("data", resultList); +// responseData.put("from", pageInfo.getStartRow()); +// responseData.put("last_page", pageInfo.getPages()); +// responseData.put("per_page", pageInfo.getPageSize()); +// responseData.put("to", pageInfo.getEndRow()); +// responseData.put("total", pageInfo.getTotal()); +// +// // 构建分页链接信息 +// String baseUrl = "https://www.huafurenjia.cn/api/goods/cate/" + cateId; +// responseData.put("first_page_url", baseUrl + "?page=1"); +// responseData.put("last_page_url", baseUrl + "?page=" + pageInfo.getPages()); +// responseData.put("next_page_url", pageInfo.isHasNextPage() ? +// baseUrl + "?page=" + pageInfo.getNextPage() : null); +// responseData.put("prev_page_url", pageInfo.isHasPreviousPage() ? +// baseUrl + "?page=" + pageInfo.getPrePage() : null); +// responseData.put("path", baseUrl); +// +// return AppletControllerUtil.appletSuccess(responseData); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("查询分类商品失败:" + e.getMessage()); +// } +// } +// +// /** +// * 获取一级城市列表 +// * +// * @param request HTTP请求对象 +// * @return 一级城市列表 +// *

+// * 接口说明: +// * - 查询parent_id=0的城市数据 +// * - 只返回id和title字段 +// * - 无需用户登录验证 +// */ +// @GetMapping(value = "/api/city/list") +// public AjaxResult getCityList(HttpServletRequest request) { +// try { +// // 构建查询条件 +// DiyCity queryCond = new DiyCity(); +// queryCond.setParentId(0L); // 查询parent_id=0的一级城市 +// +// // 查询一级城市列表 +// List cityList = diyCityService.selectDiyCityList(queryCond); +// +// // 构建返回数据(只包含id和title) +// List> resultList = new ArrayList<>(); +// for (DiyCity city : cityList) { +// Map cityData = new HashMap<>(); +// cityData.put("id", city.getId()); +// cityData.put("title", city.getTitle()); +// resultList.add(cityData); +// } +// +// return AppletControllerUtil.appletSuccess(resultList); +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取城市列表失败:" + e.getMessage()); +// } +// } +// +// /** +// * 根据经纬度获取城市信息 +// * +// * @param params 请求参数,包含latitude(纬度)、longitude(经度) +// * @param request HTTP请求对象 +// * @return 城市信息 +// *

+// * 接口说明: +// * - 接收前端传入的经纬度坐标 +// * - 调用高德地图逆地理编码API获取城市信息 +// * - 返回城市名称和详细地址信息 +// * - 无需用户登录验证 +// */ +// @PostMapping(value = "/api/location/city") +// public AjaxResult getCityByLocation(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 参数验证 +// if (params == null) { +// return AppletControllerUtil.appletWarning("请求参数不能为空"); +// } +// +// String latitude = params.get("latitude") != null ? params.get("latitude").toString() : ""; +// String longitude = params.get("longitude") != null ? params.get("longitude").toString() : ""; +// +// if (latitude.isEmpty() || longitude.isEmpty()) { +// return AppletControllerUtil.appletWarning("经纬度参数不能为空"); +// } +// +// // 验证经纬度格式并转换为double +// double lat, lng; +// try { +// lat = Double.parseDouble(latitude); +// lng = Double.parseDouble(longitude); +// +// // 验证经纬度范围 +// if (lat < -90 || lat > 90) { +// return AppletControllerUtil.appletWarning("纬度范围应在-90到90之间"); +// } +// if (lng < -180 || lng > 180) { +// return AppletControllerUtil.appletWarning("经度范围应在-180到180之间"); +// } +// } catch (NumberFormatException e) { +// return AppletControllerUtil.appletWarning("经纬度格式错误"); +// } +// +// // 2. 调用高德地图工具类获取位置信息 +// String city = GaoDeMapUtil.getCityByLocation(lng, lat); +// String address = GaoDeMapUtil.getAddressByLocation(lng, lat); +// +// // 3. 构建返回数据 +// Map locationInfo = new HashMap<>(); +// locationInfo.put("city", city != null ? city : ""); +// locationInfo.put("formatted_address", address != null ? address : ""); +// locationInfo.put("latitude", latitude); +// locationInfo.put("longitude", longitude); +// +// return AppletControllerUtil.appletSuccess(locationInfo); +// +// } catch (Exception e) { +// return AppletControllerUtil.appletError("获取位置信息失败:" + e.getMessage()); +// } +// } +// +// /** +// * 微信用户登录接口 +// * +// * @param params 请求参数 +// * @param request HTTP请求对象 +// * @return 登录结果 +// * 登录流程: +// * 1. 验证请求参数 +// * 2. 通过usercode获取微信openid +// * 3. 检查用户是否已存在(通过openid) +// * 4. 如果用户存在,直接返回用户信息 +// * 5. 如果用户不存在,获取手机号并创建/更新用户 +// */ +// @PostMapping(value = "/api/user/phone/login") +// public AjaxResult wechatLogin(@RequestBody Map params, HttpServletRequest request) { +// // 使用AppletLoginUtil执行完整的微信登录流程 +// return AppletLoginUtil.executeWechatLogin(params, usersService); +// } +// + + +// /** +// * 获取用户基本信息接口 +// * +// * @param request HTTP请求对象 +// * @return 用户基本信息 +// *

+// * 接口说明: +// * - 通过token获取当前登录用户的基本信息 +// * - 返回完整的用户数据 +// * - 需要用户登录验证 +// *

+// */ +// @GetMapping(value = "/api/user/info") +// public AjaxResult getUserInfo(HttpServletRequest request) { +// try { +// Map order_num = new HashMap<>(); +// Map goods_order_num = new HashMap<>(); +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletUnauthorized(); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletWarning("用户信息获取失败"); +// } +// +// // 3. 构建精简用户信息响应数据 +// Map userInfo = new HashMap<>(); +// userInfo.put("nickname", user.getNickname()); +// userInfo.put("phone", user.getPhone()); +// userInfo.put("ismember", user.getIsmember()); +// userInfo.put("member_begin", user.getMemberBegin()); +// userInfo.put("member_end", user.getMemberEnd()); +// userInfo.put("balance", user.getBalance()); +// userInfo.put("integral", user.getIntegral()); +// userInfo.put("shop_money", user.getConsumption()); +// userInfo.put("service_money", user.getServicefee()); +// userInfo.put("birthday", user.getBirthday()); +// userInfo.put("remember_token", userInfo.get("rememberToken")); +// +// // 头像处理 +// String avatar = user.getAvatar(); +// if (avatar != null && !avatar.isEmpty()) { +// userInfo.put("avatar", AppletControllerUtil.buildImageUrl(avatar)); +// } else { +// userInfo.put("avatar", "https://img.huafurenjia.cn/default/user_avatar.jpeg"); +// } +// order_num.put("pending_accept", orderService.selectCountOrderByUid(user.getId(), 2L)); +// order_num.put("pending_service", orderService.selectCountOrderByUid(user.getId(), 3L)); +// order_num.put("in_service", orderService.selectCountOrderByUid(user.getId(), 4L)); +// order_num.put("other_status", orderService.selectAllCountOrderByUid(user.getId())); +// userInfo.put("order_num", order_num); +// +// +// goods_order_num.put("pending_accept", goodsOrderService.selectCountGoodsOrderByUid(user.getId(), 2L)); +// goods_order_num.put("pending_service", goodsOrderService.selectCountGoodsOrderByUid(user.getId(), 3L)); +// goods_order_num.put("in_service", goodsOrderService.selectCountGoodsOrderByUid(user.getId(), 5L)); +// goods_order_num.put("other_status", goodsOrderService.selectAllCountGoodsOrderByUid(user.getId())); +// userInfo.put("goods_order_num", goods_order_num); +// // 新增tx_time字段 +// List txTimeArr = new ArrayList<>(); +// try { +// SiteConfig configQuery = new SiteConfig(); +// configQuery.setName("config_four"); +// List configList = siteConfigService.selectSiteConfigList(configQuery); +// if (configList != null && !configList.isEmpty()) { +// String configValue = configList.get(0).getValue(); +// if (configValue != null && !configValue.trim().isEmpty()) { +// JSONObject json = JSONObject.parse(configValue); +// if (json.containsKey("time")) { +// Object timeObj = json.get("time"); +// if (timeObj instanceof List) { +// txTimeArr = (List) timeObj; +// } else if (timeObj instanceof JSONArray) { +// txTimeArr = ((JSONArray) timeObj).toJavaList(Object.class); +// } +// } +// } +// } +// } catch (Exception ignore) { +// } +// userInfo.put("tx_time", txTimeArr); +// return AppletControllerUtil.appletSuccess(userInfo); +// } catch (Exception e) { +// System.err.println("查询用户基本信息异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("查询用户信息失败:" + e.getMessage()); +// } +// } + + + + +// /** +// * 获取用户基本信息接口 +// * +// * @param request HTTP请求对象 +// * @return 用户基本信息 +// *

+// * 接口说明: +// * - 通过token获取当前登录用户的基本信息 +// * - 返回完整的用户数据 +// * - 需要用户登录验证 +// *

+// */ +// @GetMapping(value = "/api/user/info") +// public AjaxResult apiuserinfo(HttpServletRequest request) { +// try { +// SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd"); +// Map order_num = new HashMap<>(); +// Map goods_order_num = new HashMap<>(); +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 3. 构建用户信息响应数据 +// Map userInfo = buildUserInfoResponse(user); +// +// userInfo.put("remember_token", userInfo.get("rememberToken")); +// +// // 新增:根据会员状态查询充值项目 +// Integer queryType = (user.getIsmember() != null && user.getIsmember() == 1) ? 2 : 1; +// UserMemberRechargeProgram query = new UserMemberRechargeProgram(); +// query.setType(queryType); +// query.setStatus(0); // 只查启用 +// java.util.List rechargePrograms = userMemberRechargeProgramService.selectUserMemberRechargeProgramList(query); +// userInfo.put("memberRechargePrograms", rechargePrograms.getFirst()); +// //List counts = orderService.selectOrderCountByBigtype(user.getId()); +// // OrderTypeCount +// order_num.put("yuyue",orderService.selectOrderCountByBigtype(user.getId(),1)); +// order_num.put("baojia",orderService.selectOrderCountByBigtype(user.getId(),2)); +// order_num.put("yikoujia",orderService.selectOrderCountByBigtype(user.getId(),3)); +// userInfo.put("order_num", order_num); +// +// goods_order_num.put("daifukuan",goodsOrderService.countGoodsOrderByUidAndStatus(user.getId(),1)); +// goods_order_num.put("daifahuo",goodsOrderService.countGoodsOrderByUidAndStatus(user.getId(),2)); +// goods_order_num.put("daishouhuo",goodsOrderService.countGoodsOrderByUidAndStatus(user.getId(),3)); +// goods_order_num.put("daipingjia",goodsOrderService.countGoodsOrderByUidAndStatus(user.getId(),4)); +// goods_order_num.put("shouhou",goodsOrderService.countGoodsOrderByUidAndStatus(user.getId(),20)); +// userInfo.put("goods_order_num", goods_order_num); +// +// // 新增tx_time字段 +// List txTimeArr = new ArrayList<>(); +// try { +// SiteConfig configQuery = new SiteConfig(); +// configQuery.setName("config_four"); +// List configList = siteConfigService.selectSiteConfigList(configQuery); +// if (configList != null && !configList.isEmpty()) { +// String configValue = configList.get(0).getValue(); +// if (configValue != null && !configValue.trim().isEmpty()) { +// JSONObject json = JSONObject.parse(configValue); +// if (json.containsKey("time")) { +// Object timeObj = json.get("time"); +// if (timeObj instanceof List) { +// txTimeArr = (List) timeObj; +// } else if (timeObj instanceof JSONArray) { +// txTimeArr = ((JSONArray) timeObj).toJavaList(Object.class); +// } +// } +// } +// } +// } catch (Exception ignore) { +// } +// userInfo.put("tx_time", txTimeArr); +// +// // 新增:查询该用户可用优惠券数量 +// int couponNum = 0; +// try { +// com.ruoyi.system.domain.CouponUser queryCoupon = new com.ruoyi.system.domain.CouponUser(); +// queryCoupon.setUid(user.getId()); +// queryCoupon.setStatus(0L); // 0=可用 +// java.util.List couponList = couponUserService.selectCouponUserList(queryCoupon); +// couponNum = couponList != null ? couponList.size() : 0; +// } catch (Exception e) { +// } +// userInfo.put("couponNum", couponNum); +// +// return AppletControllerUtil.appletSuccess(userInfo); +// +// } catch (Exception e) { +// System.err.println("查询用户基本信息异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("查询用户信息失败:" + e.getMessage()); +// } +// } + + + +// /** +// * 构建用户信息响应数据 +// * +// * @param user 用户实体 +// * @return 格式化的用户信息 +// */ +// private Map buildUserInfoResponse(Users user) { +// Map userInfo = new HashMap<>(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd"); +// +// // 基本信息 +// userInfo.put("id", user.getId()); +// userInfo.put("name", user.getName()); +// userInfo.put("nickname", user.getNickname()); +// userInfo.put("phone", user.getPhone()); +// userInfo.put("password", null); // 密码不返回 +// // userInfo.put("ismember", user.getIsmember()); +//// if (user.getMemberBegin() != null) { +//// userInfo.put("member_begin", sdfday.format(user.getMemberBegin())); +//// } +//// if (user.getMemberEnd() != null){ +//// userInfo.put("member_end", sdfday.format(user.getMemberEnd())); +//// } +//// userInfo.put("member_begin", sdfday.format(user.getMemberBegin())); +//// userInfo.put("member_end", sdfday.format(user.getMemberEnd())); +//package com.ruoyi.system.controller; +//import com.alibaba.fastjson2.JSON; +//import com.alibaba.fastjson2.JSONObject; +//import com.ruoyi.common.core.controller.BaseController; +//import com.ruoyi.common.core.domain.AjaxResult; +//import com.ruoyi.common.core.page.TableDataInfo; +//import com.ruoyi.common.utils.StringUtils; +//import com.ruoyi.system.ControllerUtil.*; +//import com.ruoyi.system.domain.*; +//import com.ruoyi.system.domain.AppleDoMain.OrderApple; +//import com.ruoyi.system.domain.AppleDoMain.AddressApple; +//import com.ruoyi.system.service.*; +//import com.winnerlook.model.VoiceResponseResult; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +//import org.springframework.web.multipart.MultipartFile; +//import javax.servlet.http.HttpServletRequest; +//import java.time.LocalDateTime; +//import java.time.ZoneId; +//import java.util.*; +//import java.text.SimpleDateFormat; +//import java.math.BigDecimal; +//import com.ruoyi.system.config.QiniuConfig; +//import com.ruoyi.system.utils.QiniuUploadUtil; +//import com.github.pagehelper.PageHelper; +//import com.github.pagehelper.PageInfo; +//import com.ruoyi.system.domain.WechatTransfer; +//import com.alibaba.fastjson2.JSONArray; +//import com.ruoyi.system.domain.QuoteCraft; +//import com.ruoyi.system.domain.QuoteType; +//import com.ruoyi.system.domain.QuoteMaterialType; +//import com.ruoyi.system.domain.QuoteMaterial; +///** +// * 小程序控制器 +// * +// * +// * @author Mr. Zhang Pan +// * @version 2.0 +// */ +//@RestController +//public class AppletController extends BaseController { +// +// private static final Logger logger = LoggerFactory.getLogger(AppletController.class); +// +// @Autowired +// private IServiceCateService serviceCateService; +// @Autowired +// private IUsersService usersService; +// @Autowired +// private ISiteConfigService siteConfigService; +// @Autowired +// private IAdvImgService advImgService; +// @Autowired +// private IServiceGoodsService serviceGoodsService; +// @Autowired +// private IUserAddressService userAddressService; +// @Autowired +// private IOrderService orderService; +// @Autowired +// private IOrderReworkService orderReworkService; +// @Autowired +// private ICooperateService cooperateService; +// @Autowired +// private ICouponUserService couponUserService; +// @Autowired +// private IIntegralLogService integralLogService; +// @Autowired +// private IIntegralOrderService integralOrderService; +// @Autowired +// private IIntegralProductService integralProductService; +// @Autowired +// private IIntegralOrderLogService integralOrderLogService; +// @Autowired +// private IIntegralCateService integralCateService; +// @Autowired +// private IOrderLogService orderLogService; +// @Autowired +// private IDiyCityService diyCityService; +// @Autowired +// private ISiteSkillService siteSkillService; +// @Autowired +// private QiniuConfig qiniuConfig; +// @Autowired +// private IGoodsCartService goodsCartService; +// @Autowired +// private IGoodsOrderService goodsOrderService; +// @Autowired +// private ICouponsService couponsService; +// @Autowired +// private IWorkerSignService workerSignService; +// @Autowired +// private IWorkerLevelService workerLevelService; +// @Autowired +// private IOrderCommentService orderCommentService; +// @Autowired +// private IWorkerMarginLogService workerMarginLogService; +// @Autowired +// private IWorkerMoneyLogService workerMoneyLogService; +// @Autowired +// private IWechatTransferService wechatTransferService; +// @Autowired +// private IQuoteCraftService quoteCraftService; +// @Autowired +// private IQuoteTypeService quoteTypeService; +// @Autowired +// private IQuoteMaterialTypeService quoteMaterialTypeService; +// @Autowired +// private IQuoteMaterialService quoteMaterialService; +// @Autowired +// private IGoodsOrderCursorService goodsOrderCursorService; +// @Autowired +// private IWorkerApplyService workerApplyService; +// @Autowired +// private IUserMemberRechargeProgramService userMemberRechargeProgramService; +// +// @Autowired +// private IUserSecondaryCardService userSecondaryCardService; +// @Autowired +// private IUserGroupBuyingService userGroupBuyingService; +// @Autowired +// private IUsersPayBeforService usersPayBeforService; +// @Autowired +// private IUserDemandQuotationService userDemandQuotationService; + + + /** * 获取服务分类列表 @@ -661,8 +2339,13 @@ public class AppletController extends BaseController { GoodsOrder queryOrder = new GoodsOrder(); queryOrder.setUid(user.getId()); - if (StringUtils.isNotNull(status) && !"".equals(status)) { - queryOrder.setStatus(Long.valueOf(status)); + if (StringUtils.isNotNull(status) && !status.isEmpty()) { + if ("7".equals(status)){ + queryOrder.setReturnstatus(7L); + }else{ + queryOrder.setStatus(Long.valueOf(status)); + } + } // 6. 查询商品订单列表 @@ -785,12 +2468,17 @@ public class AppletController extends BaseController { @PostMapping(value = "/api/user/login") public AjaxResult getuserlogin(HttpServletRequest request) { String token = request.getHeader("token"); + Map result = new HashMap<>(); + Users users = usersService.selectUsersByRememberToken(token); + if (users != null) { + result.put("user", users); users.setRemember_token(users.getRememberToken()); - return AppletControllerUtil.appletSuccess(users); + return AppletControllerUtil.appletSuccess(result); } else { - return AppletControllerUtil.appletWarning("用户不存在"); + result.put("user", ""); + return AppletControllerUtil.appletSuccess(result); } } @@ -1006,7 +2694,7 @@ public class AppletController extends BaseController { // 原有逻辑:普通服务详情 - if (serviceGoodsData.getType() != null && serviceGoodsData.getType().intValue() == 2) { + if (serviceGoodsData.getType() != null && serviceGoodsData.getType() == 2) { // type=2时返回json.txt格式 Map goodsData = AppletControllerUtil.buildType2ServiceGoodsResponse(serviceGoodsData); return AppletControllerUtil.appletSuccess(goodsData); @@ -1143,8 +2831,8 @@ public class AppletController extends BaseController { * - 保持原有排序不变 * - 无需用户登录验证 */ - @GetMapping(value = "/api/mall/cate/lst/{type}") - public AjaxResult getMallCategoryList(@PathVariable("type") int type, HttpServletRequest request) { + @GetMapping(value = "/api/mall/cate/lst") + public AjaxResult getMallCategoryList(HttpServletRequest request) { try { // 构建查询条件 ServiceCate serviceCateQuery = new ServiceCate(); @@ -1662,7 +3350,7 @@ public class AppletController extends BaseController { userInfo.put("nickname", user.getNickname()); userInfo.put("phone", user.getPhone()); userInfo.put("password", null); // 密码不返回 - // userInfo.put("ismember", user.getIsmember()); + // userInfo.put("ismember", user.getIsmember()); // if (user.getMemberBegin() != null) { // userInfo.put("member_begin", sdfday.format(user.getMemberBegin())); // } @@ -1685,9 +3373,17 @@ public class AppletController extends BaseController { // 其他业务字段 if (user.getType().equals("2")) { - userInfo.put("commission", user.getCommission() != null ? user.getCommission().toString() : "0.00"); + BigDecimal bb= user.getCommission(); + //冻结金额 + BigDecimal lookmoney= workerMoneyLogService.selectWorkerLookMoneySum(Math.toIntExact(user.getId())); + if (user.getCommission()== null) { + bb= new BigDecimal(0); + } + + userInfo.put("commission", bb.subtract(lookmoney)); userInfo.put("total_comm", user.getTotalComm() != null ? user.getTotalComm().toString() : "0.00"); userInfo.put("propose", user.getPropose() != null ? user.getPropose().toString() : "0.00"); + userInfo.put("lookmoney",lookmoney); } if (user.getType().equals("1")) { userInfo.put("balance", user.getBalance() != null ? user.getBalance().toString() : "0.00"); @@ -1912,96 +3608,96 @@ public class AppletController extends BaseController { return AppletControllerUtil.appletWarning("查询订单状态失败:" + e.getMessage()); } } - /** - * 查询用户售后返修列表 - * - * @param params 请求参数,包含page(页码)、limit(每页数量) - * @param request HTTP请求对象 - * @return 返回分页的售后返修列表 - *

- * 功能说明: - * - 获取当前登录用户的售后返修记录 - * - 支持分页查询 - * - 按创建时间倒序排列 - * - 返回符合前端要求的分页格式 - */ - @PostMapping("/api/service/order/rework/lst") - public AjaxResult getReworkList(@RequestBody Map params, HttpServletRequest request) { - try { - // 1. 获取分页参数 - int page = params.get("page") != null ? (Integer) params.get("page") : 1; - int limit = params.get("limit") != null ? (Integer) params.get("limit") : 15; - int status = (Integer) params.get("status"); - - // 2. 验证分页参数 - Map pageValidation = PageUtil.validatePageParams(page, limit); - if (!(Boolean) pageValidation.get("valid")) { - return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); - } - - // 3. 验证用户登录状态 - String token = request.getHeader("token"); - Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); - if (!(Boolean) userValidation.get("valid")) { - return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); - } - - // 4. 获取用户信息 - Users user = (Users) userValidation.get("user"); - if (user == null) { - return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); - } - - // 5. 设置分页参数 - PageHelper.startPage(page, limit); - - // 6. 构建查询条件 - OrderRework queryCondition = new OrderRework(); - queryCondition.setUid(user.getId()); // 只查询当前用户的售后记录 - queryCondition.setStatus(status); - // 7. 查询售后返修列表 - List reworkList = orderReworkService.selectOrderReworkList(queryCondition); - - // 8. 构建分页数据 - PageInfo pageInfo = new PageInfo<>(reworkList); - - // 9. 构建返回数据格式 - Map responseData = new HashMap<>(); - responseData.put("current_page", pageInfo.getPageNum()); - responseData.put("data", reworkList); - responseData.put("from", pageInfo.getStartRow()); - responseData.put("last_page", pageInfo.getPages()); - responseData.put("per_page", String.valueOf(pageInfo.getPageSize())); - responseData.put("to", pageInfo.getEndRow()); - responseData.put("total", pageInfo.getTotal()); - - // 构建分页链接信息 - Map links = new HashMap<>(); - Map prevLink = new HashMap<>(); - prevLink.put("url", null); - prevLink.put("label", "« Previous"); - prevLink.put("active", false); - - Map nextLink = new HashMap<>(); - nextLink.put("url", pageInfo.isHasNextPage() ? - "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getNextPage() : null); - nextLink.put("label", "Next »"); - nextLink.put("active", false); - - responseData.put("links", new Object[]{prevLink, nextLink}); - responseData.put("next_page_url", pageInfo.isHasNextPage() ? - "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getNextPage() : null); - responseData.put("path", "https://www.huafurenjia.cn/api/service/order/rework/lst"); - responseData.put("prev_page_url", pageInfo.isHasPreviousPage() ? - "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getPrePage() : null); - - return AppletControllerUtil.appletSuccess(responseData); - - } catch (Exception e) { - System.err.println("查询售后返修列表异常:" + e.getMessage()); - return AppletControllerUtil.appletWarning("查询售后返修列表失败:" + e.getMessage()); - } - } +// /** +// * 查询用户售后返修列表 +// * +// * @param params 请求参数,包含page(页码)、limit(每页数量) +// * @param request HTTP请求对象 +// * @return 返回分页的售后返修列表 +// *

+// * 功能说明: +// * - 获取当前登录用户的售后返修记录 +// * - 支持分页查询 +// * - 按创建时间倒序排列 +// * - 返回符合前端要求的分页格式 +// */ +// @PostMapping("/api/service/order/rework/lst") +// public AjaxResult getReworkList(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 获取分页参数 +// int page = params.get("page") != null ? (Integer) params.get("page") : 1; +// int limit = params.get("limit") != null ? (Integer) params.get("limit") : 15; +// int status = (Integer) params.get("status"); +// +// // 2. 验证分页参数 +// Map pageValidation = PageUtil.validatePageParams(page, limit); +// if (!(Boolean) pageValidation.get("valid")) { +// return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); +// } +// +// // 3. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 4. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); +// } +// +// // 5. 设置分页参数 +// PageHelper.startPage(page, limit); +// +// // 6. 构建查询条件 +// OrderRework queryCondition = new OrderRework(); +// queryCondition.setUid(user.getId()); // 只查询当前用户的售后记录 +// queryCondition.setStatus(status); +// // 7. 查询售后返修列表 +// List reworkList = orderReworkService.selectOrderReworkList(queryCondition); +// +// // 8. 构建分页数据 +// PageInfo pageInfo = new PageInfo<>(reworkList); +// +// // 9. 构建返回数据格式 +// Map responseData = new HashMap<>(); +// responseData.put("current_page", pageInfo.getPageNum()); +// responseData.put("data", reworkList); +// responseData.put("from", pageInfo.getStartRow()); +// responseData.put("last_page", pageInfo.getPages()); +// responseData.put("per_page", String.valueOf(pageInfo.getPageSize())); +// responseData.put("to", pageInfo.getEndRow()); +// responseData.put("total", pageInfo.getTotal()); +// +// // 构建分页链接信息 +// Map links = new HashMap<>(); +// Map prevLink = new HashMap<>(); +// prevLink.put("url", null); +// prevLink.put("label", "« Previous"); +// prevLink.put("active", false); +// +// Map nextLink = new HashMap<>(); +// nextLink.put("url", pageInfo.isHasNextPage() ? +// "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getNextPage() : null); +// nextLink.put("label", "Next »"); +// nextLink.put("active", false); +// +// responseData.put("links", new Object[]{prevLink, nextLink}); +// responseData.put("next_page_url", pageInfo.isHasNextPage() ? +// "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getNextPage() : null); +// responseData.put("path", "https://www.huafurenjia.cn/api/service/order/rework/lst"); +// responseData.put("prev_page_url", pageInfo.isHasPreviousPage() ? +// "https://www.huafurenjia.cn/api/service/order/rework/lst?page=" + pageInfo.getPrePage() : null); +// +// return AppletControllerUtil.appletSuccess(responseData); +// +// } catch (Exception e) { +// System.err.println("查询售后返修列表异常:" + e.getMessage()); +// return AppletControllerUtil.appletWarning("查询售后返修列表失败:" + e.getMessage()); +// } +// } /** * 合作申请提交接口 @@ -3067,50 +4763,256 @@ public class AppletController extends BaseController { return AppletControllerUtil.appletError("文件上传失败:" + e.getMessage()); } } +// /** +// * 获取服务预约时间段接口 +// * +// * @param params 请求参数,包含day(预约日期) +// * @param request HTTP请求对象 +// * @return 时间段列表数据 +// *

+// * 接口说明: +// * - 根据指定日期获取可预约的时间段列表 +// * - 返回每个时间段的可用状态和剩余数量 +// * - 支持动态时间段配置 +// * - 无需用户登录验证 +// *

+// */ +// @PostMapping(value = "/api/service/make/time") +// public AjaxResult getServiceMakeTime(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 参数验证 +// if (params == null || params.get("day") == null) { +// return AppletControllerUtil.appletWarning("日期参数不能为空"); +// } +// String day = params.get("day").toString().trim(); +// if (day.isEmpty()) { +// return AppletControllerUtil.appletWarning("日期参数不能为空"); +// } +// // 2. 验证日期格式 +// if (!AppletControllerUtil.isValidDateFormat(day)) { +// return AppletControllerUtil.appletWarning("日期格式错误,请使用yyyy-MM-dd格式"); +// } +// // 3. 检查日期是否为过去时间 +// if (AppletControllerUtil.isPastDate(day)) { +// return AppletControllerUtil.appletWarning("不能预约过去的日期"); +// } +// // 4. 构建时间段列表 +// List> timeSlotList = AppletControllerUtil.buildTimeSlotList(day); +// +// return AppletControllerUtil.appletSuccess(timeSlotList); +// +// } catch (Exception e) { +// System.err.println("获取服务预约时间段异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("获取时间段失败:" + e.getMessage()); +// } +// } + + /** - * 获取服务预约时间段接口 + * 预约时间选择接口 * - * @param params 请求参数,包含day(预约日期) * @param request HTTP请求对象 - * @return 时间段列表数据 - *

+ * @return 可预约时间段列表 + * * 接口说明: - * - 根据指定日期获取可预约的时间段列表 - * - 返回每个时间段的可用状态和剩余数量 - * - 支持动态时间段配置 - * - 无需用户登录验证 - *

+ * - day=1:今天 + * - day=2:不是今天 + * - 返回每个时间段的预约状态和剩余数量 */ @PostMapping(value = "/api/service/make/time") - public AjaxResult getServiceMakeTime(@RequestBody Map params, HttpServletRequest request) { + public AjaxResult orderMakeTime(@RequestBody Map params, HttpServletRequest request) { try { - // 1. 参数验证 + // 参数验证 if (params == null || params.get("day") == null) { return AppletControllerUtil.appletWarning("日期参数不能为空"); } String day = params.get("day").toString().trim(); - if (day.isEmpty()) { - return AppletControllerUtil.appletWarning("日期参数不能为空"); - } - // 2. 验证日期格式 - if (!AppletControllerUtil.isValidDateFormat(day)) { - return AppletControllerUtil.appletWarning("日期格式错误,请使用yyyy-MM-dd格式"); - } - // 3. 检查日期是否为过去时间 - if (AppletControllerUtil.isPastDate(day)) { - return AppletControllerUtil.appletWarning("不能预约过去的日期"); - } - // 4. 构建时间段列表 - List> timeSlotList = AppletControllerUtil.buildTimeSlotList(day); + // 获取当前时间 + Calendar now = Calendar.getInstance(); + String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(now.getTime()); + int nowHour = now.get(Calendar.HOUR_OF_DAY); + int nowMinute = now.get(Calendar.MINUTE); + int nowSecond = now.get(Calendar.SECOND); + int nowTimeInSeconds = nowHour * 3600 + nowMinute * 60 + nowSecond; - return AppletControllerUtil.appletSuccess(timeSlotList); + // 解析目标日期 + long targetDayTime = 0; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date targetDate = sdf.parse(day); + targetDayTime = targetDate.getTime() / 1000; // 转换为秒 + } catch (Exception e) { + return AppletControllerUtil.appletError("日期格式错误,请使用yyyy-MM-dd格式"); + } + + // 获取预约时间配置 + List> timeConfig = getTimeConfigFromDatabase(); + if (timeConfig == null || timeConfig.isEmpty()) { + return AppletControllerUtil.appletError("未找到预约时间配置"); + } + + List> result = new ArrayList<>(); + + for (Map timeSlot : timeConfig) { + String timeKey = (String) timeSlot.get("key"); + Integer maxNum = (Integer) timeSlot.get("num"); + + if (timeKey == null || maxNum == null) { + continue; // 跳过无效配置 + } + + boolean click = true; + String prove = "可预约"; + Integer residueNum = null; + + // 判断是否是今天 + if (nowDay.equals(day)) { + // 解析时间段 + String[] timeParts = timeKey.split("-"); + if (timeParts.length == 2) { + String endTime = timeParts[1]; + String[] timeArr = endTime.split(":"); + if (timeArr.length == 2) { + try { + int hour = Integer.parseInt(timeArr[0]); + int minute = Integer.parseInt(timeArr[1]); + int timeInSeconds = hour * 3600 + minute * 60; + + // 如果当前时间已经超过这个时间段,则不可预约 + if (nowTimeInSeconds > timeInSeconds) { + click = false; + prove = "时间已过"; + } + } catch (NumberFormatException e) { + // 时间格式错误,跳过这个时间段 + continue; + } + } + } + } + + // 如果时间段可用,检查预约数量 + if (click) { + try { + // 使用精确的查询方法获取预约数量 + Map queryParams = new HashMap<>(); + queryParams.put("makeTime", targetDayTime); + queryParams.put("makeHour", timeKey); + + // 查询当前时间段的预约数量 + Integer makeCount = orderService.selectOrderCountByMakeTimeAndHour(queryParams); + + if (makeCount == null) { + makeCount = 0; + } + + if (makeCount >= maxNum) { + click = false; + prove = "该时间段已约满"; + } else { + residueNum = maxNum - makeCount; + } + } catch (Exception e) { + // 查询失败,标记为不可预约 + click = false; + prove = "查询失败"; + logger.error("查询预约数量失败: " + e.getMessage()); + } + } + + // 构建返回数据 + Map timeData = new HashMap<>(); + timeData.put("click", click); + timeData.put("value", timeKey); + timeData.put("prove", prove); + timeData.put("residue_num", residueNum); + + result.add(timeData); + } + + return AppletControllerUtil.appletSuccess(result); } catch (Exception e) { - System.err.println("获取服务预约时间段异常:" + e.getMessage()); - return AppletControllerUtil.appletError("获取时间段失败:" + e.getMessage()); + return AppletControllerUtil.appletError("获取预约时间失败:" + e.getMessage()); } } + /** + * 从数据库获取预约时间配置 + * + * @return 时间配置列表 + */ + private List> getTimeConfigFromDatabase() { + try { + // 从数据库查询配置,对应PHP代码中的SiteConfig::where(['name'=>'config_three']) + SiteConfig siteConfig = siteConfigService.selectSiteConfigByName("config_three"); + + if (siteConfig == null || siteConfig.getValue() == null || siteConfig.getValue().trim().isEmpty()) { + // 如果数据库中没有配置,返回默认配置 + return getDefaultTimeConfig(); + } + + // 解析JSON配置,对应PHP代码中的json_decode($site_time['value'], true) + try { + com.alibaba.fastjson.JSONObject configJson = com.alibaba.fastjson.JSONObject.parseObject(siteConfig.getValue()); + com.alibaba.fastjson.JSONArray timeArray = configJson.getJSONArray("time"); + + if (timeArray == null || timeArray.isEmpty()) { + return getDefaultTimeConfig(); + } + + List> config = new ArrayList<>(); + + for (int i = 0; i < timeArray.size(); i++) { + com.alibaba.fastjson.JSONObject timeSlot = timeArray.getJSONObject(i); + + Map slot = new HashMap<>(); + slot.put("key", timeSlot.getString("key")); + slot.put("num", timeSlot.getInteger("num")); + config.add(slot); + } + + return config; + + } catch (Exception e) { + // JSON解析失败,返回默认配置 + System.err.println("解析预约时间配置JSON失败: " + e.getMessage()); + return getDefaultTimeConfig(); + } + + } catch (Exception e) { + // 数据库查询失败,返回默认配置 + System.err.println("查询预约时间配置失败: " + e.getMessage()); + return getDefaultTimeConfig(); + } + } + + /** + * 获取默认时间配置 + * + * @return 默认时间配置列表 + */ + private List> getDefaultTimeConfig() { + List> config = new ArrayList<>(); + + // 默认的时间段配置 + String[] timeSlots = { + "08:00-09:00", "09:00-10:00", "10:00-11:00", "11:00-12:00", + "13:00-14:00", "14:00-15:00", "15:00-16:00", "16:00-17:00", + "17:00-18:00", "18:00-19:00", "19:00-20:00" + }; + + for (String timeSlot : timeSlots) { + Map slot = new HashMap<>(); + slot.put("key", timeSlot); + slot.put("num", 5); // 每个时间段最多5个预约 + config.add(slot); + } + + return config; + } + + /** * 添加商品到购物车接口 * @@ -4096,10 +5998,13 @@ public class AppletController extends BaseController { orderLogService.insertOrderLog(orderLog); UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(order.getOrderId()); //如果有支付信息就要进行退款 + System.out.println("=== 开始退款处理,订单号: " + order.getOrderId() + " ==="); if (usersPayBefor != null) { - if (usersPayBefor.getStatus() == 2){ + System.out.println("=== 开始退款处理,2222222222订单号: " + usersPayBefor.getStatus() + " ==="); + // if (usersPayBefor.getStatus() == 2){ + System.out.println("=== 开始退款处理,2222222222订单号: " + order.getOrderId() + " ==="); refundUtil.refundOrder(order.getOrderId()); - } + // } } return AppletControllerUtil.appletSuccess("取消成功"); @@ -5883,7 +7788,12 @@ public class AppletController extends BaseController { Map cMap = new HashMap<>(); cMap.put("id", c.getId()); cMap.put("uid", c.getUid()); - cMap.put("images", c.getImages()); + if (StringUtils.isNotBlank(c.getImages())){ + cMap.put("images", JSONArray.parseArray(c.getImages())); + }else{ + cMap.put("images", JSONArray.parseArray("[]")); + } + cMap.put("content", c.getContent()); cMap.put("num", c.getNum()); cMap.put("created_at", c.getCreatedAt() != null ? sdf.format(c.getCreatedAt()) : null); @@ -5953,6 +7863,38 @@ public class AppletController extends BaseController { } } + /** + * 师傅签到日志接口 + * + * @param request + * @return 签到日志列表 + */ + @GetMapping("/api/form/worker/apply/check") + public AjaxResult apiformworkerapplycheck(HttpServletRequest request) { + try { + // 校验token并获取用户 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); + } + WorkerApply workerApply = new WorkerApply(); + workerApply.setUid(user.getId()); + List workerApplyList = workerApplyService.selectWorkerApplyList(workerApply); + if (workerApplyList == null || workerApplyList.isEmpty()) { + return AppletControllerUtil.appletError("用户没有申请成为师傅"); + } + return AjaxResult.success(workerApplyList.getFirst()); + } catch (Exception e) { + return AjaxResult.error("查询签到日志失败:" + e.getMessage()); + } + } + + /** * 师傅签到日志接口 * @@ -5998,7 +7940,14 @@ public class AppletController extends BaseController { Map map = new HashMap<>(); map.put("id", sign.getId()); map.put("date", sdf.format(sign.getTime())); - map.put("info", sign.getUname()); + map.put("info", "签到"); +// Users u = usersService.selectUsersById(Long.valueOf(sign.getUid())); +// if (u != null){ +// map.put("info", u); +// }else{ +// map.put("info", ""); +// } + result.add(map); } } @@ -6043,6 +7992,7 @@ public class AppletController extends BaseController { map.put("id", log.getId()); map.put("uid", log.getUid()); map.put("oid", log.getOid()); + map.put("reamk", log.getReamk()); map.put("order_id", log.getOrderId()); map.put("price", log.getPrice() != null ? log.getPrice().toString() : "0.00"); map.put("created_at", log.getCreatedAt() != null ? sdf.format(log.getCreatedAt()) : null); @@ -6140,6 +8090,17 @@ public class AppletController extends BaseController { map.put("service_price", log.getServicePrice() != null ? log.getServicePrice().toString() : "0.00"); map.put("reduction_price", log.getReductionPrice() != null ? log.getReductionPrice().toString() : "0.00"); map.put("cr", log.getCr()); + map.put("goodsmoney",log.getClmoney()); + // map.put("jsfs","服务佣金:1397.00*60.0000=838.20\\n材料费用:180.00材料分佣:0\\n质保金:(838.20+0)*质保金基数(10%)=83.82\\n最终应得:838.20+0-83.82+0=754.38"); + map.put("jsfs", log.getGongshi()); + map.put("status", log.getStatus()); + map.put("lookday", log.getLookday()); + map.put("status_type", log.getStatusType()); + map.put("beginlook", log.getBeginlook() != null ? log.getBeginlook().toString() : null); + map.put("endlook", log.getEndlook() != null ? log.getEndlook().toString() : null); + map.put("look_money", log.getLookMoney()); + map.put("admin_up_price", log.getAdminUpPrice()); + map.put("admin_up_reamk", log.getAdminUpReamk()); map.put("mergin", log.getMergin() != null ? log.getMergin().toString() : "0.00"); map.put("door_price", log.getDoorPrice() != null ? log.getDoorPrice().toString() : null); map.put("created_at", log.getCreatedAt() != null ? sdf.format(log.getCreatedAt()) : null); @@ -6472,6 +8433,7 @@ public class AppletController extends BaseController { public AjaxResult getWorkerBasicProject(@RequestParam(value = "id", required = false) Long id, @RequestParam(value = "goodid", required = false) Long goodid) { List basicList = new ArrayList<>(); + Map data = new HashMap<>(); Object quoteJson = null; // 1. 如果订单id不为空,查订单和报价日志 if (id != null) { @@ -6519,7 +8481,34 @@ public class AppletController extends BaseController { } } } - Map data = new HashMap<>(); + + + + //查询报价的支付信息 + if (id != null) { + Order order = orderService.selectOrderById(id); + if (order != null) { + // 查 type=5.0 的订单日志 + OrderLog logQuery = new OrderLog(); + logQuery.setOid(order.getId()); + logQuery.setType(new BigDecimal("5.0")); + List logs = orderLogService.selectOrderLogList(logQuery); + OrderLog logdata = logs.getFirst(); + if (logdata != null) { + Map paydata = new HashMap<>(); + paydata.put("weikuan", logdata.getPaid()); + paydata.put("dingjin", logdata.getDepPaid()); + data.put("payStatusdata", paydata); + } + + } + }else{ + Map paydata = new HashMap<>(); + paydata.put("weikuan", "1"); + paydata.put("dingjin", "1"); + data.put("payStatusdata", paydata); + } + data.put("basic", basicList); if (quoteJson != null) { data.put("quote", quoteJson); @@ -6822,10 +8811,7 @@ public class AppletController extends BaseController { List orderLogslist = orderLogService.selectOrderLogList(neworderLogdata); if(!orderLogslist.isEmpty()){ OrderLog neworderLog=orderLogslist.getFirst(); - - neworderLog.setContent(contentStr); - if (params.get("price") != null) { //String DepLogId = GenerateCustomCode.generCreateOrder("LOG"); neworderLog.setDeposit(new BigDecimal(params.get("price").toString())); @@ -6845,14 +8831,32 @@ public class AppletController extends BaseController { }else { neworderLog.setDeposit(BigDecimal.ZERO); } - neworderLog.setPrice(totalPrice.add(reductionPrice)); - neworderLog.setPaid(1l); + +// neworderLog.setPrice(totalPrice.add(reductionPrice)); + neworderLog.setPaid(1L); if (params.get("reduction") != null) { neworderLog.setReductionPrice(new BigDecimal(params.get("reduction").toString())); } else { neworderLog.setReductionPrice(BigDecimal.ZERO); } - neworderLog.setWorkerCost(ServiceAllPrice.subtract(reductionPrice)); + System.out.println("neworderLog.getPrice():totalPrice"+totalPrice); + System.out.println("neworderLog.getPrice():reductionPrice"+reductionPrice); + System.out.println("neworderLog.getPrice():neworderLog.getDeposit()"+neworderLog.getDeposit()); + + BigDecimal WK=totalPrice.subtract(reductionPrice).subtract(neworderLog.getDeposit()); + System.out.println("neworderLog.getPrice():neworderLog.getDeposit()WKWKWK"+WK); + if(WK.compareTo(BigDecimal.ZERO)>0){ + System.out.println("111neworderLog.getPrice():neworderLog.getDeposit()WKWKWK"+WK); + neworderLog.setPrice(WK); + }else{ + neworderLog.setPrice(BigDecimal.ZERO); + } +// if (params.get("reduction") != null) { +// neworderLog.setReductionPrice(new BigDecimal(params.get("reduction").toString())); +// } else { +// neworderLog.setReductionPrice(BigDecimal.ZERO); +// } + neworderLog.setWorkerCost(BigDecimal.ZERO); //log.set neworderLog.setLogId(GenerateCustomCode.generCreateOrder("EST")); //删除之前的预支付信息 @@ -6874,13 +8878,14 @@ public class AppletController extends BaseController { usersPayBeforService.deleteUsersPayBeforById(payBefore4.getId()); } } - - - - Users userinfo = usersService.selectUsersById(order.getUid()); payBeforeUtil.handleQuotationPayBefore(userinfo, neworderLog, contentStr, order.getOrderId()); - orderLogService.updateOrderLog(neworderLog); + int flg= orderLogService.updateOrderLog(neworderLog); + if (flg > 0) { + order.setGoodPrice(GoodsAllPrice); + order.setServicePrice(ServiceAllPrice); + orderService.updateOrder(order); + } return AppletControllerUtil.appletSuccess("报价成功"); }else{ order.setJsonStatus(6); @@ -6907,8 +8912,14 @@ public class AppletController extends BaseController { }else { log.setDeposit(BigDecimal.ZERO); } - log.setPrice(totalPrice.add(reductionPrice)); - log.setPaid(1l); + BigDecimal WK=totalPrice.subtract(reductionPrice).subtract(log.getDeposit()); + if(WK.compareTo(BigDecimal.ZERO)>0){ + log.setWorkerCost(WK); + }else{ + log.setWorkerCost(BigDecimal.ZERO); + } +// log.setPrice(totalPrice.add(reductionPrice)); + log.setPaid(1L); if (params.get("reduction") != null) { log.setReductionPrice(new BigDecimal(params.get("reduction").toString())); } else { @@ -6919,7 +8930,12 @@ public class AppletController extends BaseController { log.setLogId(GenerateCustomCode.generCreateOrder("EST")); log.setWorkerLogId(order.getWorkerId()); log.setWorkerId(order.getWorkerId()); - orderLogService.insertOrderLog(log); + int flg=orderLogService.insertOrderLog(log); + if (flg > 0) { + order.setGoodPrice(GoodsAllPrice); + order.setServicePrice(ServiceAllPrice); + orderService.updateOrder(order); + } Users user = usersService.selectUsersById(order.getUid()); ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); //小程序推送用户报价成功 @@ -7197,16 +9213,16 @@ public class AppletController extends BaseController { } PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); String priceDifferenceprice= params.get("priceDifferenceprice").toString(); - int paynum=usersPayBeforService.countByLastOrderIdAndStatus(order.getOrderId()); - //如果订单没有支付 - if (paynum<=0){ - // 1. 修改订单状态 - order.setStatus(6L); // 完成 - order.setReceiveType(3L); // 完成类型 - order.setJsonStatus(9); // 完成 - order.setLogJson("{\"type\":8}"); - int update = orderService.updateOrder(order); - } +// int paynum=usersPayBeforService.countByLastOrderIdAndStatus(order.getOrderId()); +// //如果订单没有支付 +// if (paynum<=0){ +// // 1. 修改订单状态 +// order.setStatus(6L); // 完成 +// order.setReceiveType(3L); // 完成类型 +// order.setJsonStatus(9); // 完成 +// order.setLogJson("{\"type\":8}"); +// int update = orderService.updateOrder(order); +// } // 2. 组装日志内容 Map logContent = new LinkedHashMap<>(); logContent.put("name", "师傅服务完成"); @@ -7222,22 +9238,44 @@ public class AppletController extends BaseController { log.setContent(contentStr); log.setWorkerId(order.getWorkerId()); log.setCreatedAt(new Date()); - //如果有补差价,就要插入日志中进行处理 if (StringUtils.isNotBlank(priceDifferenceprice)) { log.setCjMoney(new BigDecimal(priceDifferenceprice)); log.setCjPaid(1L); - Users userinfo = usersService.selectUsersById(order.getUid()); - - payBeforeUtil.createPayBefore(userinfo, log.getCjMoney(), log.getLogOrderId(), log.getId(), - null, 10L, null, null, - null, null, null,1L,null,order.getOrderId()); - } + } orderLogService.insertOrderLog(log); - Users users = usersService.selectUsersById(order.getUid()); - ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); + //如果有补差价,就要插入日志中进行处理 + if (StringUtils.isNotBlank(priceDifferenceprice)) { + log.setCjMoney(new BigDecimal(priceDifferenceprice)); + log.setCjPaid(1L); + Users userinfo = usersService.selectUsersById(order.getUid()); + + payBeforeUtil.createPayBefore(userinfo, log.getCjMoney(), log.getLogOrderId(), log.getId(), + null, 10L, null, null, + null, null, null,1L,null,order.getOrderId()); + } + //判断这个订单还有没有未支付的数据,如果有就停留在服务中如果没有就直接去到状态为4的已完成状态 + int paynum=usersPayBeforService.countByLastOrderIdAndStatus(order.getOrderId()); + //如果订单没有支付,订单完成,分佣,推送 + if (paynum<=0){ + order.setStatus(4L); // 完成 + order.setReceiveType(3L); // 完成类型 + order.setJsonStatus(9); // 完成 + order.setLogJson("{\"type\":8}"); + int update = orderService.updateOrder(order); + + Users wusers = usersService.selectUsersById(order.getWorkerId()); + WorkerCommissionUtil.processWorkerCommission(order,wusers); + Users users = usersService.selectUsersById(order.getUid()); + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); + WXsendMsgUtil.sendWorkerFinishOrder(users.getOpenid(), order, serviceGoods); + }else{ + order.setStatus(6L); // 完成 + order.setJsonStatus(9); // 完成 + int update = orderService.updateOrder(order); + } + - WXsendMsgUtil.sendWorkerFinishOrder(users.getOpenid(), order, serviceGoods); return AppletControllerUtil.appletSuccess("服务已完成"); } @@ -7624,6 +9662,7 @@ public class AppletController extends BaseController { @PostMapping(value = "/api/worker/grab/lst") public AjaxResult getWorkerGrabOrderList(@RequestBody Map params, HttpServletRequest request) { try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 1. 解析分页参数 int page = 1; int limit = 15; @@ -7653,7 +9692,7 @@ public class AppletController extends BaseController { // 3. 查询状态为1(待接单)的订单 Order orderQuery = new Order(); orderQuery.setStatus(1L); // 待接单状态 - + orderQuery.setQiangdan("1"); List orderList = orderService.selectOrderList(orderQuery); PageInfo pageInfo = new PageInfo<>(orderList); @@ -7677,23 +9716,28 @@ public class AppletController extends BaseController { orderData.put("name", order.getName()); orderData.put("phone", order.getPhone()); orderData.put("address", order.getAddress()); - - // 预约时间处理 - String makeTime = ""; - if (order.getMakeTime() != null) { - try { - // 将时间戳转换为日期格式 - Date makeDate = new Date(order.getMakeTime() * 1000L); - SimpleDateFormat makeDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - makeTime = makeDateFormat.format(makeDate); - if (order.getMakeHour() != null) { - makeTime += " " + order.getMakeHour(); - } - } catch (Exception e) { - makeTime = ""; - } + // make_time格式化 + if (order.getMakeTime() != null && order.getMakeHour() != null) { + orderData.put("make_time", sdf.format(new Date(order.getMakeTime() * 1000)) + " " + order.getMakeHour()); + } else { + orderData.put("make_time", null); } - orderData.put("make_time", makeTime); +// // 预约时间处理 +// String makeTime = ""; +// if (order.getMakeTime() != null) { +// try { +// // 将时间戳转换为日期格式 +// Date makeDate = new Date(order.getMakeTime() * 1000L); +// SimpleDateFormat makeDateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// makeTime = makeDateFormat.format(makeDate); +// if (order.getMakeHour() != null) { +// makeTime += " " + order.getMakeHour(); +// } +// } catch (Exception e) { +// makeTime = ""; +// } +// } +// orderData.put("make_time", makeTime); orderData.put("make_hour", order.getMakeHour()); orderData.put("num", order.getNum()); @@ -7708,7 +9752,8 @@ public class AppletController extends BaseController { orderData.put("is_pause", order.getIsPause()); orderData.put("mark", order.getMark()); orderData.put("address_id", order.getAddressId()); - orderData.put("sku", order.getSku()); + // orderData.put("sku", order.getSku()); + orderData.put("sku",AppletControllerUtil.parseSkuStringToObject(order.getSku())); orderData.put("worker_id", order.getWorkerId()); orderData.put("first_worker_id", order.getFirstWorkerId()); orderData.put("receive_time", order.getReceiveTime() != null ? dateFormat.format(order.getReceiveTime()) : null); @@ -8047,6 +10092,8 @@ public class AppletController extends BaseController { productInfo.put("title", product.getTitle()); productInfo.put("price", product.getPrice() != null ? product.getPrice().toString() : "0.00"); productInfo.put("stock", product.getStock()); + productInfo.put("isforservice", product.getIsforservice()); + productInfo.put("forserviceid", product.getForserviceid()); productInfo.put("sku_type", product.getSkuType()); productInfo.put("icon", AppletControllerUtil.buildImageUrl(product.getIcon())); responseData.put("product", productInfo); @@ -8594,7 +10641,7 @@ public class AppletController extends BaseController { // 分页封装 TableDataInfo tableDataInfo = getDataTable(goodsList); tableDataInfo.setRows(resultList); // 只返回精简字段 - Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); return AppletControllerUtil.appletSuccess(pageData); } //次卡数据 @@ -8646,7 +10693,7 @@ public class AppletController extends BaseController { // 分页封装 TableDataInfo tableDataInfo = getDataTable(goodsList); tableDataInfo.setRows(resultList); // 只返回精简字段 - Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); return AppletControllerUtil.appletSuccess(pageData); } //秒杀数据 @@ -8677,7 +10724,7 @@ public class AppletController extends BaseController { // 分页封装 TableDataInfo tableDataInfo = getDataTable(goodsList); tableDataInfo.setRows(resultList); // 只返回精简字段 - Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); // 获取秒杀相关数据 long msdata = 0L; @@ -8738,7 +10785,7 @@ public class AppletController extends BaseController { // 分页封装 TableDataInfo tableDataInfo = getDataTable(goodsList); tableDataInfo.setRows(resultList); // 只返回精简字段 - Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); return AppletControllerUtil.appletSuccess(pageData); } @@ -8747,275 +10794,5 @@ public class AppletController extends BaseController { } return null; } - /** - * 根据ID查询预支付记录并计算支付金额 - * - * @param id 预支付记录ID - * @param params 请求参数,包含paytype、coupon_id、mtcode - * @param request HTTP请求对象 - * @return 预支付记录详情和计算后的支付金额 - */ - @PostMapping("/api/paybefor/info/{id}") - public AjaxResult getPayBeforInfo(@PathVariable("id") String id, @RequestBody Map params, HttpServletRequest request) { - try { - // 1. 验证用户登录状态 - String token = request.getHeader("token"); - Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); - if (!(Boolean) userValidation.get("valid")) { - return AppletControllerUtil.appletWarning("用户未登录或token无效"); - } - Users user = (Users) userValidation.get("user"); - if (user == null) { - return AppletControllerUtil.appletWarning("用户信息获取失败"); - } - // 2. 参数验证 - if (StringUtils.isBlank(id)) { - return AppletControllerUtil.appletWarning("预支付记录ID不能为空"); - } - - // 3. 获取请求参数 - Integer paytype = params.get("paytype") != null ? Integer.parseInt(params.get("paytype").toString()) : 1; - Long couponId = params.get("coupon_id") != null ? Long.parseLong(params.get("coupon_id").toString()) : null; - String mtcode = params.get("mtcode") != null ? params.get("mtcode").toString() : null; - - // 4. 查询预支付记录 - UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(id); - if (payBefor == null) { - return AppletControllerUtil.appletWarning("预支付记录不存在"); - } - - // 5. 验证记录归属权(只能查看自己的记录) - if (!payBefor.getUid().equals(user.getId())) { - return AppletControllerUtil.appletWarning("无权查看该预支付记录"); - } - - // 6. 获取原始总金额(allmoney是固定的,永远不会改变) - BigDecimal originalAmount = payBefor.getAllmoney(); - if (originalAmount == null) { - originalAmount = BigDecimal.ZERO; - } - - // 获取会员优惠金额(固定不变) - BigDecimal memberMoney = payBefor.getMembermoney(); - if (memberMoney == null) { - memberMoney = BigDecimal.ZERO; - } - - // 获取服务金抵扣金额(固定不变) - BigDecimal serviceMoney = payBefor.getServicemoney(); - if (serviceMoney == null) { - serviceMoney = BigDecimal.ZERO; - } - - // 获取购物金抵扣金额(固定不变) - BigDecimal shopMoney = payBefor.getShopmoney(); - if (shopMoney == null) { - shopMoney = BigDecimal.ZERO; - } - - // 7. 计算优惠券金额(每次重新计算) - BigDecimal couponMoney = BigDecimal.ZERO; - if (couponId != null) { - CouponUser couponUser = couponUserService.selectCouponUserById(couponId); - if (couponUser != null && couponUser.getStatus() != null && couponUser.getStatus() == 1L) { - // 验证优惠券是否属于当前用户 - if (!couponUser.getUid().equals(user.getId())) { - return AppletControllerUtil.appletWarning("优惠券不属于当前用户"); - } - - // 验证优惠券是否过期 - if (couponUser.getLoseTime() != null && !"永久有效".equals(couponUser.getLoseTime())) { - try { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date loseTime = sdf.parse(couponUser.getLoseTime()); - if (new Date().after(loseTime)) { - return AppletControllerUtil.appletWarning("优惠券已过期"); - } - } catch (Exception e) { - logger.warn("解析优惠券过期时间失败: " + e.getMessage()); - } - } - - // 验证最低消费(基于原始金额) - if (couponUser.getMinPrice() != null && originalAmount.compareTo(BigDecimal.valueOf(couponUser.getMinPrice())) < 0) { - return AppletControllerUtil.appletWarning("订单金额未达到优惠券使用条件"); - } - - couponMoney = BigDecimal.valueOf(couponUser.getCouponPrice()); - } else { - return AppletControllerUtil.appletWarning("优惠券无效或已被使用"); - } - } - - // 8. 计算美团优惠金额(每次重新计算,2至15的随机整数用于测试) - BigDecimal mtMoney = BigDecimal.ZERO; - if (mtcode != null && !mtcode.trim().isEmpty()) { - // 生成2至15的随机整数 - Random random = new Random(); - int randomDiscount = random.nextInt(14) + 2; // 2到15的随机数 - mtMoney = new BigDecimal(randomDiscount); - } - - // 9. 计算实际应付金额(基于allmoney减去所有优惠) - BigDecimal actualAmount = originalAmount - .subtract(memberMoney) // 减去会员优惠 - .subtract(serviceMoney) // 减去服务金抵扣 - .subtract(shopMoney) // 减去购物金抵扣 - .subtract(couponMoney) // 减去优惠券金额 - .subtract(mtMoney); // 减去美团优惠 - - if (actualAmount.compareTo(BigDecimal.ZERO) < 0) { - actualAmount = BigDecimal.ZERO; - } - - // 10. 根据支付方式计算各支付渠道金额 - BigDecimal wxMoney = BigDecimal.ZERO; - BigDecimal yeMoney = BigDecimal.ZERO; - - if (paytype == 1) { - // 微信支付 - wxMoney = actualAmount; - yeMoney = BigDecimal.ZERO; - } else if (paytype == 2) { - // 余额支付 - if (user.getBalance() != null && user.getBalance().compareTo(actualAmount) >= 0) { - wxMoney = BigDecimal.ZERO; - yeMoney = actualAmount; - } else { - // 13. 构建返回数据 - Map result = new HashMap<>(); - result.put("id", payBefor.getId()); - result.put("orderId", payBefor.getOrderid()); - result.put("paycode", payBefor.getPaycode()); - result.put("allmoney", originalAmount); // 原始总金额(固定不变,这是您最初存储的金额) - result.put("finalAmount", actualAmount); // 实际应付金额(基于allmoney计算得出) - result.put("wxmoney", wxMoney); // 微信支付金额 - result.put("status", payBefor.getStatus()); - result.put("oid", payBefor.getOid()); - result.put("yemoney", yeMoney); // 余额支付金额 - result.put("membermoney", memberMoney); // 会员优惠金额(固定不变) - result.put("shopmoney", shopMoney); // 购物金抵扣金额(固定不变) - result.put("servicemoney", serviceMoney); // 服务金抵扣金额(固定不变) - result.put("couponmoney", couponMoney); // 优惠券金额(实时计算) - result.put("mtmoney", mtMoney); // 美团优惠金额(实时计算) - result.put("type", payBefor.getType()); - result.put("servicetype", payBefor.getServicetype()); - result.put("paytype", paytype); - result.put("usersBalance", user.getBalance()); - result.put("couponId", couponId); - result.put("mtcode", mtcode); - return AppletControllerUtil.appletSuccess(result); - } - } else if (paytype == 3) { - // 组合支付:优先使用余额,不足部分用微信支付 - if (user.getBalance() != null && user.getBalance().compareTo(actualAmount) >= 0) { - // 余额足够,全部用余额支付 - wxMoney = BigDecimal.ZERO; - yeMoney = actualAmount; - } else if (user.getBalance() != null && user.getBalance().compareTo(BigDecimal.ZERO) > 0) { - // 余额不足,优先扣除用户所有余额,剩余部分用微信支付 - yeMoney = user.getBalance(); - wxMoney = actualAmount.subtract(yeMoney); - } else { - // 无余额,全部微信支付 - wxMoney = actualAmount; - yeMoney = BigDecimal.ZERO; - } - } else { - return AppletControllerUtil.appletWarning("无效的支付方式"); - } - - // 11. 更新预支付记录(注意:allmoney保持不变,只更新其他字段) - payBefor.setPaytype(Long.valueOf(paytype)); - payBefor.setCouponid(couponId); - payBefor.setCouponmoney(couponMoney); - payBefor.setMtcode(mtcode); - payBefor.setMtmoney(mtMoney); - payBefor.setWxmoney(wxMoney); - payBefor.setYemoney(yeMoney); - // 注意:allmoney保持不变,这是原始总金额 - - int updateResult = usersPayBeforService.updateUsersPayBefor(payBefor); - if (updateResult <= 0) { - return AppletControllerUtil.appletWarning("更新预支付记录失败"); - } - - // 12. 构建支付公式 - StringBuilder paymentFormula = new StringBuilder(); - paymentFormula.append("总金额(").append(originalAmount).append(")"); - - // 添加各种优惠项 - if (memberMoney.compareTo(BigDecimal.ZERO) > 0) { - paymentFormula.append("-会员优惠(").append(memberMoney).append(")"); - } - if (serviceMoney.compareTo(BigDecimal.ZERO) > 0) { - paymentFormula.append("-服务金抵扣(").append(serviceMoney).append(")"); - } - if (shopMoney.compareTo(BigDecimal.ZERO) > 0) { - paymentFormula.append("-购物金抵扣(").append(shopMoney).append(")"); - } - if (couponMoney.compareTo(BigDecimal.ZERO) > 0) { - paymentFormula.append("-优惠券(").append(couponMoney).append(")"); - } - if (mtMoney.compareTo(BigDecimal.ZERO) > 0) { - paymentFormula.append("-美团优惠(").append(mtMoney).append(")"); - } - - paymentFormula.append("=").append(actualAmount).append("="); - - // 添加支付方式 - if (wxMoney.compareTo(BigDecimal.ZERO) > 0 && yeMoney.compareTo(BigDecimal.ZERO) > 0) { - // 组合支付 - paymentFormula.append("微信支付(").append(wxMoney).append(")+余额支付(").append(yeMoney).append(")"); - } else if (wxMoney.compareTo(BigDecimal.ZERO) > 0) { - // 纯微信支付 - paymentFormula.append("微信支付(").append(wxMoney).append(")"); - } else if (yeMoney.compareTo(BigDecimal.ZERO) > 0) { - // 纯余额支付 - paymentFormula.append("余额支付(").append(yeMoney).append(")"); - } - - // 13. 构建返回数据 - Map result = new HashMap<>(); - result.put("id", payBefor.getId()); - result.put("orderId", payBefor.getOrderid()); - result.put("paycode", payBefor.getPaycode()); - result.put("allmoney", originalAmount); // 原始总金额(固定不变,这是您最初存储的金额) - result.put("finalAmount", actualAmount); // 实际应付金额(基于allmoney计算得出) - result.put("wxmoney", wxMoney); // 微信支付金额 - result.put("status", payBefor.getStatus()); - result.put("oid", payBefor.getOid()); - result.put("yemoney", yeMoney); // 余额支付金额 - result.put("membermoney", memberMoney); // 会员优惠金额(固定不变) - result.put("shopmoney", shopMoney); // 购物金抵扣金额(固定不变) - result.put("servicemoney", serviceMoney); // 服务金抵扣金额(固定不变) - result.put("couponmoney", couponMoney); // 优惠券金额(实时计算) - result.put("mtmoney", mtMoney); // 美团优惠金额(实时计算) - result.put("type", payBefor.getType()); - result.put("paytype", paytype); - result.put("usersBalance", user.getBalance()); - result.put("couponId", couponId); - result.put("mtcode", mtcode); - result.put("servicetype", payBefor.getServicetype()); - result.put("paymentFormula", paymentFormula.toString()); // 支付公式 - -// // 添加计算明细,方便前端理解金额构成 -// Map calculationDetail = new HashMap<>(); -// calculationDetail.put("originalAmount", originalAmount); -// calculationDetail.put("memberDiscount", memberMoney); -// calculationDetail.put("serviceDiscount", serviceMoney); -// calculationDetail.put("shopDiscount", shopMoney); -// calculationDetail.put("couponDiscount", couponMoney); -// calculationDetail.put("mtDiscount", mtMoney); -// calculationDetail.put("finalAmount", actualAmount); -// result.put("calculationDetail", calculationDetail); - - return AppletControllerUtil.appletSuccess(result); - - } catch (Exception e) { - logger.error("查询预支付记录失败:", e); - return AppletControllerUtil.appletError("查询预支付记录失败:" + e.getMessage()); - } - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/CoursorUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/CoursorUtil.java index 90f9b8b..49dae79 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/CoursorUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/CoursorUtil.java @@ -1,23 +1,32 @@ package com.ruoyi.system.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.ControllerUtil.AppletControllerUtil; import com.ruoyi.system.ControllerUtil.WechatPayUtil; +import com.ruoyi.system.ControllerUtil.WorkerCommissionUtil; import com.ruoyi.system.domain.ServiceGoods; import com.ruoyi.system.domain.GoodsOrderCursor; +import com.ruoyi.system.domain.Order; +import com.ruoyi.system.domain.SiteConfig; import com.ruoyi.system.service.IServiceGoodsService; import com.ruoyi.system.service.IGoodsOrderCursorService; +import com.ruoyi.system.service.IOrderService; +import com.ruoyi.system.service.ISiteConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -36,6 +45,14 @@ public class CoursorUtil extends BaseController { @Autowired private IGoodsOrderCursorService goodsOrderCursorService; + @Autowired + private IOrderService orderService; + + @Autowired + private ISiteConfigService siteConfigService; + + + // /** // * 获取服务商品详细信息 // * @@ -94,7 +111,30 @@ public class CoursorUtil extends BaseController { return AppletControllerUtil.appletError("查询游标信息失败:" + e.getMessage()); } } - + + + + + /** + * 获取订单游标信息 + * + * @param id 游标ID + * @param request HTTP请求对象 + * @return 游标详细信息 + */ + @GetMapping(value = "/api/cursor/rCommission/info/{id}") + public AjaxResult getOrderCursorInfo2222(@PathVariable("id") long id, HttpServletRequest request) { + try { + JSONObject commissionResult = WorkerCommissionUtil.calculateCompleteWorkerCommission(id); + return AppletControllerUtil.appletSuccess(commissionResult); + + } catch (Exception e) { + return AppletControllerUtil.appletError("查询游标信息失败:" + e.getMessage()); + } + } + + + /** * 创建订单游标 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/GoodsOrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/GoodsOrderController.java index 38004df..33b54d7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/GoodsOrderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/GoodsOrderController.java @@ -1,12 +1,15 @@ package com.ruoyi.system.controller; +import java.util.Date; import java.util.List; +import java.util.Objects; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.system.ControllerUtil.OrderUtil; import com.ruoyi.system.domain.*; -import com.ruoyi.system.service.IServiceGoodsService; -import com.ruoyi.system.service.IUserAddressService; -import com.ruoyi.system.service.IUsersService; +import com.ruoyi.system.service.*; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -21,7 +24,6 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.system.service.IGoodsOrderService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -43,6 +45,10 @@ public class GoodsOrderController extends BaseController private IUsersService usersService; @Autowired private IUserAddressService userAddressService; + @Autowired + private ISiteDeliveryService siteDeliveryService; + + /** * 查询商品订单列表 */ @@ -127,6 +133,17 @@ public class GoodsOrderController extends BaseController @PutMapping public AjaxResult edit(@RequestBody GoodsOrder goodsOrder) { + GoodsOrder goodsOrderdata=goodsOrderService.selectGoodsOrderById(goodsOrder.getId()); + if (goodsOrderdata.getStatus()==2L&&goodsOrder.getStatus()==3L){ + SiteDelivery siteDelivery=siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId()); + if (siteDelivery!=null){ + JSONObject jsonObject= new JSONObject(); + jsonObject.put("wlgs",siteDelivery.getTitle()); + jsonObject.put("wldh",goodsOrder.getDeliveryNum()); + OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单已发货","2",jsonObject,2L); + } + + } return toAjax(goodsOrderService.updateGoodsOrder(goodsOrder)); } @@ -140,4 +157,140 @@ public class GoodsOrderController extends BaseController { return toAjax(goodsOrderService.deleteGoodsOrderByIds(ids)); } + + /** + * 处理售后申请 + */ + @PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')") + @Log(title = "售后申请处理", businessType = BusinessType.UPDATE) + @PostMapping("/processAfterSale") + public AjaxResult processAfterSale(@RequestBody JSONObject params) + { + try { + java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Long id = params.getLong("id"); + String action = params.getString("action"); + + if (id == null || action == null) { + return error("参数错误"); + } + + GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(id); + if (goodsOrder == null) { + return error("订单不存在"); + } + String reamk=params.get("reamk").toString() ; + if (reamk == null) { + reamk="测试数据"; + } + // 检查当前状态是否为申请状态或平台收货状态 + if (goodsOrder.getReturnstatus() == null || + (goodsOrder.getReturnstatus() != 1 && goodsOrder.getReturnstatus() != 4)) { + return error("当前订单状态不允许此操作"); + } + + JSONArray returnLogistics = null; + if (goodsOrder.getReturnjson() != null && !goodsOrder.getReturnjson().isEmpty()) { + try { + returnLogistics = JSONArray.parseArray(goodsOrder.getReturnjson()); + } catch (Exception e) { + returnLogistics = new JSONArray(); + } + } else { + returnLogistics = new JSONArray(); + } + com.alibaba.fastjson2.JSONObject returnJsonObject2 = new com.alibaba.fastjson2.JSONObject(); +// returnJsonObject2.put("title","退款中"); +// returnJsonObject2.put("content","平台将在72小时为您处理,请耐心等待!"); +// goodsOrder.setReturnshow(returnJsonObject2.toJSONString()); + JSONObject returnLogisticsData = new JSONObject(); + returnLogisticsData.put("time", dateFormat.format(new Date())); + returnLogisticsData.put("desc", returnLogistics.size() + 1); + String logMessage = ""; + String content = ""; + Long newStatus = null; + + if ("reject".equals(action)) { + // 驳回申请 + newStatus = 6L; + logMessage = "拒绝退款"; + returnJsonObject2.put("title","拒绝退款"); + returnJsonObject2.put("content","拒绝原因"+reamk); + } else if ("approve".equals(action)) { + // 同意申请 + if (goodsOrder.getReturntype() != null) { + if (goodsOrder.getReturntype() == 1) { + // 仅退款 + newStatus = 2L; + logMessage = "同意退款"; + content="商家已同意申请,72小时内完成您的退款操作"; + returnJsonObject2.put("title","退款成功"); + returnJsonObject2.put("content","平台以退款"+reamk); + } else if (goodsOrder.getReturntype() == 2) { + // 退货退款 + newStatus = 3L; + logMessage = "商品寄回"; + returnJsonObject2.put("title","请寄回物品"); + returnJsonObject2.put("content","平台将在收到货物72小时为您处理,请耐心等待!"); + } else { + return error("售后类型错误"); + } + } else { + return error("售后类型未设置"); + } + } else if ("reject_refund".equals(action)) { + // 驳回退款(平台收货后) + if (goodsOrder.getReturnstatus() != 4) { + return error("当前状态不允许此操作"); + } + newStatus = 6L; + logMessage = "驳回退款"; + returnJsonObject2.put("title","拒绝退款"); + returnJsonObject2.put("content","拒绝原因"+reamk); + } else if ("approve_refund".equals(action)) { + // 同意退款(平台收货后) + if (goodsOrder.getReturnstatus() != 4) { + return error("当前状态不允许此操作"); + } + newStatus = 5L; + logMessage = "同意退款"; + returnJsonObject2.put("title","退款成功"); + returnJsonObject2.put("content","平台以退款"+reamk); + } else { + return error("操作类型错误"); + } + returnLogisticsData.put("title", logMessage); + returnLogistics.add(returnLogisticsData); + goodsOrder.setReturnjson(returnLogistics.toJSONString()); + + // 如果是同意退款,设置退款完成时间 + if ("approve_refund".equals(action)) { + goodsOrder.setReturnfinshtime(new Date()); + } + goodsOrder.setReturnshow(returnJsonObject2.toJSONString()); + // 更新订单状态 + goodsOrder.setReturnstatus(newStatus); + int result = goodsOrderService.updateGoodsOrder(goodsOrder); + + if (result > 0) { + // 添加操作日志 + OrderUtil.addgoodsorderlog( + goodsOrder.getId(), + goodsOrder.getOrderId(), + logMessage, + "3", + new JSONObject(), + 2L + ); + + return success("操作成功"); + } else { + return error("操作失败"); + } + + } catch (Exception e) { + logger.error("处理售后申请失败", e); + return error("操作失败:" + e.getMessage()); + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java index 14a89a0..938048e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java @@ -10,6 +10,7 @@ import com.ruoyi.system.ControllerUtil.GenerateCustomCode; import com.ruoyi.system.ControllerUtil.OrderUtil; import com.ruoyi.system.ControllerUtil.WXsendMsgUtil; import com.ruoyi.system.ControllerUtil.WechatPayUtil; +import com.ruoyi.system.ControllerUtil.WechatPayV3Util; import com.ruoyi.system.domain.*; import com.ruoyi.system.service.*; import org.slf4j.Logger; @@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Calendar; @@ -99,6 +101,9 @@ public class PayNotifyController extends BaseController { @Autowired private IUserUseSecondaryCardService userUseSecondaryCardService; + @Autowired + private WechatPayV3Util wechatPayV3Util; + /** * 商品支付回调接口 @@ -377,8 +382,7 @@ public class PayNotifyController extends BaseController { UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(outTradeNo); if (usersPayBefor!=null){ - usersPayBefor.setStatus(2L); - usersPayBefor.setPaytype(4L); + usersPayBefor.setStatus(2L); usersPayBefor.setPaytype(4L); usersPayBefor.setPaytime(new Date()); usersPayBefor.setPaycode(transactionId); usersPayBeforService.updateUsersPayBefor(usersPayBefor); @@ -1652,4 +1656,106 @@ public class PayNotifyController extends BaseController { return buildFailResponse("次卡支付回调处理异常"); } } + + /** + * 次卡退款回调接口 + * @param request HTTP请求对象 + * @return XML格式响应给微信服务器 + * 逻辑: + * 1. 验证退款回调签名 + * 2. 查询次卡使用记录 + * 3. 更新退款状态 + * 4. 处理退款成功后的业务逻辑 + */ + @PostMapping("/api/secondary/card/refund/notify") + public String secondaryCardRefundNotify(HttpServletRequest request) { + try { + logger.info("收到次卡退款回调通知,开始处理..."); + + // 1. 使用WechatPayUtil处理退款回调(暂时使用支付回调方法,后续需要实现专门的退款回调处理) + Map notifyResult = wechatPayUtil.handlePayNotify(request); + + // 2. 检查处理结果 + boolean success = (Boolean) notifyResult.get("success"); + String message = (String) notifyResult.get("message"); + + if (!success) { + logger.error("次卡退款回调处理失败:{}", message); + return buildFailResponse("次卡退款回调处理失败"); + } + + // 3. 获取退款信息(暂时使用支付信息结构,后续需要根据实际退款回调结构调整) + Map refundInfo = (Map) notifyResult.get("paymentInfo"); + String outTradeNo = (String) refundInfo.get("outTradeNo"); // 原订单号 + String transactionId = (String) refundInfo.get("transactionId"); // 交易号 + String totalFee = (String) refundInfo.get("totalFee"); // 金额 + + // 4. 查询次卡使用记录 + UserUseSecondaryCard useCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(outTradeNo); + if (useCard == null) { + logger.error("未找到次卡使用记录,订单号:{}", outTradeNo); + return buildFailResponse("未找到次卡使用记录"); + } + + // 5. 更新退款状态(暂时设置为退款成功状态) + useCard.setStatus(3L); // 3=退款成功状态 + useCard.setRemark("退款成功,退款时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + + int updateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(useCard); + if (updateResult > 0) { + logger.info("次卡退款成功,订单号:{},退款金额:{}", outTradeNo, useCard.getPaymoney()); + + // 6. 处理退款成功后的业务逻辑 + handleSecondaryCardRefundSuccess(useCard, refundInfo); + + return buildSuccessResponse(); + } else { + logger.error("更新次卡退款状态失败,订单号:{}", outTradeNo); + return buildFailResponse("更新退款状态失败"); + } + + } catch (Exception e) { + logger.error("次卡退款回调处理异常:", e); + return buildFailResponse("次卡退款回调处理异常"); + } + } + + /** + * 处理次卡退款成功后的业务逻辑 + * @param useCard 次卡使用记录 + * @param refundInfo 退款信息 + */ + private void handleSecondaryCardRefundSuccess(UserUseSecondaryCard useCard, Map refundInfo) { + try { + // 1. 记录退款成功日志 + logger.info("次卡退款成功,用户ID:{},订单号:{},退款金额:{}", + useCard.getUid(), useCard.getOrderid(), useCard.getPaymoney()); + + // 2. 获取用户信息 + Users user = usersService.selectUsersById(useCard.getUid()); + if (user != null) { + // 3. 发送退款成功通知(可选) + // WXsendMsgUtil.sendRefundSuccess(user.getOpenid(), useCard, refundInfo); + + // 4. 记录退款流水(可选) + PayMoneyLog payMoneyLog = new PayMoneyLog(); + payMoneyLog.setOid(useCard.getId()); + payMoneyLog.setOrderId(useCard.getOrderid()); + payMoneyLog.setUid(useCard.getUid()); + payMoneyLog.setUname(user.getName()); + payMoneyLog.setPrice(useCard.getPaymoney().negate()); // 负数表示退款 + payMoneyLog.setMark("次卡退款"); + payMoneyLog.setPayTime(new Date()); + payMoneyLogService.insertPayMoneyLog(payMoneyLog); + + logger.info("次卡退款流水记录已保存,用户:{},金额:{}", user.getName(), useCard.getPaymoney()); + } + + // 5. 其他业务逻辑(根据需求补充) + // TODO: 补充具体的业务逻辑 + + } catch (Exception e) { + logger.error("处理次卡退款成功业务逻辑异常:", e); + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/QuoteTypeController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/QuoteTypeController.java index 7969086..1b29a3e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/QuoteTypeController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/QuoteTypeController.java @@ -124,7 +124,19 @@ public class QuoteTypeController extends BaseController public AjaxResult goodsDataList(@PathVariable("type") int type) { ServiceGoods serviceGoods=new ServiceGoods(); - serviceGoods.setType(type); + if(type==3){ + serviceGoods.setIsfixed(1); + } + if(type==4){ + serviceGoods.setIsgroup(1); + } + if(type==1){ + serviceGoods.setType(1); + } + if(type==2){ + serviceGoods.setType(2); + } + //serviceGoods.setType(type); return success(serviceGoodsService.selectServiceGoodsList(serviceGoods)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMarginLogController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMarginLogController.java index c607ed7..746d3f8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMarginLogController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMarginLogController.java @@ -1,6 +1,7 @@ package com.ruoyi.system.controller; import java.util.List; +import java.math.BigDecimal; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -17,7 +18,9 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.domain.WorkerMarginLog; +import com.ruoyi.system.domain.Users; import com.ruoyi.system.service.IWorkerMarginLogService; +import com.ruoyi.system.service.IUsersService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -33,6 +36,9 @@ public class WorkerMarginLogController extends BaseController { @Autowired private IWorkerMarginLogService workerMarginLogService; + + @Autowired + private IUsersService usersService; /** * 查询师傅质保金明细列表 @@ -77,7 +83,33 @@ public class WorkerMarginLogController extends BaseController @PostMapping public AjaxResult add(@RequestBody WorkerMarginLog workerMarginLog) { - return toAjax(workerMarginLogService.insertWorkerMarginLog(workerMarginLog)); + try { + // 1. 插入质保金明细记录 + int result = workerMarginLogService.insertWorkerMarginLog(workerMarginLog); + + if (result > 0) { + // 2. 更新师傅的质保金余额 + Users user = usersService.selectUsersById(workerMarginLog.getUid()); + if (user != null) { + // 获取当前质保金余额 + BigDecimal currentMargin = user.getMargin() != null ? user.getMargin() : BigDecimal.ZERO; + // 计算新的质保金余额(增加变动金额) + BigDecimal newMargin = currentMargin.add(workerMarginLog.getPrice()); + + // 更新师傅的质保金余额 + user.setMargin(newMargin); + usersService.updateUsers(user); + + return success("质保金变动成功"); + } else { + return error("师傅信息不存在"); + } + } else { + return error("质保金明细记录插入失败"); + } + } catch (Exception e) { + return error("质保金变动失败: " + e.getMessage()); + } } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/json.txt b/ruoyi-system/src/main/java/com/ruoyi/system/controller/json.txt index b8230d6..ff23ec2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/json.txt +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/json.txt @@ -1,92 +1,21 @@ - // 个人中心 - public function index(Request $request) +// 师傅当前进行的单子 + public function current_order() { - $param = $request->post(); - $limit = isset($param['limit']) && $param['limit'] ? $param['limit'] : env('PAGE_LIMIT'); - - if($this->user_info['level']) - { - $this->user_info['level_info'] = WorkerLevel::select('id','image')->find($this->user_info['level']); - } - // 个人基本信息 - $data['user'] = $this->user_info; - // 质保金 - if(!$this->user_info['margin']){ - $data['user']['margin'] = 0; - } - // 累计佣金 - if(!$this->user_info['total_comm']) - { - $data['user']['total_comm'] = 0; - } - // 佣金 - if(!$this->user_info['commission']) - { - $data['user']['commission'] = 0; - } - // 师傅技能 - if($this->user_info['skill_ids']) - { - $skill_ids = array_filter(json_decode($this->user_info['skill_ids'],true)); - $this->user_info['skill_arr'] = skill::whereIn('id',$skill_ids)->select('id','title')->get(); - } - // 师傅服务地区 - if($this->user_info['service_city_ids']) - { - $this->user_info['service_city_arr'] = DiyCity::whereIn('id',json_decode($this->user_info['service_city_ids'],true))->select('id','title')->get(); - } - // 等级信息 - if($this->user_info['level']) - { - $level = WorkerLevel::select('image')->find($this->user_info['level']); - if($level) $data['user']['level_img'] = $level['image']; - } - // 是否禁止接单 - if(strtotime($this->user_info['prohibit_time']) < time() && strtotime($this->user_info['prohibit_time']) + $this->user_info['prohibit_time_num']*3600 > time()){ - // 禁止剩余是啊金 - $residue_time = strtotime($this->user_info['prohibit_time']) + $this->user_info['prohibit_time_num']*3600 - time(); - $hours = intval($residue_time / 3600); - $minutes = intval(($residue_time % 3600) / 60); - $seconds = $residue_time % 60; - $str = ''; - if($hours > 0) $str .= $hours.'小时'; - if($minutes > 0) $str .= $minutes.'分钟'; - if($seconds > 0) $str .= $seconds.'秒'; - - $this->user_info['prohibit'] = '因违反平台规定,'.$this->user_info['prohibit_time_num'].'小时内禁止接单,剩余'.$str; - } + $info = ['oid'=>null,'order_id'=>null]; + // $info = Log::select('oid','order_id')->where(['worker_id'=>$this->user_info['id']])->whereIn('type',[4,5,6])->where('is_pause','<>',2)->first(); + // 主订单 待服务的订单 + $order_info = Order::select('id','order_id')->where(['worker_id'=>$this->user_info['id'],'status'=>2])->orderBy('id','asc')->get(); - // 我的服务订单 - // $oids = Log::where(['worker_id'=>$this->user_info['id'],'type'=>8])->pluck('oid')->toArray(); - $oids = Log::where(['worker_id'=>$this->user_info['id']])->pluck('oid')->toArray(); - - // 我的评价 - if($oids){ - $model = new Comment(); - if(isset($param['type']) && $param['type']) - { - $model = $model->where(['num_type'=>$param['type']]); + $LogModel = new Log(); + foreach($order_info as $val){ + $info = $LogModel->where(['worker_id'=>$this->user_info['id'],'oid'=>$val['id']])->whereNull('give_up')->whereIn('type',[4,5])->whereNull('is_pause')->first(); + // 停止录音 + $info_tingzhi = $LogModel->where(['worker_id'=>$this->user_info['id'],'oid'=>$val['id']])->whereNull('give_up')->where('type','>',5)->whereNull('is_pause')->first(); + if($info_tingzhi){ + continue; } - $data['data'] = $model->whereIn('oid',$oids) - ->with(['user'=>function($query){ - $query->select('id','name','avatar'); - }]) - ->select('id','uid','images','content','num','created_at') - ->paginate($limit); - // 总评分 - $total_num = 0; - foreach($data['data'] as &$val) - { - // 时间转换 - $val['time'] = $this->mdate($val['created_at']); - $total_num += $val['num']; - } - // 评价数量 - $data['comment']['one'] = Comment::where(['num_type'=>1])->whereIn('oid',$oids)->count(); - $data['comment']['two'] = Comment::where(['num_type'=>2])->whereIn('oid',$oids)->count(); - $data['comment']['three'] = Comment::where(['num_type'=>3])->whereIn('oid',$oids)->count(); - if(count($data['data']) < 1) $data['comment']['total'] = 0; - else $data['comment']['total'] = round($total_num/count($data['data']),1); + if($info) break; } - return $this->success($data); - } \ No newline at end of file + + return $this->success($info); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java index cdec440..74d58f0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java @@ -10,13 +10,16 @@ import com.ruoyi.system.domain.*; import com.ruoyi.system.service.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.ruoyi.system.utils.FFmpegUtilsSimple; +import com.ruoyi.system.utils.QiniuUploadUtil; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.math.BigDecimal; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -46,6 +49,7 @@ public class AppletControllerUtil { private static final IUserAddressService userAddressService = SpringUtils.getBean(IUserAddressService.class); private static final IOrderCommentService orderCommentService = SpringUtils.getBean(IOrderCommentService.class); private static final IOrderLogService orderLogService = SpringUtils.getBean(IOrderLogService.class); + private static final IOrderSoundLogService orderSoundLogService = SpringUtils.getBean(IOrderSoundLogService.class); @@ -106,7 +110,7 @@ public class AppletControllerUtil { */ public static AjaxResult appletdengluWarning(String message) { AjaxResult result = new AjaxResult(); - result.put("code", 422); + result.put("code", 332); result.put("msg", message); result.put("data", new ArrayList<>()); return result; @@ -173,7 +177,7 @@ public class AppletControllerUtil { */ public static AjaxResult appletError(String message) { AjaxResult result = new AjaxResult(); - result.put("code", 500); + result.put("code", 422); result.put("msg", message); result.put("data", new ArrayList<>()); return result; @@ -729,6 +733,86 @@ public class AppletControllerUtil { return imageList; } + + /** + * 构建售后返修列表数据 + * + * @param reworkList 售后返修列表 + * @return 构建后的列表数据 + */ + public static List> buildReworkList(List reworkList) { + List> resultList = new ArrayList<>(); + + if (reworkList == null || reworkList.isEmpty()) { + return resultList; + } + + for (OrderRework rework : reworkList) { + Map reworkMap = new HashMap<>(); + + // 基本信息 + reworkMap.put("id", rework.getId()); + reworkMap.put("uid", rework.getUid()); + reworkMap.put("uname", rework.getUname()); + reworkMap.put("oid", rework.getOid()); + reworkMap.put("order_id", rework.getOrderId()); + reworkMap.put("phone", rework.getPhone()); + reworkMap.put("mark", rework.getMark()); + reworkMap.put("status", rework.getStatus()); + reworkMap.put("status_text", getReworkStatusText(rework.getStatus().longValue())); + reworkMap.put("created_at", rework.getCreatedAt()); + reworkMap.put("updated_at", rework.getUpdatedAt()); + + // 关联订单信息 + if (rework.getOrderId() != null) { + try { + Order order = orderService.selectOrderByOrderId(rework.getOrderId()); + if (order != null) { + Map orderInfo = new HashMap<>(); + orderInfo.put("id", order.getId()); + orderInfo.put("orderId", order.getOrderId()); + orderInfo.put("totalPrice", order.getTotalPrice()); + orderInfo.put("status", order.getStatus()); + orderInfo.put("statusText", getOrderStatusText(order.getStatus())); + orderInfo.put("createdAt", order.getCreatedAt()); + reworkMap.put("orderInfo", orderInfo); + } + } catch (Exception e) { + + } + } + + resultList.add(reworkMap); + } + + return resultList; + } + + /** + * 获取售后返修状态文本 + * + * @param status 状态值 + * @return 状态文本 + */ + public static String getReworkStatusText(Long status) { + if (status == null) { + return "未知状态"; + } + + switch (status.intValue()) { + case 0: + return "待处理"; + case 1: + return "已处理"; + case 2: + return "已拒绝"; + case 3: + return "已完成"; + default: + return "未知状态"; + } + } + /** * 解析字符串为普通字符串列表 * @@ -1005,7 +1089,7 @@ public class AppletControllerUtil { * - 状态信息:启用状态、注册时间等 * - 默认值:密码、角色等系统字段 */ - private static Users createNewWechatUser(String openid, Map wechatUserInfo) { + public static Users createNewWechatUser(String openid, Map wechatUserInfo) { Users newUser = new Users(); // 基础信息 @@ -1046,7 +1130,7 @@ public class AppletControllerUtil { * - 更新登录时间 * - 保持原有的系统信息不变 */ - private static Users updateExistingWechatUser(Users existingUser, Map wechatUserInfo) { + public static Users updateExistingWechatUser(Users existingUser, Map wechatUserInfo) { // 更新微信相关信息 existingUser.setNickname((String) wechatUserInfo.get("nickname")); existingUser.setAvatar((String) wechatUserInfo.get("avatar")); @@ -1070,7 +1154,7 @@ public class AppletControllerUtil { * - 状态信息:用户状态、注册时间等 * - 过滤敏感信息:密码等 */ - private static Map buildUserResponseInfo(Users userRecord, Map wechatUserInfo) { + public static Map buildUserResponseInfo(Users userRecord, Map wechatUserInfo) { Map userInfo = new HashMap<>(); // 基础用户信息 @@ -2596,6 +2680,197 @@ public class AppletControllerUtil { return fullUrl; } + + + + + + /** + * 创建FFmpeg输入列表文件 + * + * @param filePaths 文件路径列表 + * @return 输入列表文件路径 + * @throws IOException IO异常 + */ + public static String createInputListFile(List filePaths) throws IOException { + String inputListFile = Files.createTempFile("input_list", ".txt").toString(); + StringBuilder content = new StringBuilder(); + + for (String filePath : filePaths) { + content.append("file '").append(filePath.replace("'", "'\\''")).append("'").append(System.lineSeparator()); + } + + Files.write(Paths.get(inputListFile), content.toString().getBytes()); + return inputListFile; + } + + /** + * 执行FFmpeg合并命令 + * + * @param inputListFile 输入列表文件路径 + * @param outputPath 输出文件路径 + * @return 是否成功 + */ + public static boolean executeFFmpegMerge(String inputListFile, String outputPath) { + try { + + + // 检查输入文件是否存在 + File inputFile = new File(inputListFile); + if (!inputFile.exists()) { + //logger.error("输入列表文件不存在: {}", inputListFile); + return false; + } + + // 检查输出目录是否存在 + File outputFile = new File(outputPath); + File outputDir = outputFile.getParentFile(); + if (!outputDir.exists()) { + outputDir.mkdirs(); + } + + // 读取输入文件列表 + List inputFiles = java.nio.file.Files.readAllLines(java.nio.file.Paths.get(inputListFile)) + .stream() + .filter(line -> line.startsWith("file '")) + .map(line -> line.substring(6, line.length() - 1)) // 提取文件路径 + .collect(java.util.stream.Collectors.toList()); + + // 使用FFmpegUtilsSimple进行合并 + boolean success = FFmpegUtilsSimple.mergeAudioFiles(inputFiles, outputPath); + + if (success) { + // logger.info("FFmpeg合并成功,输出文件: {}", outputPath); + return true; + } else { + // logger.error("FFmpeg合并失败"); + return false; + } + + } catch (Exception e) { + // logger.error("执行FFmpeg命令异常", e); + return false; + } + } + + + + /** + * 上传文件到七牛云 + * + * @param localFilePath 本地文件路径 + * @param qiniuPath 七牛云存储路径 + * @return 文件访问URL + * @throws IOException IO异常 + */ + public static String uploadToQiniu(String localFilePath, String qiniuPath) throws IOException { + try (FileInputStream fileInputStream = new FileInputStream(localFilePath)) { + return QiniuUploadUtil.uploadStream(fileInputStream, qiniuPath); + } + } + + /** + * 清理合并后的资源 + * + * @param soundLogs 录音日志列表 + * @param filePaths 文件路径列表 + * @param tempOutputPath 临时输出文件路径 + * @param inputListFile 输入列表文件路径 + */ + public void cleanupAfterMerge(List soundLogs, List filePaths, + String tempOutputPath, String inputListFile) { + try { + // 删除录音日志记录 + for (OrderSoundLog soundLog : soundLogs) { + orderSoundLogService.deleteOrderSoundLogById(soundLog.getId()); + } + + // 删除原始文件 + for (String filePath : filePaths) { + File file = new File(filePath); + if (file.exists()) { + file.delete(); + } + } + + // 删除文件夹(如果为空) + if (!filePaths.isEmpty()) { + String firstFilePath = filePaths.get(0); + File parentDir = new File(firstFilePath).getParentFile(); + if (parentDir != null && parentDir.exists() && parentDir.list().length == 0) { + parentDir.delete(); + } + } + + // 清理临时文件 + cleanupTempFiles(tempOutputPath, inputListFile); + + } catch (Exception e) { + // logger.error("清理资源异常", e); + } + } + + /** + * 清理临时文件 + * + * @param tempOutputPath 临时输出文件路径 + * @param inputListFile 输入列表文件路径 + */ + public static void cleanupTempFiles(String tempOutputPath, String inputListFile) { + try { + // 删除临时输出文件 + if (tempOutputPath != null) { + File tempFile = new File(tempOutputPath); + if (tempFile.exists()) { + tempFile.delete(); + } + } + + // 删除输入列表文件 + if (inputListFile != null) { + File inputFile = new File(inputListFile); + if (inputFile.exists()) { + inputFile.delete(); + } + } + + } catch (Exception e) { + // logger.error("清理临时文件异常", e); + } + } + + + /** + * 去除HTML标签 + * + * @param html HTML内容 + * @return 去除标签后的纯文本 + */ + public static String stripHtmlTags(String html) { + if (html == null || html.trim().isEmpty()) { + return ""; + } + + // 简单的HTML标签去除逻辑 + String result = html; + + // 去除常见的HTML标签 + result = result.replaceAll("<[^>]*>", ""); + + // 去除HTML实体 + result = result.replaceAll(" ", " "); + result = result.replaceAll("&", "&"); + result = result.replaceAll("<", "<"); + result = result.replaceAll(">", ">"); + result = result.replaceAll(""", "\""); + result = result.replaceAll("'", "'"); + + // 去除多余的空格和换行 + result = result.replaceAll("\\s+", " "); + result = result.trim(); + + return result; + } /** * 构建时间段列表 * @@ -3341,6 +3616,8 @@ public class AppletControllerUtil { data.put("margin", goods.getMargin() != null ? goods.getMargin().toString() : null); data.put("skill_ids", goods.getSkillIds()); data.put("servicetype", goods.getServicetype()); + data.put("isforservice", goods.getIsforservice()); + data.put("forserviceid", goods.getForserviceid()); // 处理图片数组 data.put("imgs", parseImagesStringToArray(goods.getImgs())); // 时间字段 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java index 2d57c8e..6a932f2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java @@ -88,7 +88,7 @@ public class CartOrderUtil { } } order.setTotalPrice(itemPrice); - order.setGoodPrice(serviceGoods.getPrice()); + order.setGoodPrice(BigDecimal.ZERO); order.setServicePrice(BigDecimal.ZERO); order.setPayPrice(itemPrice); order.setStatus(1L); @@ -98,6 +98,7 @@ public class CartOrderUtil { order.setIsPause(1); order.setMainOrderId(maincorid); order.setDeduction(BigDecimal.ZERO); + order.setBigtype(serviceGoods.getServicetype()); int insertResult = orderService.insertOrder(order); if (insertResult <= 0) { result.put("success", false); @@ -141,7 +142,7 @@ public class CartOrderUtil { * @param goodsOrderService 商品订单service * @return 下单结果Map */ - public static Map createGoodsOrderFromOnes(Users user, String sku,int num, String reamk,ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid) { + public static Map createGoodsOrderFromOnes(Users user, String sku,int num, String reamk,ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid,Long isself) { Map result = new HashMap<>(); try { BigDecimal itemPrice=BigDecimal.ZERO; @@ -173,13 +174,16 @@ public class CartOrderUtil { goodsOrder.setProductName(serviceGoods.getTitle()); goodsOrder.setNum((long) num); goodsOrder.setSku(sku); + goodsOrder.setIsself(isself); goodsOrder.setIsforservice(serviceGoods.getIsforservice()); goodsOrder.setForserviceid(serviceGoods.getForserviceid()); goodsOrder.setMark(reamk); - goodsOrder.setAddressId(userAddress.getId()); - goodsOrder.setName(userAddress.getName()); - goodsOrder.setPhone(userAddress.getPhone()); - goodsOrder.setAddress(userAddress.getAddressInfo()); + if (isself!=1){ + goodsOrder.setAddressId(userAddress.getId()); + goodsOrder.setName(userAddress.getName()); + goodsOrder.setPhone(userAddress.getPhone()); + goodsOrder.setAddress(userAddress.getAddressInfo()); + } goodsOrder.setTotalPrice(itemPrice); goodsOrder.setGoodPrice(serviceGoods.getPrice()); goodsOrder.setPayPrice(itemPrice); @@ -195,6 +199,11 @@ public class CartOrderUtil { result.put("orderId", goodsOrder.getOrderId()); result.put("productName", serviceGoods.getTitle()); result.put("allprice", itemPrice.toString()); + com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); + jsonObject.put("name", "订单创建成功"); + //添加记录日志Long oid,String orderId,String title,String type,String content,Long ordertype + OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L); + return result; } catch (Exception e) { logger.error("商品类购物车下单异常:", e); @@ -212,7 +221,7 @@ public class CartOrderUtil { * @param goodsOrderService 商品订单service * @return 下单结果Map */ - public static Map createGoodsOrderFromCart(Users user, GoodsCart cart, ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid) { + public static Map createGoodsOrderFromCart(Users user, GoodsCart cart, ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid,Long isself) { Map result = new HashMap<>(); try { BigDecimal itemPrice=BigDecimal.ZERO; @@ -247,6 +256,7 @@ public class CartOrderUtil { goodsOrder.setIsforservice(serviceGoods.getIsforservice()); goodsOrder.setForserviceid(serviceGoods.getForserviceid()); goodsOrder.setMark(cart.getReamk()); + goodsOrder.setIsself(isself); goodsOrder.setAddressId(userAddress.getId()); goodsOrder.setName(userAddress.getName()); goodsOrder.setPhone(userAddress.getPhone()); @@ -267,8 +277,10 @@ public class CartOrderUtil { result.put("productName", serviceGoods.getTitle()); result.put("allprice", itemPrice.toString()); PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); + com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); + jsonObject.put("name", "订单创建成功"); + OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L); String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, goodsOrder.getOrderId(), null, goodsOrder.getProductId(), 11L, goodsOrder.getSku(), null, null, null, null,2L, null, null); - return result; } catch (Exception e) { logger.error("商品类购物车下单异常:", e); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java index 0563b10..3c187fd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java @@ -629,7 +629,7 @@ public class OrderUtil { System.out.println("=== prepayCallback 方法开始 ==="); System.out.println("输入参数 - payBefor: " + (payBefor != null ? payBefor.toString() : "null")); System.out.println("输入参数 - user: " + (user != null ? user.toString() : "null")); - + if (payBefor == null || user == null) { System.out.println("参数验证失败 - payBefor或user为空"); return null; @@ -640,7 +640,21 @@ public class OrderUtil { IOrderService orderService = SpringUtils.getBean(IOrderService.class); - // 拼团 + // 单个商品支付 + if (type == 5){ + GoodsOrder gorder = new GoodsOrder(); + gorder.setMainOrderId(payBefor.getOrderid()); + List gorders = goodsOrderService.selectGoodsOrderList(gorder); + if (gorders != null && !gorders.isEmpty()){ + for (GoodsOrder g: gorders){ + g.setStatus(2L); + goodsOrderService.updateGoodsOrder(g); + } + } + updateInventoryAndSales(gorder.getOrderId(), 2); + return payBefor.getOrderid(); + + } if (type == 6){ GoodsOrder gorder = new GoodsOrder(); gorder.setMainOrderId(payBefor.getOrderid()); @@ -717,7 +731,7 @@ public class OrderUtil { if (order != null) { //更新最新的一条日志信息 - OrderLog orderLog = orderLogService.selectDataTheFirstNew(order.getId()); + OrderLog orderLog = orderLogService.selectOrderLogById(payBefor.getOid()); orderLog.setPayTime(System.currentTimeMillis()/1000); orderLog.setPaid(2L); int updateResult = orderLogService.updateOrderLog(orderLog); @@ -782,8 +796,9 @@ public class OrderUtil { order.setStatus(2L); order.setJsonStatus(2); order.setFirstWorkerId(users.getId()); - order.setIsAccept(1); + // order.setIsAccept(1); order.setWorkerPhone(users.getPhone()); + order.setTotalPrice(userDemandQuotation.getMoney()); order.setWorkerId(users.getId()); int orderUpdateResult = orderService.updateOrder(order); System.out.println("订单更新结果: " + orderUpdateResult); @@ -808,6 +823,7 @@ public class OrderUtil { System.out.println("未找到报价记录,处理失败"); } System.out.println("需求报价订单处理完成,返回order: " + (order != null ? order.getOrderId() : "null")); + updateInventoryAndSales(order.getOrderId(), 1); //dispatchOrderCheck(order); return order; } else { @@ -816,7 +832,8 @@ public class OrderUtil { System.out.println("需求报价订单处理失败,返回null"); return null; } - if (type == 2) { + //次卡购买的回调 + if (type == 12) { System.out.println("处理次卡订单"); IUserUseSecondaryCardService userUseSecondaryCardService = SpringUtils.getBean(IUserUseSecondaryCardService.class); UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(payBefor.getOrderid()); @@ -830,10 +847,45 @@ public class OrderUtil { } return null; } + //秒杀的回调 + if (type == 2) { + Order order = orderService.selectOrderByOrderId(payBefor.getOrderid()); + System.out.println("查询到的订单: " + (order != null ? order.toString() : "null")); + if (order != null) { + System.out.println("添加订单日志"); + OrderLog orderLog = new OrderLog(); + orderLog.setOid(order.getId()); + orderLog.setOrderId(order.getOrderId()); + orderLog.setTitle("订单支付"); + orderLog.setType(new BigDecimal("1.1")); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("name", "订单支付成功,待派单"); + orderLog.setContent(jsonObject.toJSONString()); + int logInsertResult = orderLogService.insertOrderLog(orderLog); + System.out.println("订单日志插入结果: " + logInsertResult); + + System.out.println("更新订单状态为待派单"); + order.setStatus(1L); // 1=待预约 + int orderUpdateResult = orderService.updateOrder(order); + System.out.println("订单状态更新结果: " + orderUpdateResult); + System.out.println("普通订单处理完成,返回order: " + order.getOrderId()); + + //派单效验 + dispatchOrderCheck(order); + //库存及销量变更 + updateInventoryAndSales(order.getOrderId(), 1); + return order; + } else { + System.out.println("未找到订单"); + } + return null; + } if (type == 1) { System.out.println("=== 处理拼团订单 ==="); + String ptorderid= payBefor.getOrderid(); + System.out.println("拼团订单ID: " + ptorderid); //第一步创建订单状态为待成团 Order order = new Order(); @@ -841,7 +893,7 @@ public class OrderUtil { order.setStatus(9L); // 9=待成团 order.setOrderId(ptorderid); order.setUid(payBefor.getUid()); - order.setNum(1L); // 默认1,可根据业务调整 + order.setNum(payBefor.getNum()); // 默认1,可根据业务调整 //order.setProductId(payBefor.getSku() != null ? Long.valueOf(payBefor.getSku()) : null); // 假设sku字段存储商品ID order.setProductId(payBefor.getServiceid()); // 假设sku字段存储商品ID System.out.println("商品ID: " + payBefor.getServiceid()); @@ -963,7 +1015,10 @@ public class OrderUtil { System.out.println("拼团成功,所有订单状态已更新"); } System.out.println("拼团订单处理完成,返回order: " + order.getOrderId()); + //派单效验 dispatchOrderCheck(order); + //库存及销量变更 + updateInventoryAndSales(ptorderid, 1); return order; } else { // 其他类型 System.out.println("=== 处理其他类型订单 ==="); @@ -1091,27 +1146,111 @@ public class OrderUtil { return false; } + /** + * 用户付款后回调中修改订单状态的辅助方法 + * 逻辑:如果用户付款的时候,查询paynum=0(没有可付款的数据), + * 且订单最新状态大于等于6(师傅已完成),那么就修改订单为已完成状态 + * + * @param orderid 订单ID + * @return 剩余可付款数量 + */ public static int ISTOPAYSIZE(String orderid) { - IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class); - IOrderService orderService = SpringUtils.getBean(IOrderService.class); - int count = usersPayBeforService.countByLastOrderIdAndStatus(orderid); - System.out.println("count订单日志: " +count); - if(count <= 0){ + try { + IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class); + IOrderService orderService = SpringUtils.getBean(IOrderService.class); + + // 1. 查询剩余可付款数量 + int paynum = usersPayBeforService.countByLastOrderIdAndStatus(orderid); + System.out.println("订单 " + orderid + " 剩余可付款数量: " + paynum); + + // 2. 查询订单信息 Order order = orderService.selectOrderByOrderId(orderid); - if(order != null){ - OrderLog orderLog = orderLogService.selectDataTheFirstNew(order.getId()); - System.out.println("订单日志: " + (orderLog != null ? orderLog.toString() : "null")); - System.out.println("orderLog.getType()订单日志: " + orderLog.getType()); - if(orderLog.getType().compareTo(new BigDecimal("6")) > 0){ - // 修改订单状态为6 - order.setStatus(6L); - orderService.updateOrder(order); - } + if (order == null) { + System.err.println("未找到订单信息,orderid: " + orderid); + return paynum; } + + // 3. 查询订单最新日志 + OrderLog orderLog = orderLogService.selectDataTheFirstNew(order.getId()); + if (orderLog == null) { + System.err.println("未找到订单最新日志,orderid: " + orderid); + return paynum; + } + + // 4. 判断订单最新状态是否大于等于6(师傅已完成) + BigDecimal latestLogType = orderLog.getType(); + boolean isWorkerCompleted = latestLogType != null && latestLogType.compareTo(new BigDecimal("6")) >= 0; + System.out.println("订单 " + orderid + " 最新日志类型: " + latestLogType + ", 师傅是否已完成: " + isWorkerCompleted); + + // 5. 如果paynum=0且师傅已完成,则修改订单为已完成状态 + if (paynum <= 0 && isWorkerCompleted) { + System.out.println("订单 " + orderid + " 满足完成条件:无剩余付款且师傅已完成,开始修改订单状态"); + + // 修改订单状态为已完成 + order.setStatus(4L); // 4:已完成 + order.setReceiveType(3L); // 3:完成类型 + order.setJsonStatus(9); // 9:已完成 + order.setLogJson("{\"type\":8}"); // 8:完成状态 + + int updateResult = orderService.updateOrder(order); + System.out.println("订单状态更新结果: " + updateResult); + + // 处理师傅佣金 + if (order.getWorkerId() != null) { + Users worker = usersService.selectUsersById(order.getWorkerId()); + if (worker != null) { + JSONObject commissionResult = WorkerCommissionUtil.calculateCompleteWorkerCommission(order.getId()); + // WorkerCommissionUtil.processWorkerCommission(order, worker); + System.out.println("师傅佣金处理完成,师傅ID: " + order.getWorkerId()); + } + } + +// // 处理用户通知(可选) +// if (order.getUid() != null) { +// Users user = usersService.selectUsersById(order.getUid()); +// if (user != null) { +// // 这里可以添加微信通知等逻辑 +// // ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); +// // WXsendMsgUtil.sendWorkerFinishOrder(user.getOpenid(), order, serviceGoods); +// System.out.println("用户通知处理完成,用户ID: " + order.getUid()); +// } +// } + + System.out.println("订单 " + orderid + " 状态修改为已完成"); + } + +// else { +// System.out.println("订单 " + orderid + " 不满足完成条件:剩余付款数量=" + paynum + ", 师傅是否已完成=" + isWorkerCompleted); +// +// // 如果还有剩余付款,但师傅已完成,可以设置为待付款状态 +// if (paynum > 0 && isWorkerCompleted) { +// order.setStatus(6L); // 6:待付款 +// order.setJsonStatus(9); // 9:已完成 +// int updateResult = orderService.updateOrder(order); +// System.out.println("订单状态更新为待付款,更新结果: " + updateResult); +// } +// } + + return paynum; + + } catch (Exception e) { + System.err.println("ISTOPAYSIZE方法执行异常,orderid: " + orderid + ", 错误: " + e.getMessage()); + e.printStackTrace(); + return 0; } - return count; } + public static int addgoodsorderlog(Long oid,String orderId,String title,String type,JSONObject content,Long ordertype) { + OrderLog orderLog = new OrderLog(); + orderLog.setOid(oid); + orderLog.setOrderId(orderId); + orderLog.setTitle( title); + orderLog.setContent(content.toJSONString()); + orderLog.setType(new BigDecimal(type)); + orderLog.setOrdertype(ordertype); + orderLogService.insertOrderLog(orderLog); + return 1; + } /** @@ -1149,7 +1288,7 @@ public class OrderUtil { order.setStatus(1L); order.setFirstWorkerId(users.getId()); - order.setIsAccept(1); + // order.setIsAccept(1); order.setWorkerPhone(users.getPhone()); order.setWorkerId(users.getId()); int orderUpdateResult = orderService.updateOrder(order); @@ -1251,11 +1390,271 @@ public class OrderUtil { return result; } + /** + * 库存及销量变更 + * 根据订单ID更新商品/服务的销量和库存 + * + * @param orderid 订单ID + * @param type 商品类型 1=服务类商品 2=商城类商品 + * @return 处理结果,成功返回true,失败返回false + */ + public static boolean updateInventoryAndSales(String orderid, Integer type) { + try { + // 1. 根据type查询订单数据 + Object order = null; + if (type == 1) { + // 服务类商品,调用IOrderService查询订单数据 + IOrderService orderService = SpringUtils.getBean(IOrderService.class); + order = orderService.selectOrderByOrderId(orderid); + } else if (type == 2) { + // 商城类商品,调用IGoodsOrderService查询订单数据 + IGoodsOrderService goodsOrderService = SpringUtils.getBean(IGoodsOrderService.class); + order = goodsOrderService.selectGoodsOrderByorderId(orderid); + } else { + System.err.println("无效的商品类型,type: " + type + ", orderid: " + orderid); + return false; + } + + if (order == null) { + System.err.println("未找到订单数据,orderid: " + orderid + ", type: " + type); + return false; + } + + // 2. 查询商品/服务数据 + IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class); + Long productId = null; + Long orderNum = null; + String orderSku = null; + + if (type == 1) { + // 服务类商品 + Order serviceOrder = (Order) order; + productId = serviceOrder.getProductId(); + orderNum = serviceOrder.getNum() != null ? serviceOrder.getNum() : 1L; + orderSku = serviceOrder.getSku(); + } else if (type == 2) { + // 商城类商品 + GoodsOrder goodsOrder = (GoodsOrder) order; + productId = goodsOrder.getProductId(); + orderNum = goodsOrder.getNum() != null ? goodsOrder.getNum() : 1L; + orderSku = goodsOrder.getSku(); + } + + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); + + if (serviceGoods == null) { + System.err.println("未找到商品/服务数据,productId: " + productId + ", type: " + type); + return false; + } + + // 3. 增加销量 + Long currentSales = serviceGoods.getSales() != null ? serviceGoods.getSales() : 0L; + serviceGoods.setSales(currentSales + orderNum); + + // 4. 更新库存 + updateStock(serviceGoods, orderSku, orderNum); + + // 5. 保存更新后的商品/服务数据 + int updateResult = serviceGoodsService.updateServiceGoods(serviceGoods); + + if (updateResult > 0) { + System.out.println("库存及销量更新成功,orderid: " + orderid + + ", type: " + type + ", 销量增加: " + orderNum + ", 商品ID: " + serviceGoods.getId()); + return true; + } else { + System.err.println("库存及销量更新失败,orderid: " + orderid + ", type: " + type); + return false; + } + + } catch (Exception e) { + System.err.println("库存及销量变更异常,orderid: " + orderid + ", type: " + type + ", 错误: " + e.getMessage()); + e.printStackTrace(); + return false; + } + } + + /** + * 库存及销量变更(兼容旧版本) + * 根据订单ID更新商品/服务的销量和库存,默认为服务类商品 + * + * @param orderid 订单ID + * @return 处理结果,成功返回true,失败返回false + */ + public static boolean updateInventoryAndSales(String orderid) { + return updateInventoryAndSales(orderid, 1); // 默认为服务类商品 + } + + /** + * 更新库存逻辑 + * + * @param serviceGoods 商品/服务对象 + * @param orderSku 订单SKU + * @param orderNum 订单数量 + */ + private static void updateStock(ServiceGoods serviceGoods, String orderSku, Long orderNum) { + // 如果订单的sku为空或null,直接扣减ServiceGoods的库存 + if (orderSku == null || orderSku.trim().isEmpty()) { + Long currentStock = serviceGoods.getStock() != null ? serviceGoods.getStock() : 0L; + serviceGoods.setStock(Math.max(0, currentStock - orderNum)); // 确保库存不为负数 + System.out.println("直接扣减库存,商品ID: " + serviceGoods.getId() + + ", 扣减数量: " + orderNum + ", 剩余库存: " + serviceGoods.getStock()); + } else { + // 如果订单的sku有值,在ServiceGoods的sku中查找对应的sku并扣减库存 + updateSkuStock(serviceGoods, orderSku, orderNum); + } + } + + /** + * 更新SKU库存 + * + * @param serviceGoods 商品/服务对象 + * @param orderSku 订单SKU(具体规格选择) + * @param orderNum 订单数量 + */ + private static void updateSkuStock(ServiceGoods serviceGoods, String orderSku, Long orderNum) { + try { + String serviceSku = serviceGoods.getSku(); + if (serviceSku == null || serviceSku.trim().isEmpty()) { + System.err.println("商品SKU为空,无法更新SKU库存,商品ID: " + serviceGoods.getId()); + return; + } + + // 解析ServiceGoods的SKU JSON(复杂多规格格式) + JSONObject skuJson = JSONObject.parseObject(serviceSku); + + // 检查是否是复杂多规格格式 + if (!skuJson.containsKey("sku") || !skuJson.containsKey("type")) { + System.err.println("商品SKU格式不是多规格格式,商品ID: " + serviceGoods.getId()); + return; + } + + // 获取sku数组 + JSONArray skuArray = skuJson.getJSONArray("sku"); + if (skuArray == null || skuArray.isEmpty()) { + System.err.println("商品SKU数组为空,商品ID: " + serviceGoods.getId()); + return; + } + + // 解析订单SKU(具体规格选择) + JSONObject orderSkuJson = JSONObject.parseObject(orderSku); + + // 在sku数组中查找匹配的规格 + boolean found = false; + for (int i = 0; i < skuArray.size(); i++) { + JSONObject skuItem = skuArray.getJSONObject(i); + + // 检查是否匹配订单SKU的所有属性 + if (isSkuMatch(skuItem, orderSkuJson)) { + // 找到匹配的SKU,更新库存 + String stockStr = skuItem.getString("stock"); + + if (stockStr != null && !stockStr.trim().isEmpty()) { + try { + Long currentStock = Long.parseLong(stockStr); + Long newStock = Math.max(0, currentStock - orderNum); // 确保库存不为负数 + skuItem.put("stock", newStock.toString()); + + // 更新ServiceGoods的sku字段 + serviceGoods.setSku(skuJson.toJSONString()); + + System.out.println("SKU库存更新成功,商品ID: " + serviceGoods.getId() + + ", 订单SKU: " + orderSku + ", 扣减数量: " + orderNum + + ", 剩余库存: " + newStock); + found = true; + break; + } catch (NumberFormatException e) { + System.err.println("SKU库存格式错误,商品ID: " + serviceGoods.getId() + + ", SKU: " + orderSku + ", 库存值: " + stockStr); + } + } else { + System.err.println("SKU库存为空,商品ID: " + serviceGoods.getId() + ", SKU: " + orderSku); + } + } + } + + if (!found) { + System.err.println("未找到匹配的SKU,商品ID: " + serviceGoods.getId() + + ", 订单SKU: " + orderSku); + } + + } catch (Exception e) { + System.err.println("更新SKU库存异常,商品ID: " + serviceGoods.getId() + + ", 订单SKU: " + orderSku + ", 错误: " + e.getMessage()); + } + } + + /** + * 检查SKU是否匹配 + * + * @param skuItem 商品SKU项 + * @param orderSkuJson 订单SKU JSON + * @return 是否匹配 + */ + private static boolean isSkuMatch(JSONObject skuItem, JSONObject orderSkuJson) { + try { + // 遍历订单SKU的所有属性,检查是否与商品SKU项匹配 + for (String key : orderSkuJson.keySet()) { + // 跳过非属性字段(如price、stock等) + if ("price".equals(key) || "groupprice".equals(key) || + "seckillprice".equals(key) || "stock".equals(key) || + "pic".equals(key)) { + continue; + } + + String orderValue = orderSkuJson.getString(key); + String skuValue = skuItem.getString(key); + + // 如果属性值不匹配,返回false + if (!orderValue.equals(skuValue)) { + return false; + } + } + return true; + } catch (Exception e) { + System.err.println("SKU匹配检查异常: " + e.getMessage()); + return false; + } + } + public static void main(String[] args) { // 构造一个测试用的json字符串 String testJson = "{\"project\":{\"name\":\"项目费用\",\"price\":1132.00},\"reduction\":{\"name\":\"优惠金额\",\"price\":\"1\"},\"deposit\":{\"name\":\"定金\",\"price\":\"10\"},\"basic\":[{\"name\":\"测试基建2\",\"select\":true},{\"name\":\"测试基建5\",\"select\":true},{\"name\":\"测试基建8\",\"select\":true}],\"craft\":[{\"name\":\"三挂一方柜\",\"price\":\"336.00\",\"pid\":192,\"id\":1889,\"count\":3}],\"material\":[{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1241,\"pid\":93,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1240,\"pid\":93,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1196,\"pid\":93,\"count\":1},{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1197,\"pid\":93,\"count\":1},{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1197,\"pid\":92,\"count\":1},{\"name\":\"111\",\"price\":\"10.00\",\"id\":1250,\"pid\":92,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1196,\"pid\":92,\"count\":2}]}"; OrderUtil util = new OrderUtil(); JSONObject result = util.getbaojiajson(testJson); System.out.println("处理后的结果: " + result.toJSONString()); + + // 测试库存及销量变更方法 + System.out.println("=== 测试库存及销量变更方法 ==="); + + // 测试服务类商品(type=1) + String serviceOrderId = "TEST_SERVICE_ORDER_001"; + boolean serviceResult = updateInventoryAndSales(serviceOrderId, 1); + System.out.println("服务类商品库存及销量变更测试结果: " + serviceResult); + + // 测试商城类商品(type=2) + String goodsOrderId = "TEST_GOODS_ORDER_001"; + boolean goodsResult = updateInventoryAndSales(goodsOrderId, 2); + System.out.println("商城类商品库存及销量变更测试结果: " + goodsResult); + + // 测试兼容旧版本(默认为服务类商品) + String orderId = "TEST_ORDER_001"; + boolean result2 = updateInventoryAndSales(orderId); + System.out.println("兼容旧版本库存及销量变更测试结果: " + result2); + + // 测试SKU匹配逻辑 + System.out.println("=== 测试SKU匹配逻辑 ==="); + String testOrderSku = "{\"颜色\":\"黑\",\"大小\":\"小\",\"尺寸\":\"300*300\",\"pic\":[\"https://img.huafurenjia.cn/images/2025-07-15/c638e39be08941aaaa47ee926a1ac5e5.png\"],\"price\":\"100\",\"groupprice\":\"100\",\"seckillprice\":\"99\",\"stock\":\"100\"}"; + JSONObject orderSkuJson = JSONObject.parseObject(testOrderSku); + + // 模拟一个SKU项进行匹配测试 + JSONObject testSkuItem = new JSONObject(); + testSkuItem.put("颜色", "黑"); + testSkuItem.put("大小", "小"); + testSkuItem.put("尺寸", "300*300"); + testSkuItem.put("price", "100"); + testSkuItem.put("stock", "100"); + + boolean matchResult = isSkuMatch(testSkuItem, orderSkuJson); + System.out.println("SKU匹配测试结果: " + matchResult); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PageUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PageUtil.java index 8f60d8c..a05a20c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PageUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PageUtil.java @@ -59,7 +59,7 @@ public class PageUtil { pageData.put("data", tableDataInfo.getRows()); pageData.put("from", from); pageData.put("last_page", lastPage); - // pageData.put("next_page_url", nextPageUrl); + pageData.put("next_page_url", nextPageUrl); pageData.put("per_page", String.valueOf(perPage)); //pageData.put("prev_page_url", prevPageUrl); //pageData.put("to", to); @@ -68,34 +68,34 @@ public class PageUtil { return pageData; } - /** - * 构建简单的分页响应数据(不包含URL) - * - * @param tableDataInfo 分页表格数据 - * @param currentPage 当前页码 - * @param perPage 每页数量 - * @return 简单分页响应数据 - */ - public static Map buildSimplePageResponse(TableDataInfo tableDataInfo, int currentPage, int perPage) { - Map pageData = new HashMap<>(); - - // 计算分页信息 - long total = tableDataInfo.getTotal(); - int lastPage = (int) Math.ceil((double) total / perPage); - int from = total > 0 ? (currentPage - 1) * perPage + 1 : 0; - int to = (int) Math.min(currentPage * perPage, total); - - // 设置分页数据(不包含URL) - pageData.put("current_page", currentPage); - pageData.put("data", tableDataInfo.getRows()); - pageData.put("from", from); - pageData.put("last_page", lastPage); - pageData.put("per_page", String.valueOf(perPage)); - pageData.put("to", to); - pageData.put("total", total); - - return pageData; - } +// /** +// * 构建简单的分页响应数据(不包含URL) +// * +// * @param tableDataInfo 分页表格数据 +// * @param currentPage 当前页码 +// * @param perPage 每页数量 +// * @return 简单分页响应数据 +// */ +// public static Map buildSimplePageResponse(TableDataInfo tableDataInfo, int currentPage, int perPage) { +// Map pageData = new HashMap<>(); +// +// // 计算分页信息 +// long total = tableDataInfo.getTotal(); +// int lastPage = (int) Math.ceil((double) total / perPage); +// int from = total > 0 ? (currentPage - 1) * perPage + 1 : 0; +// int to = (int) Math.min(currentPage * perPage, total); +// +// // 设置分页数据(不包含URL) +// pageData.put("current_page", currentPage); +// pageData.put("data", tableDataInfo.getRows()); +// pageData.put("from", from); +// pageData.put("last_page", lastPage); +// pageData.put("per_page", String.valueOf(perPage)); +// pageData.put("to", to); +// pageData.put("total", total); +// +// return pageData; +// } /** * 计算总页数 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PayBeforeUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PayBeforeUtil.java index 84805e0..bed7ae1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PayBeforeUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/PayBeforeUtil.java @@ -351,17 +351,84 @@ public class PayBeforeUtil { } try { com.alibaba.fastjson2.JSONObject json = com.alibaba.fastjson2.JSONObject.parseObject(baojiajson); + + // 获取总金额 + BigDecimal totalAmount = BigDecimal.ZERO; + JSONObject project = json.getJSONObject("project"); + if (project != null) { + String projectPriceStr = project.getString("price"); + try { + totalAmount = new BigDecimal(projectPriceStr); + } catch (Exception ignore) {} + } + + // 获取优惠金额 + BigDecimal reductionPrice = BigDecimal.ZERO; + JSONObject reduction = json.getJSONObject("reduction"); + if (reduction != null) { + String reductionPriceStr = reduction.getString("price"); + try { + reductionPrice = new BigDecimal(reductionPriceStr); + } catch (Exception ignore) {} + } + // 处理定金 + handleDepositPayBefore(user, orderLog, json, lastorderid); + + // 处理尾款 + handleFinalPaymentPayBefore(user, orderLog, json, totalAmount, reductionPrice, lastorderid); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 处理定金预支付数据 + * @param user 用户实体 + * @param orderLog 订单日志实体 + * @param json 报价json对象 + * @param lastorderid 主订单号 + */ + private void handleDepositPayBefore(Users user, OrderLog orderLog, com.alibaba.fastjson2.JSONObject json, String lastorderid) { + try { + // 获取报价中的定金信息 JSONObject deposit = json.getJSONObject("deposit"); + BigDecimal depositPrice = BigDecimal.ZERO; + boolean hasDepositInQuotation = false; + if (deposit != null) { String depositPriceStr = deposit.getString("price"); - BigDecimal depositPrice = null; try { depositPrice = new BigDecimal(depositPriceStr); + hasDepositInQuotation = depositPrice.compareTo(BigDecimal.ZERO) > 0; } catch (Exception ignore) {} - if (depositPrice != null && depositPrice.compareTo(BigDecimal.ZERO) > 0) { - // 添加定金预支付信息 - this.createPayBefore( + } + + // 查询预支付表中是否已有定金数据 + UsersPayBefor existingDeposit = queryPayBeforeByOrderidAndType(orderLog.getOrderId(), 8L); + + if (hasDepositInQuotation) { + // 报价中有定金 + if (existingDeposit != null) { + // 预支付表中已有定金数据,需要更新 + if (existingDeposit.getAllmoney().compareTo(depositPrice) != 0) { + // 金额不一致,删除旧数据,插入新数据 + usersPayBeforService.deleteUsersPayBeforById(existingDeposit.getId()); + createPayBefore( + user, + depositPrice, + orderLog.getDepLogId(), // orderid + orderLog.getId(), // oid + null, // serviceId + 8L, // type=8 定金 + null, null, null, null, null, 1L, null, lastorderid + ); + } + // 金额一致,无需操作 + } else { + // 预支付表中没有定金数据,插入新数据 + createPayBefore( user, depositPrice, orderLog.getDepLogId(), // orderid @@ -371,34 +438,58 @@ public class PayBeforeUtil { null, null, null, null, null, 1L, null, lastorderid ); } + } else { + // 报价中没有定金 + if (existingDeposit != null) { + // 预支付表中有定金数据,需要删除 + usersPayBeforService.deleteUsersPayBeforById(existingDeposit.getId()); + } + // 报价中没有定金,预支付表中也没有,无需操作 } - // 处理尾款 - JSONObject project = json.getJSONObject("project"); - if (project != null) { - String projectPriceStr = project.getString("price"); - BigDecimal projectPrice = null; + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 处理尾款预支付数据 + * @param user 用户实体 + * @param orderLog 订单日志实体 + * @param json 报价json对象 + * @param totalAmount 总金额 + * @param reductionPrice 优惠金额 + * @param lastorderid 主订单号 + */ + private void handleFinalPaymentPayBefore(Users user, OrderLog orderLog, com.alibaba.fastjson2.JSONObject json, + BigDecimal totalAmount, BigDecimal reductionPrice, String lastorderid) { + try { + // 获取报价中的定金信息 + JSONObject deposit = json.getJSONObject("deposit"); + BigDecimal depositPrice = BigDecimal.ZERO; + + if (deposit != null) { + String depositPriceStr = deposit.getString("price"); try { - projectPrice = new BigDecimal(projectPriceStr); + depositPrice = new BigDecimal(depositPriceStr); } catch (Exception ignore) {} - if (projectPrice != null && projectPrice.compareTo(BigDecimal.ZERO) > 0) { - // 判断优惠金额 - JSONObject reduction = json.getJSONObject("reduction"); - BigDecimal reductionPrice = BigDecimal.ZERO; - if (reduction != null) { - String reductionPriceStr = reduction.getString("price"); - try { - reductionPrice = new BigDecimal(reductionPriceStr); - } catch (Exception ignore) {} - } - BigDecimal finalTail = projectPrice; - if (reductionPrice != null && reductionPrice.compareTo(BigDecimal.ZERO) > 0) { - finalTail = projectPrice.subtract(reductionPrice); - } - if (finalTail.compareTo(BigDecimal.ZERO) > 0) { - // 添加尾款预支付信息 - this.createPayBefore( + } + + // 计算尾款金额:总金额 - 定金 - 优惠金额 + BigDecimal finalPaymentAmount = totalAmount.subtract(depositPrice).subtract(reductionPrice); + + // 查询预支付表中是否已有尾款数据 + UsersPayBefor existingFinalPayment = queryPayBeforeByOrderidAndType(orderLog.getOrderId(), 9L); + + if (finalPaymentAmount.compareTo(BigDecimal.ZERO) > 0) { + // 尾款金额大于0 + if (existingFinalPayment != null) { + // 预支付表中已有尾款数据,需要更新 + if (existingFinalPayment.getAllmoney().compareTo(finalPaymentAmount) != 0) { + // 金额不一致,删除旧数据,插入新数据 + usersPayBeforService.deleteUsersPayBeforById(existingFinalPayment.getId()); + createPayBefore( user, - finalTail, + finalPaymentAmount, orderLog.getLogOrderId(), // orderid orderLog.getId(), // oid null, // serviceId @@ -406,10 +497,76 @@ public class PayBeforeUtil { null, null, null, null, null, 1L, null, lastorderid ); } + // 金额一致,无需操作 + } else { + // 预支付表中没有尾款数据,插入新数据 + createPayBefore( + user, + finalPaymentAmount, + orderLog.getLogOrderId(), // orderid + orderLog.getId(), // oid + null, // serviceId + 9L, // type=9 尾款 + null, null, null, null, null, 1L, null, lastorderid + ); } + } else { + // 尾款金额小于等于0 + if (existingFinalPayment != null) { + // 预支付表中有尾款数据,需要删除 + usersPayBeforService.deleteUsersPayBeforById(existingFinalPayment.getId()); + } + // 尾款金额为0或负数,不插入预支付数据 } } catch (Exception e) { e.printStackTrace(); } } + + /** + * 根据订单ID和支付类型查询预支付记录 + * @param oid 订单ID + * @param type 支付类型 + * @return 预支付记录,不存在返回null + */ + private UsersPayBefor queryPayBeforeByOrderAndType(Long oid, Long type) { + try { + UsersPayBefor queryParam = new UsersPayBefor(); + queryParam.setOid(oid); + queryParam.setType(type); + List payBeforeList = usersPayBeforService.selectUsersPayBeforList(queryParam); + + if (payBeforeList != null && !payBeforeList.isEmpty()) { + return payBeforeList.get(0); // 返回第一条记录 + } + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + + + /** + * 根据订单ID和支付类型查询预支付记录 + * @param type 支付类型 + * @return 预支付记录,不存在返回null + */ + private UsersPayBefor queryPayBeforeByOrderidAndType(String orderid, Long type) { + try { + UsersPayBefor queryParam = new UsersPayBefor(); + queryParam.setLastorderid(orderid); + queryParam.setType(type); + List payBeforeList = usersPayBeforService.selectUsersPayBeforList(queryParam); + + if (payBeforeList != null && !payBeforeList.isEmpty()) { + return payBeforeList.get(0); // 返回第一条记录 + } + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/RefundUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/RefundUtil.java index 61de9e7..bd04cd4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/RefundUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/RefundUtil.java @@ -7,6 +7,8 @@ import com.ruoyi.system.ControllerUtil.WechatPayV3Util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; import java.util.Map; @Component @@ -18,25 +20,50 @@ public class RefundUtil { private static IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class); private static IUserMemnerConsumptionLogService userMemnerConsumptionLogService = SpringUtils.getBean(IUserMemnerConsumptionLogService.class); private static IUserGroupBuyingService userGroupBuyingService = SpringUtils.getBean(IUserGroupBuyingService.class); + private static ISiteConfigService siteConfigService = SpringUtils.getBean(ISiteConfigService.class); + private static IIntegralLogService integralLogService = SpringUtils.getBean(IIntegralLogService.class); + private static IUserBenefitPointsService userBenefitPointsService = SpringUtils.getBean(IUserBenefitPointsService.class); // 退款方法 public boolean refundOrder(String orderid) { + System.out.println("=== 开始退款处理,订单号: " + orderid + " ==="); + // 查询预支付记录 + System.out.println("步骤1: 查询预支付记录..."); UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderid); if (payBefor == null) { + System.err.println("❌ 预支付记录不存在,订单号: " + orderid); return false; } + System.out.println("✅ 预支付记录查询成功"); + System.out.println(" 订单信息 - 用户ID: " + payBefor.getUid() + + ", 订单金额: " + payBefor.getAllmoney() + + ", 支付类型: " + payBefor.getPaytype() + + ", 服务类型: " + payBefor.getServicetype()); + boolean refundSuccess = false; - // paytype=4,微信退款,金额为allmoney + + // 1. 处理微信退款和余额退款 + System.out.println("步骤2: 开始处理退款..."); if (payBefor.getPaytype() != null && payBefor.getPaytype() == 4) { + System.out.println(" 检测到支付类型为4(微信支付),处理微信退款..."); + // paytype=4,微信退款,金额为allmoney if (payBefor.getAllmoney() != null && payBefor.getAllmoney().compareTo(BigDecimal.ZERO) > 0) { + System.out.println(" 微信退款金额: " + payBefor.getAllmoney() + "元"); Map refundSuccessdata = wechatPayV3Util.refund(payBefor.getOrderid(), payBefor.getPaycode(), payBefor.getAllmoney().intValue(), payBefor.getAllmoney().intValue(), "退款", ""); refundSuccess = true; // 可根据refundSuccessdata内容判断 + System.out.println("✅ 微信退款处理完成"); + } else { + System.out.println("❌ 微信退款金额为0或空"); } } else { + System.out.println(" 检测到混合支付类型,分别处理微信和余额退款..."); boolean wxRefunded = false; boolean yeRefunded = false; + + // 处理微信退款 if (payBefor.getWxmoney() != null && payBefor.getWxmoney().compareTo(BigDecimal.ZERO) > 0) { + System.out.println(" 微信退款金额: " + payBefor.getWxmoney() + "元"); Map refundSuccessdata = wechatPayV3Util.refund( payBefor.getOrderid(), payBefor.getPaycode(), @@ -46,17 +73,56 @@ public class RefundUtil { "" ); wxRefunded = true; // 可根据refundSuccessdata内容判断 + System.out.println("✅ 微信退款处理完成"); + } else { + System.out.println(" 微信退款金额为0或空,跳过微信退款"); } + + // 处理余额退款 if (payBefor.getYemoney() != null && payBefor.getYemoney().compareTo(BigDecimal.ZERO) > 0) { + System.out.println(" 余额退款金额: " + payBefor.getYemoney() + "元"); yeRefunded = refundBalance(payBefor); + if (yeRefunded) { + System.out.println("✅ 余额退款处理完成"); + } else { + System.err.println("❌ 余额退款处理失败"); + } + } else { + System.out.println(" 余额退款金额为0或空,跳过余额退款"); } + refundSuccess = wxRefunded || yeRefunded; // 或者 wxRefunded && yeRefunded + System.out.println(" 退款结果 - 微信退款: " + wxRefunded + ", 余额退款: " + yeRefunded); } - // 退款成功后,修改状态为3 + + // 2. 如果退款成功,处理积分扣除和服务金消费金处理 if (refundSuccess) { - payBefor.setStatus(3L); - usersPayBeforService.updateUsersPayBefor(payBefor); + System.out.println("步骤3: 退款成功,开始处理积分和服务金消费金..."); + try { + // 处理积分扣除 + System.out.println(" 3.1: 处理积分扣除..."); + processIntegralDeduction(payBefor); + + // 处理服务金和消费金扣除 + System.out.println(" 3.2: 处理服务金和消费金增加..."); + processBenefitDeduction(payBefor); + + // 修改状态为3 + System.out.println(" 3.3: 更新订单状态为已退款..."); + payBefor.setStatus(3L); + usersPayBeforService.updateUsersPayBefor(payBefor); + System.out.println("✅ 订单状态更新完成"); + + } catch (Exception e) { + // 记录异常但不影响退款结果 + System.err.println("❌ 退款后处理异常:" + e.getMessage()); + e.printStackTrace(); + } + } else { + System.err.println("❌ 退款失败,跳过后续处理"); } + + System.out.println("=== 退款处理完成,最终结果: " + (refundSuccess ? "成功" : "失败") + " ==="); return refundSuccess; } @@ -93,4 +159,291 @@ public class RefundUtil { // WXsendMsgUtil.sendUserPayMoney(user.getOpenid(), "余额退款成功", payBefor.getYemoney().toString(), "1", "余额退款成功"); return true; } + + /** + * 处理积分扣除 + * + * @param payBefor 支付前对象 + */ + private void processIntegralDeduction(UsersPayBefor payBefor) { + System.out.println(" 开始处理积分扣除..."); + try { + System.out.println(" 查询用户信息..."); + Users users = usersService.selectUsersById(payBefor.getUid()); + if (users == null) { + System.err.println("❌ 用户不存在,用户ID: " + payBefor.getUid()); + return; + } + System.out.println(" ✅ 用户信息查询成功,用户ID: " + users.getId()); + + System.out.println(" 查询系统配置信息..."); + // 查询配置信息 + SiteConfig config = siteConfigService.selectSiteConfigByName("config_one"); + if (config == null || config.getValue() == null) { + System.err.println("❌ 未找到config_one配置信息"); + return; + } + System.out.println(" ✅ 系统配置信息查询成功"); + + System.out.println(" 解析配置信息..."); + // 解析配置信息 + com.alibaba.fastjson.JSONObject configJson = com.alibaba.fastjson.JSONObject.parseObject(config.getValue()); + BigDecimal orderScore = configJson.getBigDecimal("orderScore"); + + if (orderScore == null) { + System.err.println("❌ 配置信息不完整,orderScore为空"); + return; + } + System.out.println(" ✅ 积分兑换比例: " + orderScore); + + System.out.println(" 计算应扣除积分..."); + // 计算积分:allmoney / orderScore,向下取整 + BigDecimal integralDecimal = payBefor.getAllmoney().divide(orderScore, 0, RoundingMode.DOWN); + Long integralPoints = integralDecimal.longValue(); + System.out.println(" 订单金额: " + payBefor.getAllmoney() + "元"); + System.out.println(" 计算得出应扣除积分: " + integralPoints + "点"); + + if (integralPoints > 0) { + System.out.println(" 检查用户当前积分..."); + // 检查用户积分是否足够 + Long currentIntegral = users.getIntegral() != null ? users.getIntegral() : 0L; + System.out.println(" 用户当前积分: " + currentIntegral + "点"); + + if (currentIntegral < integralPoints) { + System.err.println(" ⚠️ 用户积分不足,当前积分" + currentIntegral + ",需要扣除" + integralPoints); + integralPoints = currentIntegral; // 只能扣除现有积分 + System.out.println(" 调整为扣除现有积分: " + integralPoints + "点"); + } + + if (integralPoints > 0) { + System.out.println(" 更新用户积分..."); + // 更新用户积分 + users.setIntegral(currentIntegral - integralPoints); + // 注意:total_integral不减少,因为这是累计积分 + + System.out.println(" 保存用户信息..."); + // 更新用户信息 + int updateResult = usersService.updateUsers(users); + if (updateResult > 0) { + System.out.println(" ✅ 用户积分更新成功"); + + System.out.println(" 记录积分扣除日志..."); + // 添加积分减少日志 + IntegralLog integralLog = new IntegralLog(); + integralLog.setOrderId(payBefor.getOrderid()); + integralLog.setTitle("订单退款扣除积分"); + integralLog.setMark("订单退款" + payBefor.getAllmoney() + "元,扣除积分" + integralPoints + "点"); + integralLog.setUid(users.getId()); + integralLog.setUname(users.getName()); + integralLog.setType(2L); // 2:减少 + integralLog.setNum(integralPoints); + integralLog.setCreatedAt(new Date()); + integralLog.setUpdatedAt(new Date()); + + integralLogService.insertIntegralLog(integralLog); + + System.out.println(" ✅ 积分扣除完成,扣除积分" + integralPoints + "点"); + } else { + System.err.println("❌ 更新用户积分失败,用户ID: " + users.getId()); + } + } else { + System.out.println(" 无需扣除积分"); + } + } else { + System.out.println(" 计算积分为0,无需扣除"); + } + + } catch (Exception e) { + System.err.println("❌ 处理积分扣除异常: " + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * 处理服务金和消费金增加 + * + * @param payBefor 支付前对象 + */ + private void processBenefitDeduction(UsersPayBefor payBefor) { + System.out.println(" 开始处理服务金和消费金增加..."); + try { + System.out.println(" 查询用户信息..."); + Users users = usersService.selectUsersById(payBefor.getUid()); + if (users == null) { + System.err.println("❌ 用户不存在,用户ID: " + payBefor.getUid()); + return; + } + System.out.println(" ✅ 用户信息查询成功,用户ID: " + users.getId()); + + System.out.println(" 查询系统配置信息..."); + // 查询配置信息 + SiteConfig config = siteConfigService.selectSiteConfigByName("config_one"); + if (config == null || config.getValue() == null) { + System.err.println("❌ 未找到config_one配置信息"); + return; + } + System.out.println(" ✅ 系统配置信息查询成功"); + + System.out.println(" 解析配置信息..."); + // 解析配置信息 + com.alibaba.fastjson.JSONObject configJson = com.alibaba.fastjson.JSONObject.parseObject(config.getValue()); + BigDecimal servicefee = configJson.getBigDecimal("servicefee"); + BigDecimal consumption = configJson.getBigDecimal("consumption"); + + if (servicefee == null || consumption == null) { + System.err.println("❌ 配置信息不完整,servicefee或consumption为空"); + return; + } + System.out.println(" ✅ 服务金比例: " + servicefee + "%, 消费金比例: " + consumption + "%"); + + System.out.println(" 判断订单类型..."); + // 根据servicetype判断处理类型 + Integer servicetype = payBefor.getServicetype() != null ? payBefor.getServicetype().intValue() : 1; + System.out.println(" 订单类型: " + servicetype + " (" + (servicetype == 1 ? "服务类型" : "商城类型") + ")"); + + if (servicetype == 1) { + System.out.println(" 处理服务类型订单,增加消费金..."); + // 服务类型:增加消费金 + processConsumptionAddition(payBefor, users, consumption); + } else if (servicetype == 2) { + System.out.println(" 处理商城类型订单,增加服务金..."); + // 商城类型:增加服务金 + processServicefeeAddition(payBefor, users, servicefee); + } + + } catch (Exception e) { + System.err.println("❌ 处理服务金和消费金增加异常: " + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * 处理消费金增加 + * + * @param payBefor 支付前对象 + * @param users 用户对象 + * @param consumption 消费金比例 + */ + private void processConsumptionAddition(UsersPayBefor payBefor, Users users, BigDecimal consumption) { + System.out.println(" 开始处理消费金增加..."); + try { + System.out.println(" 计算增加金额..."); + // 计算增加金额:allmoney * consumption% + BigDecimal benefitAmount = payBefor.getAllmoney().multiply(consumption).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); + System.out.println(" 订单金额: " + payBefor.getAllmoney() + "元"); + System.out.println(" 消费金比例: " + consumption + "%"); + System.out.println(" 计算得出增加金额: " + benefitAmount + "元"); + + if (benefitAmount.compareTo(BigDecimal.ZERO) > 0) { + System.out.println(" 获取用户当前消费金余额..."); + // 获取当前消费金余额 + BigDecimal currentConsumption = users.getConsumption() != null ? users.getConsumption() : BigDecimal.ZERO; + System.out.println(" 用户当前消费金余额: " + currentConsumption + "元"); + + System.out.println(" 更新用户消费金..."); + // 增加消费金 + users.setConsumption(currentConsumption.add(benefitAmount)); + System.out.println(" 更新后消费金余额: " + users.getConsumption() + "元"); + + System.out.println(" 保存用户信息..."); + // 更新用户信息 + int updateResult = usersService.updateUsers(users); + if (updateResult > 0) { + System.out.println(" ✅ 用户信息更新成功"); + + System.out.println(" 记录消费金增加日志..."); + // 添加福利金增加日志 + UserBenefitPoints benefitPoints = new UserBenefitPoints(); + benefitPoints.setType(1L); // 消费金 + benefitPoints.setDotime(new Date()); + benefitPoints.setOrdermoney(payBefor.getAllmoney()); + benefitPoints.setMoney(benefitAmount); // 正数 + benefitPoints.setOrdertype(1L); // 收入 + benefitPoints.setUid(users.getId()); + benefitPoints.setBeformoney(currentConsumption); + benefitPoints.setAftremoney(users.getConsumption()); + benefitPoints.setCreatedAt(new Date()); + benefitPoints.setUpdatedAt(new Date()); + benefitPoints.setReamk("订单退款增加消费金,订单金额:" + payBefor.getAllmoney() + "元,消费金比例:" + consumption + "%,实际增加:" + benefitAmount + "元"); + + userBenefitPointsService.insertUserBenefitPoints(benefitPoints); + + System.out.println(" ✅ 消费金增加完成,增加" + benefitAmount + "元"); + } else { + System.err.println(" ❌ 用户信息更新失败"); + } + } else { + System.out.println(" 计算金额为0,无需增加消费金"); + } + + } catch (Exception e) { + System.err.println(" ❌ 处理消费金增加异常: " + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * 处理服务金增加 + * + * @param payBefor 支付前对象 + * @param users 用户对象 + * @param servicefee 服务金比例 + */ + private void processServicefeeAddition(UsersPayBefor payBefor, Users users, BigDecimal servicefee) { + System.out.println(" 开始处理服务金增加..."); + try { + System.out.println(" 计算增加金额..."); + // 计算增加金额:allmoney * servicefee% + BigDecimal benefitAmount = payBefor.getAllmoney().multiply(servicefee).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); + System.out.println(" 订单金额: " + payBefor.getAllmoney() + "元"); + System.out.println(" 服务金比例: " + servicefee + "%"); + System.out.println(" 计算得出增加金额: " + benefitAmount + "元"); + + if (benefitAmount.compareTo(BigDecimal.ZERO) > 0) { + System.out.println(" 获取用户当前服务金余额..."); + // 获取当前服务金余额 + BigDecimal currentServicefee = users.getServicefee() != null ? users.getServicefee() : BigDecimal.ZERO; + System.out.println(" 用户当前服务金余额: " + currentServicefee + "元"); + + System.out.println(" 更新用户服务金..."); + // 增加服务金 + users.setServicefee(currentServicefee.add(benefitAmount)); + System.out.println(" 更新后服务金余额: " + users.getServicefee() + "元"); + + System.out.println(" 保存用户信息..."); + // 更新用户信息 + int updateResult = usersService.updateUsers(users); + if (updateResult > 0) { + System.out.println(" ✅ 用户信息更新成功"); + + System.out.println(" 记录服务金增加日志..."); + // 添加福利金增加日志 + UserBenefitPoints benefitPoints = new UserBenefitPoints(); + benefitPoints.setType(2L); // 服务金 + benefitPoints.setDotime(new Date()); + benefitPoints.setOrdermoney(payBefor.getAllmoney()); + benefitPoints.setMoney(benefitAmount); // 正数 + benefitPoints.setOrdertype(1L); // 收入 + benefitPoints.setUid(users.getId()); + benefitPoints.setBeformoney(currentServicefee); + benefitPoints.setAftremoney(users.getServicefee()); + benefitPoints.setCreatedAt(new Date()); + benefitPoints.setUpdatedAt(new Date()); + benefitPoints.setReamk("订单退款增加服务金,订单金额:" + payBefor.getAllmoney() + "元,服务金比例:" + servicefee + "%,实际增加:" + benefitAmount + "元"); + + userBenefitPointsService.insertUserBenefitPoints(benefitPoints); + + System.out.println(" ✅ 服务金增加完成,增加" + benefitAmount + "元"); + } else { + System.err.println(" ❌ 用户信息更新失败"); + } + } else { + System.out.println(" 计算金额为0,无需增加服务金"); + } + + } catch (Exception e) { + System.err.println(" ❌ 处理服务金增加异常: " + e.getMessage()); + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayUtil.java index acebe7f..442c6ff 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayUtil.java @@ -81,7 +81,7 @@ public class WechatPayUtil { private static final String WECHAT_TRANSFER_URL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; // 企业付款 - public static final String PAY_FH = "https://4a8ed13a.r3.cpolar.top/"; + public static final String PAY_FH = "https://12cb4ff9.r3.cpolar.top/"; /** * 其他配置常量 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayV3Util.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayV3Util.java index 88a5ef5..3ac980e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayV3Util.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WechatPayV3Util.java @@ -401,8 +401,8 @@ public class WechatPayV3Util { // 构建请求参数 log.info("🔧 开始构建请求参数"); Map amount = new HashMap<>(); - amount.put("refund", refundFee); - amount.put("total", totalFee); + amount.put("refund", 1); + amount.put("total", 1); amount.put("currency", "CNY"); Map params = new HashMap<>(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/GoodsOrder.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/GoodsOrder.java index 7d8b3e2..7b6438a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/GoodsOrder.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/GoodsOrder.java @@ -157,7 +157,18 @@ public class GoodsOrder extends BaseEntity private String paystartdate; private String payenddate; + private Long returntype; + private String returnreason; + private String returnfiledata; + private String returnlogistics; + private String returnlogisticscode; + private String returnjson; + private Long returnstatus; + private Date returntime; + private BigDecimal returnmoney; + private Date returnfinshtime; + private String returnshow; /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @@ -558,6 +569,95 @@ public class GoodsOrder extends BaseEntity this.isforservice = isforservice; } + + public String getReturnjson() { + return returnjson; + } + + public void setReturnjson(String returnjson) { + this.returnjson = returnjson; + } + + public String getReturnlogisticscode() { + return returnlogisticscode; + } + + public void setReturnlogisticscode(String returnlogisticscode) { + this.returnlogisticscode = returnlogisticscode; + } + + public String getReturnlogistics() { + return returnlogistics; + } + + public void setReturnlogistics(String returnlogistics) { + this.returnlogistics = returnlogistics; + } + + public String getReturnfiledata() { + return returnfiledata; + } + + public void setReturnfiledata(String returnfiledata) { + this.returnfiledata = returnfiledata; + } + + public String getReturnreason() { + return returnreason; + } + + public void setReturnreason(String returnreason) { + this.returnreason = returnreason; + } + + public Long getReturntype() { + return returntype; + } + + public void setReturntype(Long returntype) { + this.returntype = returntype; + } + + public Date getReturnfinshtime() { + return returnfinshtime; + } + + public void setReturnfinshtime(Date returnfinshtime) { + this.returnfinshtime = returnfinshtime; + } + + public BigDecimal getReturnmoney() { + return returnmoney; + } + + public void setReturnmoney(BigDecimal returnmoney) { + this.returnmoney = returnmoney; + } + + public Date getReturntime() { + return returntime; + } + + public void setReturntime(Date returntime) { + this.returntime = returntime; + } + + public Long getReturnstatus() { + return returnstatus; + } + + public void setReturnstatus(Long returnstatus) { + this.returnstatus = returnstatus; + } + + public String getReturnshow() { + return returnshow; + } + + public void setReturnshow(String returnshow) { + this.returnshow = returnshow; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java index 1887d26..96ebed0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java @@ -226,6 +226,11 @@ public class Order extends BaseEntity private String payenddate; private String startdate; private String enddate; + private String qiangdan; + + + + /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @@ -953,6 +958,15 @@ public class Order extends BaseEntity this.ispay = ispay; } + + public String getQiangdan() { + return qiangdan; + } + + public void setQiangdan(String qiangdan) { + this.qiangdan = qiangdan; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderLog.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderLog.java index 1712ad7..06a727c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderLog.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderLog.java @@ -126,6 +126,14 @@ public class OrderLog extends BaseEntity @Excel(name = "历史师傅订单") private Long workerLogId; + + + /** 历史师傅订单 */ + @Excel(name = "订单了别") + private Long ordertype; + + + /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Date createdAt; @@ -433,6 +441,14 @@ public class OrderLog extends BaseEntity this.cjPaid = cjPaid; } + public Long getOrdertype() { + return ordertype; + } + + public void setOrdertype(Long ordertype) { + this.ordertype = ordertype; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserUseSecondaryCard.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserUseSecondaryCard.java index e2193e7..d008249 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserUseSecondaryCard.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserUseSecondaryCard.java @@ -65,6 +65,9 @@ public class UserUseSecondaryCard extends BaseEntity @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Date updatedAt; + + private String nostatus; + public void setId(Long id) { this.id = id; @@ -185,6 +188,15 @@ public class UserUseSecondaryCard extends BaseEntity return updatedAt; } + + public String getNostatus() { + return nostatus; + } + + public void setNostatus(String nostatus) { + this.nostatus = nostatus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java index 6c4ef51..c073d44 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java @@ -104,7 +104,7 @@ public class UsersPayBefor extends BaseEntity private Long servicetype; - + private Long num; private Long baojiaid; private String sku; @@ -381,6 +381,14 @@ public class UsersPayBefor extends BaseEntity this.lastorderid = lastorderid; } + public Long getNum() { + return num; + } + + public void setNum(Long num) { + this.num = num; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMarginLog.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMarginLog.java index f2e7ddc..a983ab2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMarginLog.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMarginLog.java @@ -33,6 +33,11 @@ public class WorkerMarginLog extends BaseEntity @Excel(name = "订单号") private String orderId; + + /** 订单号 */ + @Excel(name = "原因") + private String reamk; + /** 金额 */ @Excel(name = "金额") private BigDecimal price; @@ -115,6 +120,14 @@ public class WorkerMarginLog extends BaseEntity return updatedAt; } + public String getReamk() { + return reamk; + } + + public void setReamk(String reamk) { + this.reamk = reamk; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMoneyLog.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMoneyLog.java index 8cb3556..5b55309 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMoneyLog.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/WorkerMoneyLog.java @@ -107,6 +107,17 @@ public class WorkerMoneyLog extends BaseEntity @Excel(name = "锁单金额") private BigDecimal lookMoney; + + /** 平台变更金额原因 */ + @Excel(name = "分佣公式") + private String gongshi; + + /** 锁单金额 */ + @Excel(name = "锁单金额") + private BigDecimal clmoney; + + + public void setId(int id) { this.id = id; @@ -325,6 +336,27 @@ public class WorkerMoneyLog extends BaseEntity this.workerName = workerName; } + + public BigDecimal getClmoney() { + return clmoney; + } + + public void setClmoney(BigDecimal clmoney) { + this.clmoney = clmoney; + } + + public String getGongshi() { + return gongshi; + } + + public void setGongshi(String gongshi) { + this.gongshi = gongshi; + } + + public void setCr(int cr) { + this.cr = cr; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderMapper.java index 6284df6..37e80d0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderMapper.java @@ -1,6 +1,7 @@ package com.ruoyi.system.mapper; import java.util.List; +import java.util.Map; import com.ruoyi.system.domain.AppleDoMain.OrderApple; import com.ruoyi.system.domain.Order; @@ -85,4 +86,94 @@ public interface OrderMapper * @return 订单数量 */ Integer selectOrderCountByBigtype(@Param("uid") Long uid, @Param("type") Integer type); + + // ========== 预约人数查询相关方法 ========== + + /** + * 根据预约日期和时间段查询预约数量 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约数量 + */ + public Integer selectOrderCountByMakeTimeAndHour(Map params); + + /** + * 根据预约日期查询所有预约订单 + * + * @param params 查询参数,包含makeTime + * @return 预约订单列表 + */ + public List selectOrderListByMakeTime(Map params); + + /** + * 根据预约日期和时间段查询预约订单列表 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约订单列表 + */ + public List selectOrderListByMakeTimeAndHour(Map params); + + /** + * 查询指定日期范围内的预约统计 + * + * @param params 查询参数,包含startTime和endTime + * @return 预约统计列表 + */ + public List> selectOrderCountByDateRange(Map params); + + /** + * 查询指定日期和时间段的预约详情 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约订单列表 + */ + public List selectOrderDetailByMakeTimeAndHour(Map params); + + /** + * 查询用户指定日期的预约数量 + * + * @param params 查询参数,包含uid和makeTime + * @return 预约数量 + */ + public Integer selectUserOrderCountByMakeTime(Map params); + + /** + * 查询指定日期和时间段的用户预约 + * + * @param params 查询参数,包含uid、makeTime和makeHour + * @return 预约订单列表 + */ + public List selectUserOrderByMakeTimeAndHour(Map params); + + /** + * 查询预约时间冲突的订单 + * + * @param params 查询参数,包含makeTime、makeHour和excludeOrderId + * @return 冲突的订单列表 + */ + public List selectConflictingOrders(Map params); + + /** + * 查询指定日期所有时间段的预约统计 + * + * @param params 查询参数,包含makeTime + * @return 预约统计列表 + */ + public List> selectOrderCountByDate(Map params); + + /** + * 查询指定日期和时间段的可用预约数量 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 可用预约数量 + */ + public Integer selectAvailableOrderCount(Map params); + + /** + * 查询指定日期和时间段的预约用户列表 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约用户列表 + */ + public List> selectOrderUsersByMakeTimeAndHour(Map params); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceGoodsMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceGoodsMapper.java index 0c14817..3576d8c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceGoodsMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceGoodsMapper.java @@ -32,8 +32,16 @@ public interface ServiceGoodsMapper - public String selectTitlesByIds(@Param("ids") List ids); + + /** + * 按销量排序查询服务内容列表 + * + * @param limit 限制数量 + * @return 服务内容集合 + */ + public List selectServiceGoodsListBySales(@Param("limit") int limit); + /** * 查询服务内容列表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/WorkerMoneyLogMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/WorkerMoneyLogMapper.java index 580b556..8ff661a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/WorkerMoneyLogMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/WorkerMoneyLogMapper.java @@ -55,12 +55,12 @@ public interface WorkerMoneyLogMapper public int updateWorkerMoneyLogStatusIfEndlookAfterNow(); - - - - - - + /** + * 统计指定workerId且status!=0的look_money总和 + * @param workerId 师傅ID + * @return look_money总和 + */ + public BigDecimal selectWorkerLookMoneySum(Integer workerId); /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderService.java index a732899..d57cfb6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service; import java.util.List; +import java.util.Map; import com.ruoyi.system.domain.AppleDoMain.OrderApple; import com.ruoyi.system.domain.Order; @@ -83,4 +84,94 @@ public interface IOrderService * @return 订单数量 */ Integer selectOrderCountByBigtype(Long uid, Integer type); + + // ========== 预约人数查询相关方法 ========== + + /** + * 根据预约日期和时间段查询预约数量 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约数量 + */ + public Integer selectOrderCountByMakeTimeAndHour(Map params); + + /** + * 根据预约日期查询所有预约订单 + * + * @param params 查询参数,包含makeTime + * @return 预约订单列表 + */ + public List selectOrderListByMakeTime(Map params); + + /** + * 根据预约日期和时间段查询预约订单列表 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约订单列表 + */ + public List selectOrderListByMakeTimeAndHour(Map params); + + /** + * 查询指定日期范围内的预约统计 + * + * @param params 查询参数,包含startTime和endTime + * @return 预约统计列表 + */ + public List> selectOrderCountByDateRange(Map params); + + /** + * 查询指定日期和时间段的预约详情 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约订单列表 + */ + public List selectOrderDetailByMakeTimeAndHour(Map params); + + /** + * 查询用户指定日期的预约数量 + * + * @param params 查询参数,包含uid和makeTime + * @return 预约数量 + */ + public Integer selectUserOrderCountByMakeTime(Map params); + + /** + * 查询指定日期和时间段的用户预约 + * + * @param params 查询参数,包含uid、makeTime和makeHour + * @return 预约订单列表 + */ + public List selectUserOrderByMakeTimeAndHour(Map params); + + /** + * 查询预约时间冲突的订单 + * + * @param params 查询参数,包含makeTime、makeHour和excludeOrderId + * @return 冲突的订单列表 + */ + public List selectConflictingOrders(Map params); + + /** + * 查询指定日期所有时间段的预约统计 + * + * @param params 查询参数,包含makeTime + * @return 预约统计列表 + */ + public List> selectOrderCountByDate(Map params); + + /** + * 查询指定日期和时间段的可用预约数量 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 可用预约数量 + */ + public Integer selectAvailableOrderCount(Map params); + + /** + * 查询指定日期和时间段的预约用户列表 + * + * @param params 查询参数,包含makeTime和makeHour + * @return 预约用户列表 + */ + public List> selectOrderUsersByMakeTimeAndHour(Map params); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceGoodsService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceGoodsService.java index 75251fe..7c77adb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceGoodsService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceGoodsService.java @@ -51,6 +51,14 @@ public interface IServiceGoodsService public List selectServiceGoodsfrocikaList(List ids); + /** + * 按销量排序查询服务内容列表 + * + * @param limit 限制数量 + * @return 服务内容集合 + */ + public List selectServiceGoodsListBySales(int limit); + /** * 新增服务内容 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IWorkerMoneyLogService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IWorkerMoneyLogService.java index b67aa4d..11ae3ca 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IWorkerMoneyLogService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IWorkerMoneyLogService.java @@ -54,6 +54,13 @@ public interface IWorkerMoneyLogService public int updateWorkerMoneyLogStatusIfEndlookAfterNow(); + /** + * 统计指定workerId且status!=0的look_money总和 + * @param workerId 师傅ID + * @return look_money总和 + */ + public BigDecimal selectWorkerLookMoneySum(Integer workerId); + /** * 批量删除师傅金额明细 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java index 4414a39..95fd5a9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service.impl; import java.util.List; +import java.util.Map; import com.ruoyi.system.domain.AppleDoMain.OrderApple; import org.springframework.beans.factory.annotation.Autowired; @@ -101,7 +102,7 @@ public class OrderServiceImpl implements IOrderService /** * 批量删除服务订单 * - * @param ids 需要删除的服务订单主键 + * @param ids 需要删除的服务订单主键集合 * @return 结果 */ @Override @@ -121,4 +122,94 @@ public class OrderServiceImpl implements IOrderService { return orderMapper.deleteOrderById(id); } + + // ========== 预约人数查询相关方法实现 ========== + + /** + * 根据预约日期和时间段查询预约数量 + */ + @Override + public Integer selectOrderCountByMakeTimeAndHour(Map params) { + return orderMapper.selectOrderCountByMakeTimeAndHour(params); + } + + /** + * 根据预约日期查询所有预约订单 + */ + @Override + public List selectOrderListByMakeTime(Map params) { + return orderMapper.selectOrderListByMakeTime(params); + } + + /** + * 根据预约日期和时间段查询预约订单列表 + */ + @Override + public List selectOrderListByMakeTimeAndHour(Map params) { + return orderMapper.selectOrderListByMakeTimeAndHour(params); + } + + /** + * 查询指定日期范围内的预约统计 + */ + @Override + public List> selectOrderCountByDateRange(Map params) { + return orderMapper.selectOrderCountByDateRange(params); + } + + /** + * 查询指定日期和时间段的预约详情 + */ + @Override + public List selectOrderDetailByMakeTimeAndHour(Map params) { + return orderMapper.selectOrderDetailByMakeTimeAndHour(params); + } + + /** + * 查询用户指定日期的预约数量 + */ + @Override + public Integer selectUserOrderCountByMakeTime(Map params) { + return orderMapper.selectUserOrderCountByMakeTime(params); + } + + /** + * 查询指定日期和时间段的用户预约 + */ + @Override + public List selectUserOrderByMakeTimeAndHour(Map params) { + return orderMapper.selectUserOrderByMakeTimeAndHour(params); + } + + /** + * 查询预约时间冲突的订单 + */ + @Override + public List selectConflictingOrders(Map params) { + return orderMapper.selectConflictingOrders(params); + } + + /** + * 查询指定日期所有时间段的预约统计 + */ + @Override + public List> selectOrderCountByDate(Map params) { + return orderMapper.selectOrderCountByDate(params); + } + + /** + * 查询指定日期和时间段的可用预约数量 + */ + @Override + public Integer selectAvailableOrderCount(Map params) { + return orderMapper.selectAvailableOrderCount(params); + } + + /** + * 查询指定日期和时间段的预约用户列表 + */ + @Override + public List> selectOrderUsersByMakeTimeAndHour(Map params) { + return orderMapper.selectOrderUsersByMakeTimeAndHour(params); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceGoodsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceGoodsServiceImpl.java index 4e0e6b7..0491e5c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceGoodsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceGoodsServiceImpl.java @@ -72,6 +72,18 @@ public class ServiceGoodsServiceImpl implements IServiceGoodsService return serviceGoodsMapper.selectServiceGoodsfrocikaList(ids); } + + /** + * 按销量排序查询服务内容列表 + * + * @param limit 限制数量 + * @return 服务内容集合 + */ + @Override + public List selectServiceGoodsListBySales(int limit) { + return serviceGoodsMapper.selectServiceGoodsListBySales(limit); + } + /** * 新增服务内容 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WorkerMoneyLogServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WorkerMoneyLogServiceImpl.java index cad1b08..973d8f6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WorkerMoneyLogServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WorkerMoneyLogServiceImpl.java @@ -91,7 +91,10 @@ public class WorkerMoneyLogServiceImpl implements IWorkerMoneyLogService public int updateWorkerMoneyLogStatusIfEndlookAfterNow(){ return workerMoneyLogMapper.updateWorkerMoneyLogStatusIfEndlookAfterNow(); } + public BigDecimal selectWorkerLookMoneySum(Integer workerId) { + return workerMoneyLogMapper.selectWorkerLookMoneySum(workerId); + } /** * 批量删除师傅金额明细 * diff --git a/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml index 1bfde78..662ed14 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ContentMapper.xml @@ -27,6 +27,7 @@ and title like concat('%', #{title}, '%') and content = #{content} + and id = #{id} and image = #{image} order by id desc diff --git a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml index 281c18c..50213f6 100644 --- a/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/GoodsOrderMapper.xml @@ -36,6 +36,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + @@ -44,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, type, main_order_id, order_id, transaction_id,forserviceid,isforservice,isself,coupon_id,shopadresssid, uid, product_id, name, phone, address, num, total_price, good_price, service_price, pay_price, deduction, postage, pay_time, status, delivery_id, delivery_num, send_time, mark, address_id, sku, created_at, updated_at, deleted_at from goods_order + select id, type, main_order_id,returnshow, returnstatus,order_id,returntime,returnmoney,returnfinshtime,returntype,returnreason,returnfiledata,returnlogistics,returnlogisticscode,returnjson, transaction_id,forserviceid,isforservice,isself,coupon_id,shopadresssid, uid, product_id, name, phone, address, num, total_price, good_price, service_price, pay_price, deduction, postage, pay_time, status, delivery_id, delivery_num, send_time, mark, address_id, sku, created_at, updated_at, deleted_at from goods_order @@ -62,6 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and worker_id = #{workerId} and first_worker_id = #{firstWorkerId} and give_up = #{giveUp} + and ordertype = #{ordertype} + + and worker_cost = #{workerCost} and reduction_price = #{reductionPrice} and is_pause = #{isPause} @@ -149,6 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" deleted_at, cj_money, cj_paid, + ordertype, + created_at, updated_at @@ -180,6 +186,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{deletedAt}, #{cjMoney}, #{cjPaid}, + #{ordertype}, + NOW(), NOW() @@ -215,6 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" deleted_at = #{deletedAt}, cj_money = #{cjMoney}, cj_paid = #{cjPaid}, + ordertype = #{ordertype}, + + updated_at = NOW() diff --git a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml index 6560a27..6229e58 100644 --- a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml @@ -182,6 +182,9 @@ and bigtype = #{bigtype} + + AND (worker_id IS NULL OR worker_id = '') + and make_time >= #{makeTimeStart} and make_time < #{makeTimeEnd} @@ -196,7 +199,7 @@ and id in ( select b.oid from user_demand_quotation b where b.status=1) - + and is_comment =#{isComment} @@ -741,4 +744,132 @@ #{id} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/ServiceGoodsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ServiceGoodsMapper.xml index 47b52f0..5e6b889 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ServiceGoodsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ServiceGoodsMapper.xml @@ -118,6 +118,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + diff --git a/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml index 5e6a4a5..286f178 100644 --- a/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml @@ -21,6 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + @@ -39,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, uid, paytype,grouporderid,baojiaid, lastorderid,wxmoney,serviceid,servicetype,sku,addressid,maketime,attachments, yemoney, allmoney,membermoney, shopmoney, servicemoney, couponid, couponmoney, mtcode, mtmoney, type, orderid, oid, status, paytime, paycode from users_pay_befor + select id, uid, paytype,grouporderid,baojiaid,num, lastorderid,wxmoney,serviceid,servicetype,sku,addressid,maketime,attachments, yemoney, allmoney,membermoney, shopmoney, servicemoney, couponid, couponmoney, mtcode, mtmoney, type, orderid, oid, status, paytime, paycode from users_pay_befor @@ -43,6 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" oid, order_id, price, + reamk, + created_at, updated_at @@ -51,6 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{oid}, #{orderId}, #{price}, + #{reamk}, + NOW(), NOW() @@ -63,6 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" oid = #{oid}, order_id = #{orderId}, price = #{price}, + reamk = #{reamk}, + updated_at = NOW() where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml index 375aa95..0b810ba 100644 --- a/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml @@ -14,6 +14,8 @@ + + @@ -29,7 +31,7 @@ - select id, worker_id, oid, order_id, price, type, service_price, reduction_price, cr, mergin, door_price, created_at, updated_at, status, status_type, beginlook, endlook, lookday, admin_up_price, admin_up_reamk, look_money from worker_money_log + select id, worker_id, oid, order_id, price,clmoney,gongshi, type, service_price, reduction_price, cr, mergin, door_price, created_at, updated_at, status, status_type, beginlook, endlook, lookday, admin_up_price, admin_up_reamk, look_money from worker_money_log + + UPDATE worker_money_log SET status = 2 @@ -107,6 +116,8 @@ admin_up_price, admin_up_reamk, look_money, + gongshi, + clmoney, #{workerId}, @@ -129,6 +140,8 @@ #{adminUpPrice}, #{adminUpReamk}, #{lookMoney}, + #{gongshi}, + #{clmoney}, @@ -155,6 +168,8 @@ admin_up_price = #{adminUpPrice}, admin_up_reamk = #{adminUpReamk}, look_money = #{lookMoney}, + gongshi = #{gongshi}, + clmoney = #{clmoney}, where id = #{id} diff --git a/ruoyi-ui/src/api/system/GoodsOrder.js b/ruoyi-ui/src/api/system/GoodsOrder.js index 5fd6eb6..4fcfb40 100644 --- a/ruoyi-ui/src/api/system/GoodsOrder.js +++ b/ruoyi-ui/src/api/system/GoodsOrder.js @@ -82,3 +82,12 @@ export function delGoodsOrder(id) { method: 'delete' }) } + +// 处理售后申请 +export function processAfterSale(data) { + return request({ + url: '/system/GoodsOrder/processAfterSale', + method: 'post', + data: data + }) +} diff --git a/ruoyi-ui/src/views/system/AdvImg/index.vue b/ruoyi-ui/src/views/system/AdvImg/index.vue index a38f8bb..9bdb8b9 100644 --- a/ruoyi-ui/src/views/system/AdvImg/index.vue +++ b/ruoyi-ui/src/views/system/AdvImg/index.vue @@ -160,7 +160,8 @@ - + + @@ -179,9 +180,11 @@ + + + + diff --git a/ruoyi-ui/src/views/system/UserSecondaryCard/index.vue b/ruoyi-ui/src/views/system/UserSecondaryCard/index.vue index 2d5dcf0..ae7a720 100644 --- a/ruoyi-ui/src/views/system/UserSecondaryCard/index.vue +++ b/ruoyi-ui/src/views/system/UserSecondaryCard/index.vue @@ -116,19 +116,42 @@ ¥ {{ scope.row.realMoney !== undefined && scope.row.realMoney !== null ? parseFloat(scope.row.realMoney).toFixed(2) : '0.00' }} - + + + + @@ -218,10 +241,10 @@ - - - - + + + + import { listUserSecondaryCard, getUserSecondaryCard, delUserSecondaryCard, addUserSecondaryCard, updateUserSecondaryCard ,selectList,selectServiceCateList} from "@/api/system/UserSecondaryCard" - +import { getGoodsDataList } from "@/api/system/GoodsOrder" export default { name: "UserSecondaryCard", dicts: ['cika'], @@ -437,7 +460,7 @@ export default { }, getUserSecondaryCard () { - selectList().then(response => { + getGoodsDataList(1).then(response => { this.ServiceGoodsList = response.data }) }, @@ -453,21 +476,66 @@ export default { getserviceCateList(){ - selectServiceCateList().then(response => { - this.serviceCateList = response.data - }) + selectServiceCateList().then(response => { + this.serviceCateList = response.data + }) }, parseImageArray(val) { if (!val) return []; - if (Array.isArray(val)) return val; + + if (Array.isArray(val)) { + return val.map(item => { + if (typeof item === 'string') return item; + if (item && item.url) return item.url; + return ''; + }).filter(Boolean); + } + try { const arr = JSON.parse(val); - if (Array.isArray(arr)) return arr; - } catch (e) {} + if (Array.isArray(arr)) { + return arr.map(item => { + if (typeof item === 'string') return item; + if (item && item.url) return item.url; + return ''; + }).filter(Boolean); + } + } catch (e) { + // 如果不是JSON,可能是单个图片URL + if (typeof val === 'string' && val.trim()) { + return [val.trim()]; + } + } + return []; }, + handleImageError(event) { + // 图片加载失败时的处理 + const imgElement = event.target; + imgElement.style.display = 'none'; + imgElement.onerror = null; // 防止重复触发 + + // 在图片位置显示错误提示 + const errorDiv = document.createElement('div'); + errorDiv.className = 'image-error'; + errorDiv.innerHTML = ''; + errorDiv.style.cssText = ` + width: ${imgElement.width}px; + height: ${imgElement.height}px; + display: flex; + align-items: center; + justify-content: center; + background: #f5f7fa; + border: 1px dashed #c0c4cc; + border-radius: 4px; + color: #909399; + font-size: 16px; + `; + imgElement.parentNode.insertBefore(errorDiv, imgElement); + }, + /** 修改按钮操作 */ handleUpdate(row) { @@ -646,4 +714,67 @@ export default { .status-tag { font-weight: bold; } +.image-container { + display: flex; + flex-direction: column; + align-items: center; + gap: 4px; +} +.image-row { + display: flex; + flex-wrap: wrap; + gap: 4px; + justify-content: center; + align-items: center; +} +.carousel-container { + display: flex; + flex-direction: column; + align-items: center; + gap: 4px; +} +.carousel-row { + display: flex; + flex-wrap: nowrap; + gap: 6px; + justify-content: flex-start; + align-items: center; + overflow-x: auto; + max-width: 280px; + padding: 2px; + scrollbar-width: thin; + scrollbar-color: #c0c4cc transparent; +} +.carousel-row::-webkit-scrollbar { + height: 4px; +} +.carousel-row::-webkit-scrollbar-track { + background: transparent; +} +.carousel-row::-webkit-scrollbar-thumb { + background: #c0c4cc; + border-radius: 2px; +} +.carousel-row::-webkit-scrollbar-thumb:hover { + background: #909399; +} +.table-image { + border-radius: 4px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + transition: transform 0.2s ease; + flex-shrink: 0; +} +.table-image:hover { + transform: scale(1.05); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); +} +.no-image { + color: #909399; + font-style: italic; +} +.image-count { + font-size: 12px; + color: #909399; + text-align: center; +} diff --git a/ruoyi-ui/src/views/system/UsersWorker/index.vue b/ruoyi-ui/src/views/system/UsersWorker/index.vue index 024148d..855e189 100644 --- a/ruoyi-ui/src/views/system/UsersWorker/index.vue +++ b/ruoyi-ui/src/views/system/UsersWorker/index.vue @@ -213,10 +213,22 @@ + + + -