|
@@ -1,17 +1,20 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.SysCouponDao;
|
|
|
+import com.ym.mec.biz.dal.entity.SysCoupon;
|
|
|
+import com.ym.mec.biz.dal.page.SysCouponQueryInfo;
|
|
|
+import com.ym.mec.biz.service.SysCouponService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
-import com.ym.mec.biz.dal.entity.SysCoupon;
|
|
|
-import com.ym.mec.biz.service.SysCouponService;
|
|
|
-import com.ym.mec.biz.dal.dao.SysCouponDao;
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon> implements SysCouponService {
|
|
@@ -25,6 +28,23 @@ public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public PageInfo<SysCoupon> queryPage(SysCouponQueryInfo queryInfo) {
|
|
|
+ PageInfo<SysCoupon> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<SysCoupon> dataList = new ArrayList<>();
|
|
|
+ int count = this.findCount(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = this.getDAO().queryPage(params);
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public void updateCoupon(SysCoupon sysCoupon) {
|
|
|
SysCoupon oldCoupon = sysCouponDao.lockCoupon(sysCoupon.getId());
|
|
@@ -37,8 +57,8 @@ public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon> i
|
|
|
oldCoupon.setStockCount(sysCoupon.getStockCount());
|
|
|
oldCoupon.setWarningStockNum(sysCoupon.getWarningStockNum());
|
|
|
sysCouponDao.update(oldCoupon);
|
|
|
- return;
|
|
|
+ }else{
|
|
|
+ sysCouponDao.update(sysCoupon);
|
|
|
}
|
|
|
- sysCouponDao.update(sysCoupon);
|
|
|
}
|
|
|
}
|