Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
d367b6c1
Commit
d367b6c1
authored
Jul 18, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化订单查询接口
parent
a97beab2
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
32 deletions
+96
-32
SOrderController.java
...in/java/share/web/controller/system/SOrderController.java
+1
-0
SOrder.java
share-system/src/main/java/share/system/domain/SOrder.java
+6
-0
SConsumerCouponMapper.java
.../main/java/share/system/mapper/SConsumerCouponMapper.java
+2
-0
SOrderMapper.java
...ystem/src/main/java/share/system/mapper/SOrderMapper.java
+2
-1
ISConsumerCouponService.java
...in/java/share/system/service/ISConsumerCouponService.java
+2
-0
SConsumerCouponServiceImpl.java
...share/system/service/impl/SConsumerCouponServiceImpl.java
+6
-2
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+14
-25
SConsumerCouponMapper.xml
...rc/main/resources/mapper/system/SConsumerCouponMapper.xml
+9
-0
SOrderMapper.xml
...-system/src/main/resources/mapper/system/SOrderMapper.xml
+54
-4
No files found.
share-admin/src/main/java/share/web/controller/system/SOrderController.java
View file @
d367b6c1
...
@@ -43,6 +43,7 @@ public class SOrderController extends BaseController
...
@@ -43,6 +43,7 @@ public class SOrderController extends BaseController
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfoVo
list
(
SOrder
sOrder
)
public
TableDataInfoVo
list
(
SOrder
sOrder
)
{
{
startPage
();
return
sOrderService
.
pageList
(
sOrder
);
return
sOrderService
.
pageList
(
sOrder
);
}
}
...
...
share-system/src/main/java/share/system/domain/SOrder.java
View file @
d367b6c1
...
@@ -170,4 +170,10 @@ public class SOrder extends BaseEntity
...
@@ -170,4 +170,10 @@ public class SOrder extends BaseEntity
@TableField
(
select
=
false
)
@TableField
(
select
=
false
)
private
Date
endPayTime
;
private
Date
endPayTime
;
@TableField
(
select
=
false
)
private
Integer
pageNum
;
@TableField
(
select
=
false
)
private
Integer
pageSize
;
}
}
share-system/src/main/java/share/system/mapper/SConsumerCouponMapper.java
View file @
d367b6c1
...
@@ -73,4 +73,6 @@ public interface SConsumerCouponMapper extends BaseMapper<SConsumerCoupon>
...
@@ -73,4 +73,6 @@ public interface SConsumerCouponMapper extends BaseMapper<SConsumerCoupon>
List
<
SConsumerCoupon
>
queryList
();
List
<
SConsumerCoupon
>
queryList
();
int
removeByIdList
(
@Param
(
"couponIds"
)
List
<
Long
>
expiredCoupons
);
int
removeByIdList
(
@Param
(
"couponIds"
)
List
<
Long
>
expiredCoupons
);
List
<
SConsumerCoupon
>
selectOrderList
();
}
}
share-system/src/main/java/share/system/mapper/SOrderMapper.java
View file @
d367b6c1
...
@@ -3,6 +3,7 @@ package share.system.mapper;
...
@@ -3,6 +3,7 @@ package share.system.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
share.system.domain.SOrder
;
import
share.system.domain.SOrder
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -71,5 +72,5 @@ public interface SOrderMapper extends BaseMapper<SOrder>
...
@@ -71,5 +72,5 @@ public interface SOrderMapper extends BaseMapper<SOrder>
List
<
SOrder
>
selectSOrderByStoreIdAndMaxTime
(
SOrder
order
);
List
<
SOrder
>
selectSOrderByStoreIdAndMaxTime
(
SOrder
order
);
SOrder
sumPrice
(
SOrder
sOrder
);
HashMap
<
String
,
Object
>
sumPrice
(
SOrder
sOrder
);
}
}
share-system/src/main/java/share/system/service/ISConsumerCouponService.java
View file @
d367b6c1
...
@@ -91,4 +91,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
...
@@ -91,4 +91,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
SConsumerCoupon
selectSConsumerCouponByCode
(
String
code
);
SConsumerCoupon
selectSConsumerCouponByCode
(
String
code
);
List
<
SConsumerCoupon
>
storeNameByIds
(
List
<
Long
>
longs
);
List
<
SConsumerCoupon
>
storeNameByIds
(
List
<
Long
>
longs
);
List
<
SConsumerCoupon
>
selectOrderList
();
}
}
share-system/src/main/java/share/system/service/impl/SConsumerCouponServiceImpl.java
View file @
d367b6c1
...
@@ -593,14 +593,18 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
...
@@ -593,14 +593,18 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Override
@Override
public
List
<
SConsumerCoupon
>
storeNameByIds
(
List
<
Long
>
longs
)
{
public
List
<
SConsumerCoupon
>
storeNameByIds
(
List
<
Long
>
longs
)
{
LambdaQueryWrapper
<
SConsumerCoupon
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
SConsumerCoupon
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
select
(
SConsumerCoupon:
:
getId
,
SConsumerCoupon:
:
getName
,
SConsumerCoupon:
:
getCouponPayPrice
,
queryWrapper
.
select
(
SConsumerCoupon:
:
getId
,
SConsumerCoupon:
:
getName
);
SConsumerCoupon:
:
getPlatformType
,
SConsumerCoupon:
:
getDealgroupId
,
SConsumerCoupon:
:
getTiktokSkuId
);
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
longs
))
{
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
longs
))
{
queryWrapper
.
in
(
SConsumerCoupon:
:
getId
,
longs
);
queryWrapper
.
in
(
SConsumerCoupon:
:
getId
,
longs
);
}
}
return
this
.
list
(
queryWrapper
);
return
this
.
list
(
queryWrapper
);
}
}
@Override
public
List
<
SConsumerCoupon
>
selectOrderList
()
{
return
baseMapper
.
selectOrderList
();
}
private
void
extracted
(
SConsumerCoupon
item
,
BigDecimal
bigDecimal
,
SRoom
byId
,
BigDecimal
subtract
,
SStore
sStore
)
{
private
void
extracted
(
SConsumerCoupon
item
,
BigDecimal
bigDecimal
,
SRoom
byId
,
BigDecimal
subtract
,
SStore
sStore
)
{
//计算价格
//计算价格
BigDecimal
multiply
=
bigDecimal
.
multiply
(
byId
.
getPrice
());
BigDecimal
multiply
=
bigDecimal
.
multiply
(
byId
.
getPrice
());
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
d367b6c1
...
@@ -15,6 +15,7 @@ import com.cronutils.model.definition.CronDefinitionBuilder;
...
@@ -15,6 +15,7 @@ import com.cronutils.model.definition.CronDefinitionBuilder;
import
com.cronutils.model.time.ExecutionTime
;
import
com.cronutils.model.time.ExecutionTime
;
import
com.cronutils.parser.CronParser
;
import
com.cronutils.parser.CronParser
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
...
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
share.common.constant.Constants
;
import
share.common.constant.Constants
;
import
share.common.constant.HttpStatus
;
import
share.common.core.page.PageDomain
;
import
share.common.core.page.PageDomain
;
import
share.common.core.page.TableDataInfo
;
import
share.common.core.page.TableDataInfo
;
import
share.common.core.page.TableSupport
;
import
share.common.core.page.TableSupport
;
...
@@ -352,16 +354,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -352,16 +354,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
@Override
public
TableDataInfoVo
pageList
(
SOrder
sOrder
)
{
public
TableDataInfoVo
pageList
(
SOrder
sOrder
)
{
List
<
SOrder
>
sOrders
=
selectSOrderList
(
sOrder
);
List
<
SOrder
>
sOrders
=
selectSOrderList
(
sOrder
);
TableDataInfoVo
tableDataInfo
=
new
TableDataInfoVo
();
tableDataInfo
.
setCode
(
HttpStatus
.
SUCCESS
);
tableDataInfo
.
setMsg
(
"查询成功"
);
tableDataInfo
.
setRows
(
sOrders
);
tableDataInfo
.
setTotal
(
new
PageInfo
(
sOrders
).
getTotal
());
List
<
SOrderVo
>
sOrderVos
=
convertDosToVos
(
sOrders
);
List
<
SOrderVo
>
sOrderVos
=
convertDosToVos
(
sOrders
);
SOrder
summedPrice
=
baseMapper
.
sumPrice
(
sOrder
);
HashMap
<
String
,
Object
>
summedPrice
=
baseMapper
.
sumPrice
(
sOrder
);
//优惠卷售卖总金额
//优惠卷售卖总金额
final
BigDecimal
[]
totalSalesAmount
=
{
new
BigDecimal
(
"0.00"
)};
final
BigDecimal
[]
totalSalesAmount
=
{
new
BigDecimal
(
"0.00"
)};
//申请退款总金额
Map
<
Long
,
SConsumerCoupon
>
couponMap
=
consumerCouponService
.
selectOrderList
()
final
BigDecimal
[]
totalRefundAmount
=
{
new
BigDecimal
(
"0.00"
)};
//实际退款总金额
final
BigDecimal
[]
totalRealRefundAmount
=
{
new
BigDecimal
(
"0.00"
)};
Map
<
Long
,
SConsumerCoupon
>
couponMap
=
consumerCouponService
.
storeNameByIds
(
sOrders
.
stream
().
map
(
SOrder:
:
getCouponId
).
distinct
().
collect
(
Collectors
.
toList
()))
.
stream
().
collect
(
Collectors
.
toMap
(
SConsumerCoupon:
:
getId
,
s
->
s
));
.
stream
().
collect
(
Collectors
.
toMap
(
SConsumerCoupon:
:
getId
,
s
->
s
));
if
(
CollectionUtils
.
isNotEmpty
(
sOrderVos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
sOrderVos
))
{
sOrderVos
.
stream
().
forEach
(
item
->
{
sOrderVos
.
stream
().
forEach
(
item
->
{
...
@@ -378,29 +382,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -378,29 +382,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
totalSalesAmount
[
0
]
=
totalSalesAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
userCoupon
.
getCouponPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
userCoupon
.
getCouponPayPrice
());
totalSalesAmount
[
0
]
=
totalSalesAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
userCoupon
.
getCouponPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
userCoupon
.
getCouponPayPrice
());
}
}
}
}
if
(
item
.
getPayStatus
().
equals
(
YesNoEnum
.
yes
.
getIndex
())
&&
item
.
getRefundStatus
().
equals
(
RefundStatusEnum
.
REFUNDED
.
getCode
()))
{
totalRefundAmount
[
0
]
=
totalRefundAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
item
.
getPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getPayPrice
());
totalRealRefundAmount
[
0
]
=
totalRealRefundAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
item
.
getRefundPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getRefundPrice
());
}
});
});
}
}
sOrderVos
.
sort
(
Comparator
.
comparing
(
SOrderVo:
:
getCreateTime
).
reversed
());
sOrderVos
.
sort
(
Comparator
.
comparing
(
SOrderVo:
:
getCreateTime
).
reversed
());
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
tableDataInfo
.
setTotalAmount
((
BigDecimal
)
summedPrice
.
get
(
"totalPrice"
));
Integer
pageNum
=
pageDomain
.
getPageNum
();
tableDataInfo
.
setAmount
((
BigDecimal
)
summedPrice
.
get
(
"payPrice"
));
Integer
pageSize
=
pageDomain
.
getPageSize
();
int
start
=
(
pageNum
-
1
)
*
pageSize
;
int
end
=
Math
.
min
(
start
+
pageSize
,
sOrderVos
.
size
());
List
<
SOrderVo
>
pagedList
=
sOrderVos
.
subList
(
start
,
end
);
TableDataInfoVo
tableDataInfo
=
new
TableDataInfoVo
();
tableDataInfo
.
setRows
(
pagedList
);
tableDataInfo
.
setTotal
(
sOrderVos
.
size
());
tableDataInfo
.
setCode
(
200
);
tableDataInfo
.
setMsg
(
"查询成功"
);
tableDataInfo
.
setTotalAmount
(
summedPrice
.
getTotalPrice
());
tableDataInfo
.
setAmount
(
summedPrice
.
getPayPrice
());
tableDataInfo
.
setTotalSalesAmount
(
totalSalesAmount
[
0
]);
tableDataInfo
.
setTotalSalesAmount
(
totalSalesAmount
[
0
]);
tableDataInfo
.
setTotalRefundAmount
(
totalRefundAmount
[
0
]
);
tableDataInfo
.
setTotalRefundAmount
(
(
BigDecimal
)
summedPrice
.
get
(
"totalRealRefundAmount"
)
);
tableDataInfo
.
setTotalRealRefundAmount
(
totalRealRefundAmount
[
0
]
);
tableDataInfo
.
setTotalRealRefundAmount
(
(
BigDecimal
)
summedPrice
.
get
(
"refundPrice"
)
);
return
tableDataInfo
;
return
tableDataInfo
;
}
}
...
...
share-system/src/main/resources/mapper/system/SConsumerCouponMapper.xml
View file @
d367b6c1
...
@@ -164,6 +164,15 @@
...
@@ -164,6 +164,15 @@
<select
id=
"queryList"
resultType=
"share.system.domain.SConsumerCoupon"
>
<select
id=
"queryList"
resultType=
"share.system.domain.SConsumerCoupon"
>
<include
refid=
"selectSConsumerCouponVo"
/>
<include
refid=
"selectSConsumerCouponVo"
/>
</select>
</select>
<select
id=
"selectOrderList"
resultType=
"share.system.domain.SConsumerCoupon"
>
select id,
dealgroup_id,
tiktok_sku_id,
coupon_pay_price,
platform_type
from s_consumer_coupon
where id in (select coupon_id from s_order)
</select>
<insert
id=
"insertSConsumerCoupon"
parameterType=
"SConsumerCoupon"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<insert
id=
"insertSConsumerCoupon"
parameterType=
"SConsumerCoupon"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into s_consumer_coupon
insert into s_consumer_coupon
...
...
share-system/src/main/resources/mapper/system/SOrderMapper.xml
View file @
d367b6c1
...
@@ -90,7 +90,46 @@
...
@@ -90,7 +90,46 @@
</sql>
</sql>
<select
id=
"selectSOrderList"
parameterType=
"SOrder"
resultMap=
"SOrderResult"
>
<select
id=
"selectSOrderList"
parameterType=
"SOrder"
resultMap=
"SOrderResult"
>
<include
refid=
"selectSOrderVo"
/>
select id,
order_no,
out_trade_no,
historical_order_no,
order_type,
pay_type,
pay_status,
store_id,
room_id,
consumer_id,
consumer_name,
consumer_phone,
pack_id,
pack_price,
coupon_id,
coupon_price,
total_price,
pay_price,
duration,
balance,
discount_ratio,
pay_time,
time_long,
pre_start_date,
pre_end_date,
start_date,
end_date,
status,
refund_status,
refund_reason,
refund_reason_time,
refund_price,
is_delete,
create_by,
create_time,
update_by,
update_time,
arrival_time,
remark
from s_order
where pay_status = 1
where pay_status = 1
and is_delete = 0
and is_delete = 0
<if
test=
"orderNo != null and orderNo != ''"
>
and order_no = #{orderNo}
</if>
<if
test=
"orderNo != null and orderNo != ''"
>
and order_no = #{orderNo}
</if>
...
@@ -150,6 +189,7 @@
...
@@ -150,6 +189,7 @@
<if
test=
"arrivalTime != null and arrivalTime != ''"
>
and arrival_time = #{arrivalTime}
</if>
<if
test=
"arrivalTime != null and arrivalTime != ''"
>
and arrival_time = #{arrivalTime}
</if>
<if
test=
"remark != null and remark != ''"
>
and remark = #{remark}
</if>
<if
test=
"remark != null and remark != ''"
>
and remark = #{remark}
</if>
ORDER BY create_time DESC
ORDER BY create_time DESC
LIMIT #{pageNum}, #{pageSize} ;
</select>
</select>
<select
id=
"selectSOrderById"
parameterType=
"Long"
resultMap=
"SOrderResult"
>
<select
id=
"selectSOrderById"
parameterType=
"Long"
resultMap=
"SOrderResult"
>
...
@@ -267,9 +307,19 @@
...
@@ -267,9 +307,19 @@
and create_time >= #{createTime}
and create_time >= #{createTime}
group by store_id) t on t.id = s.id
group by store_id) t on t.id = s.id
</select>
</select>
<select
id=
"sumPrice"
resultType=
"share.system.domain.SOrder"
>
<select
id=
"sumPrice"
resultType=
"java.util.HashMap"
>
select sum(total_price) as totalPrice,
select sum(ifnull(total_price,0)) as totalPrice,
sum(pay_price) as payPrice
sum(ifnull(pay_price,0)) as payPrice ,
SUM( CASE WHEN
pay_status=1 AND refund_status = 3
THEN ifnull( pay_price,0) ELSE 0 END
) AS totalRealRefundAmount,
SUM( CASE WHEN
pay_status=1 AND refund_status = 3
THEN ifnull(refund_price,0) ELSE 0 END
) AS refundPrice
from s_order
from s_order
where pay_status = 1
where pay_status = 1
and is_delete = 0
and is_delete = 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment