Commit d25f8093 by Huang Linyu

Merge branch 'release' of 192.168.10.6:caosy/fun-golf-service into release

parents 3f79626a f9773570
......@@ -73,7 +73,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 ("
......@@ -81,6 +80,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;
......
......@@ -162,7 +162,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;
......@@ -187,7 +187,7 @@ public class VoucherService {
throw new VoucherException(-10, "抵用劵校验不通过");
}
}
}*/
/**
* 校验抵用劵是否可以使用,事务传播级别为REQUEST_NEW
......@@ -196,35 +196,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, "抵用劵校验不通过");
}
}
/**
......
......@@ -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, "您的抵用劵使用错误");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment