Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
caosy
/
fun-golf-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f9773570
authored
Dec 15, 2017
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify the vouch error when pay
parent
7bfa3066
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
20 deletions
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherDao.java
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
src/main/java/com/ctrip/fun/golf/service/order/AbstractOrderService.java
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherDao.java
View file @
f9773570
...
...
@@ -71,7 +71,6 @@ public class VoucherDao extends GenericHibernateDao<Voucher, Integer> {
return
this
.
getEntities
(
hsql
);
}
@Deprecated
public
int
useVoucher
(
String
ids
,
Long
orderNo
)
{
String
sql
=
"update Voucher set used="
+
VourcherStatusEnum
.
USED
.
getValue
()
+
" , useDate=now() , orderNo="
+
orderNo
+
" where used=0 and id in ("
...
...
@@ -79,6 +78,11 @@ public class VoucherDao extends GenericHibernateDao<Voucher, Integer> {
Query
query
=
getSession
().
createQuery
(
sql
);
return
query
.
executeUpdate
();
}
public
int
useVoucher
(
String
id
,
BigDecimal
amount
){
String
hql
=
"update Voucher set amount="
+
amount
+
" where used=0 and id ="
+
id
;
Query
query
=
getSession
().
createQuery
(
hql
);
return
query
.
executeUpdate
();
}
public
int
useVoucher
(
String
id
,
Long
orderNo
,
BigDecimal
amount
){
String
hql
=
"update Voucher set used="
+
VourcherStatusEnum
.
USED
.
getValue
()
+
" , useDate=now() , orderNo="
+
orderNo
+
",amount="
+
amount
+
" where used=0 and id ="
+
id
;
...
...
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
View file @
f9773570
...
...
@@ -160,7 +160,7 @@ public class VoucherService {
* @param i
* @param integer
*/
@Deprecated
/*
@Deprecated
public void useVoucher(int count, long orderNO, String voucherIds, Integer resourceId, Integer productId, Date playDate ) {
String voucherIdArr[] = voucherIds.split(",");
int useCount = 0;
...
...
@@ -185,7 +185,7 @@ public class VoucherService {
throw new VoucherException(-10, "抵用劵校验不通过");
}
}
}
*/
/**
* 校验抵用劵是否可以使用,事务传播级别为REQUEST_NEW
...
...
@@ -194,35 +194,51 @@ public class VoucherService {
* @param orderNO
* @param voucherIds
*/
public
void
userVoucher
(
int
count
,
long
orderNO
,
String
voucherIds
)
{
/*
public void userVoucher(int count, long orderNO, String voucherIds) {
String voucherIdArr[] = voucherIds.split(",");
int useCount = 0;
for(String id :voucherIdArr){
Voucher voucher = voucherDao.findById(Integer.parseInt(id));
VoucherRule rule = voucherRuleDao.findById(voucher.getRuleId());
Order order = orderDao.getOrderByOrderNo(orderNO);
List
<
EventActivityOrderItem
>
eventActivityOrderItemList
=
eventActivityOrderItemDao
.
getOrderItemByOrderId
(
order
.
getOrderId
());
if
(
eventActivityOrderItemList
.
size
()>
0
){
EventActivityOrderItem
item
=
eventActivityOrderItemList
.
get
(
0
);
MultipleCourseConditionBean
bean
=
null
;
try
{
bean
=
(
MultipleCourseConditionBean
)
JsonUtil
.
readValue
(
rule
.
getConditionJson
(),
Class
.
forName
(
rule
.
getConditionBean
()));
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
CourseRuleConditionBaseBean
t
=
new
CourseRuleConditionBaseBean
();
t
.
setPlayDate
(
item
.
getPlayDate
());
t
.
setResourceId
(
item
.
getResourceId
());
t
.
setProductId
(
item
.
getCourseProductId
());
BigDecimal
amount
=
bean
.
getEnableAmount
(
t
);
if(rule != null && 1== rule.getMultiple()){
List<EventActivityOrderItem> eventActivityOrderItemList = eventActivityOrderItemDao.getOrderItemByOrderId(order.getOrderId());
if(eventActivityOrderItemList.size()>0){
EventActivityOrderItem item = eventActivityOrderItemList.get(0);
MultipleCourseConditionBean bean = null;
try {
bean = (MultipleCourseConditionBean)JsonUtil.readValue(rule.getConditionJson(), Class.forName(rule.getConditionBean()));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
CourseRuleConditionBaseBean t = new CourseRuleConditionBaseBean();
t.setPlayDate(item.getPlayDate());
t.setResourceId(item.getResourceId());
t.setProductId(item.getCourseProductId());
BigDecimal amount = bean.getEnableAmount(t);
useCount += voucherDao.useVoucher(id, orderNO,amount);
}
useCount
+=
voucherDao
.
useVoucher
(
id
,
orderNO
,
amount
);
}else{
//只更新y
useCount = voucherDao.useVoucher(voucherIds, orderNO);
break;
}
}
if (count != useCount) {
throw new VoucherException(-10, "抵用劵校验不通过");
}
}*/
public
void
userVoucher
(
int
count
,
long
orderNO
,
String
voucherIds
)
{
int
useCount
=
voucherDao
.
useVoucher
(
voucherIds
,
orderNO
);
if
(
count
!=
useCount
)
{
throw
new
VoucherException
(-
10
,
"抵用劵校验不通过"
);
}
}
/**
...
...
src/main/java/com/ctrip/fun/golf/service/order/AbstractOrderService.java
View file @
f9773570
...
...
@@ -933,6 +933,19 @@ public abstract class AbstractOrderService<H extends AbstractOrderBean<T>, T> ex
order
.
setOrderUserStatus
(
UserOrderStatusEnum
.
WAITING_PAY
.
getValue
());
getOrderDao
().
update
(
order
);
placeOrderResponseBean
.
setPayParameter
(
JsonUtil
.
writeValueAsString
(
result
.
getBody
()));
//为了多球场抵用券,所以在这一步就更新bsc_voucher中的amount
if
(
order
.
getVoucherAmount
().
doubleValue
()
>
0
)
{
List
<
VoucherItemBean
>
beanlist
=
abstractOrderBean
.
getVoucherList
();
int
usedCount
=
0
;
if
(
beanlist
.
size
()>
0
){
for
(
VoucherItemBean
bean:
beanlist
){
usedCount
+=
voucherDao
.
useVoucher
(
bean
.
getId
()+
""
,
bean
.
getAmount
());
}
if
(
usedCount
!=
order
.
getVoucherCount
()){
throw
new
OrderException
(-
100
,
"您的抵用劵使用错误"
);
}
}
}
}
else
{
// 注释掉发起支付的时候失败,导致库存多余的问题
...
...
@@ -957,9 +970,13 @@ public abstract class AbstractOrderService<H extends AbstractOrderBean<T>, T> ex
}
if
(
order
.
getVoucherAmount
().
doubleValue
()
>
0
)
{
List
<
VoucherItemBean
>
beanlist
=
abstractOrderBean
.
getVoucherList
();
int
usedCount
=
0
;
if
(
beanlist
.
size
()>
0
){
for
(
VoucherItemBean
bean:
beanlist
){
voucherDao
.
useVoucher
(
bean
.
getId
()+
""
,
order
.
getOrderNo
(),
bean
.
getAmount
());
usedCount
+=
voucherDao
.
useVoucher
(
bean
.
getId
()+
""
,
order
.
getOrderNo
(),
bean
.
getAmount
());
}
if
(
usedCount
!=
order
.
getVoucherCount
()){
throw
new
OrderException
(-
100
,
"您的抵用劵使用错误"
);
}
}
}
...
...
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