Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
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
huluobin
gogirl-miniapp-backend
Commits
14f571bf
Commit
14f571bf
authored
Mar 18, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3a7093bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
49 deletions
+72
-49
MarketServiceImpl.java
...com/gogirl/application/market/impl/MarketServiceImpl.java
+5
-41
MvcInterceptorConfig.java
...om/gogirl/infrastructure/config/MvcInterceptorConfig.java
+1
-0
CustomerIdLock.java
...a/com/gogirl/infrastructure/util/lock/CustomerIdLock.java
+56
-0
CouponController.java
...ain/java/com/gogirl/interfaces/user/CouponController.java
+9
-7
XcxController.java
src/main/java/com/gogirl/interfaces/xcx/XcxController.java
+1
-1
No files found.
src/main/java/com/gogirl/application/market/impl/MarketServiceImpl.java
View file @
14f571bf
...
...
@@ -290,7 +290,11 @@ public class MarketServiceImpl implements MarketService {
OrderManage
orderManage
=
orderManageMapper
.
selectById
(
orderId
);
List
<
OrderServe
>
orderServeList
=
orderServeMapper
.
selectList
(
new
LambdaQueryWrapper
<
OrderServe
>().
eq
(
OrderServe:
:
getOrderId
,
orderId
));
orderManage
.
setListOrderServer
(
orderServeList
);
// orderServeList.forEach(orderServe -> orderServe.setBindCoupon(2));
orderServeList
.
forEach
(
orderServe
->
{
orderServe
.
setBindInnerCoupon
(
2
);
orderServe
.
setBindTimesCard
(
2
);
orderServe
.
setBindOuterCoupon
(
2
);
});
//1.改价结算
//总支付金额等于 总价格+总改价
...
...
@@ -307,20 +311,6 @@ public class MarketServiceImpl implements MarketService {
orderServe
.
setAchievement
(
orderServe
.
getPrice
().
add
(
orderServe
.
getServeChangePrice
()));
});
// //2.闲时折扣结算
// orderManage.getListOrderServer().forEach(orderServe -> {
// //服务折扣金额等于闲时折扣金额
// orderServe.setDiscountPrice(orderServe.getLeisureDiscountPrice());
// //服务支付金额-闲时折扣金额
// orderServe.setPayPrice(orderServe.getPayPrice().subtract(orderServe.getLeisureDiscountPrice()));
// //总支付金额- 闲时折扣基恩
// orderManage.setTotalPaymentAmount(orderManage.getTotalPaymentAmount().subtract(orderServe.getLeisureDiscountPrice()));
// //总折扣金额 + = 闲时折扣金额
// orderManage.setDiscountPrice(orderManage.getDiscountPrice().add(orderServe.getLeisureDiscountPrice()));
// });
//3.次卡
if
(
ListUtil
.
isNotEmpty
(
timesCardUsedRecordList
))
{
//次卡使用记录
...
...
@@ -371,25 +361,6 @@ public class MarketServiceImpl implements MarketService {
orderServe
.
setBindTimesCard
(
1
);
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
// 在从服务上折扣的钱
// BigDecimal leftServeDiscountAmount = timesCardUsedRecord.getDiscountAmount().subtract(serveDiscountAmount);
// if (supportServe != null && leftServeDiscountAmount.compareTo(BigDecimal.ZERO) > 0) {
//
// BigDecimal actualSupportServeDiscountAmount = leftServeDiscountAmount.min(supportServe.getPayPrice());
// TimesCardOrderServeDetail supportTimesCardOrderServeDetail = new TimesCardOrderServeDetail();
// supportTimesCardOrderServeDetail.setDiscountAmount(actualSupportServeDiscountAmount);
// supportTimesCardOrderServeDetail.setOrderServeId(supportServe.getId());
// supportTimesCardOrderServeDetail.setOrderId(orderId);
// supportTimesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
// //业绩
// supportTimesCardOrderServeDetail.setAchievement(BigDecimal.ZERO);
// timesCardOrderServeDetailMapper.insert(supportTimesCardOrderServeDetail);
//
// //订单折扣金额更新
// supportServe.setBindCoupon(1);
// supportServe.addDiscountPrice(actualSupportServeDiscountAmount);
// orderManage.addDiscountPrice(actualSupportServeDiscountAmount);
// }
//更新使用次数
TimesCardCustomerRelevance
timesCardCustomerRelevance
=
timesCardCustomerRelevanceService
.
getById
(
timesCardUsedRecord
.
getCardRelevanceCustomerId
());
...
...
@@ -401,8 +372,6 @@ public class MarketServiceImpl implements MarketService {
timesCardCustomerRelevanceService
.
updateById
(
timesCardCustomerRelevance
);
}
else
{
throw
new
RRException
(
"次卡冲突"
);
// timesCardUsedRecord.setOrderId(null);
// timesCardUsedRecordMapper.updateById(timesCardUsedRecord);
}
});
...
...
@@ -499,8 +468,6 @@ public class MarketServiceImpl implements MarketService {
// }
}
else
{
throw
new
RRException
(
"外部券冲突"
);
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceMapper.updateById(couponCustomerRelevance);
}
});
...
...
@@ -586,9 +553,6 @@ public class MarketServiceImpl implements MarketService {
}
//内部券抵扣不了
else
{
// couponCustomerRelevance.setState(null);
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceService.updateById(couponCustomerRelevance);
throw
new
RRException
(
"内部券冲突"
);
}
});
...
...
src/main/java/com/gogirl/infrastructure/config/MvcInterceptorConfig.java
View file @
14f571bf
...
...
@@ -30,6 +30,7 @@ public class MvcInterceptorConfig extends WebMvcConfigurationSupport {
//登陆
.
excludePathPatterns
(
"/customer/message/loginLog"
)
.
excludePathPatterns
(
"/customer/message/pageIn"
)
.
excludePathPatterns
(
"/customer/message/logoutLog"
)
.
excludePathPatterns
(
"/customer/xcx/login"
)
.
excludePathPatterns
(
"/customer/csrf"
)
...
...
src/main/java/com/gogirl/infrastructure/util/lock/CustomerIdLock.java
0 → 100644
View file @
14f571bf
package
com
.
gogirl
.
infrastructure
.
util
.
lock
;
import
java.util.HashMap
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
* * 分段锁,系统提供一定数量的原始锁,根据传入用户id值获取对应的锁并加锁 * 注意:要锁的用户id值如果发生改变,有可能导致锁无法成功释放!!!
*/
public
class
CustomerIdLock
{
private
final
static
HashMap
<
Integer
,
ReentrantLock
>
lockMap
=
new
HashMap
<>();
private
Integer
segments
=
500
;
// 默认分段数量
private
CustomerIdLock
()
{
init
(
null
,
false
);
}
private
CustomerIdLock
(
Integer
counts
,
boolean
fair
)
{
init
(
counts
,
fair
);
}
/*静态内部类实现单例*/
public
static
final
CustomerIdLock
getInsatance
()
{
return
SingletonHolder
.
instance
;
}
private
void
init
(
Integer
counts
,
boolean
fair
)
{
if
(
counts
!=
null
)
{
segments
=
counts
;
}
for
(
int
i
=
0
;
i
<
segments
;
i
++)
{
lockMap
.
put
(
i
,
new
ReentrantLock
(
fair
));
}
}
public
void
lock
(
int
key
)
{
ReentrantLock
lock
=
lockMap
.
get
(
key
%
segments
);
lock
.
lock
();
}
public
void
unlock
(
int
key
)
{
ReentrantLock
lock
=
lockMap
.
get
(
key
%
segments
);
lock
.
unlock
();
}
@Override
public
String
toString
()
{
return
"SegmentLock [segments="
+
segments
+
", lockMap="
+
lockMap
+
"]"
;
}
/*静态内部类实现单例*/
private
static
class
SingletonHolder
{
private
static
final
CustomerIdLock
instance
=
new
CustomerIdLock
(
null
,
true
);
}
}
src/main/java/com/gogirl/interfaces/user/CouponController.java
View file @
14f571bf
...
...
@@ -3,11 +3,9 @@ package com.gogirl.interfaces.user;
import
com.gogirl.application.market.CouponService
;
import
com.gogirl.application.xcx.GogirlTokenService
;
import
com.gogirl.domain.market.coupon.Coupon
;
import
com.gogirl.domain.xcx.GogirlToken
;
import
com.gogirl.infrastructure.common.base.JsonResult
;
import
com.gogirl.infrastructure.common.util.StringUtils
;
import
com.gogirl.infrastructure.util.SessionUtils
;
import
com.go
ogle.common.collect.Lists
;
import
com.go
girl.infrastructure.util.lock.CustomerIdLock
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.AllArgsConstructor
;
...
...
@@ -15,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@Api
(
tags
=
{
"优惠券配置接口"
},
value
=
"优惠券配置接口"
)
...
...
@@ -47,8 +44,14 @@ public class CouponController {
@PostMapping
(
"/customer/sendNewCustomerCouponXcx"
)
public
JsonResult
<
Coupon
>
sendNewCustomerCouponXcx
(
String
token
)
{
Integer
customerId
=
SessionUtils
.
getCustomerId
();
Coupon
coupon
=
couponService
.
sendNewCustomerCouponXcx
(
customerId
);
return
JsonResult
.
success
(
coupon
);
CustomerIdLock
lock
=
CustomerIdLock
.
getInsatance
();
try
{
lock
.
lock
(
customerId
);
Coupon
coupon
=
couponService
.
sendNewCustomerCouponXcx
(
customerId
);
return
JsonResult
.
success
(
coupon
);
}
finally
{
lock
.
unlock
(
customerId
);
}
}
@ApiOperation
(
value
=
"小程序发券"
)
...
...
@@ -64,7 +67,6 @@ public class CouponController {
}
@ApiOperation
(
value
=
"美甲师根据订单号查询可用外部券"
)
@GetMapping
(
"/technician/getOrderExternalCoupon"
)
public
JsonResult
<
List
<
Coupon
>>
getOrderExternalCoupon
(
@RequestHeader
String
token
,
...
...
src/main/java/com/gogirl/interfaces/xcx/XcxController.java
View file @
14f571bf
...
...
@@ -79,7 +79,7 @@ public class XcxController {
@RequestParam
String
iv
)
throws
InvalidAlgorithmParameterException
{
log
.
info
(
"手机号码授权,用户信息:"
);
Customer
customer
=
customerService
.
authorizedPhone
(
token
,
encryptedData
,
iv
);
return
JsonResult
.
success
();
return
JsonResult
.
success
(
customer
);
}
@GetMapping
(
"/customer/xcx/getUserInfo"
)
...
...
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