|
@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -35,6 +37,7 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
|
|
|
public CmVipCoupon get(String id) {
|
|
|
CmVipCoupon vipCoupon = super.get(id);
|
|
|
if (null != vipCoupon) {
|
|
|
+ setVipCouponStatus(vipCoupon);
|
|
|
List<CmCoupon> couponList = new ArrayList<>();
|
|
|
List<String> bindCoupons = cmCouponVipDao.getBindCoupons(id);
|
|
|
for (String s : bindCoupons) {
|
|
@@ -51,6 +54,7 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
|
|
|
Page<CmVipCoupon> vipPage = super.findPage(page, cmVipCoupon);
|
|
|
List<CmVipCoupon> cmVipCouponList = vipPage.getList();
|
|
|
cmVipCouponList.forEach(vipCoupon -> {
|
|
|
+ setVipCouponStatus(vipCoupon);
|
|
|
List<String> bindCoupons = cmCouponVipDao.getBindCoupons(vipCoupon.getId());
|
|
|
List<CmCoupon> couponList = cmCouponVipDao.getCouponListByIds(bindCoupons, cmVipCoupon.getCouponType(), cmVipCoupon.getStatus());
|
|
|
Date date = new Date();
|
|
@@ -78,6 +82,32 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
|
|
|
return vipPage;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置会员优惠生效状态
|
|
|
+ */
|
|
|
+ private void setVipCouponStatus(CmVipCoupon vipCoupon) {
|
|
|
+ if (!"2".equals(vipCoupon.getStatus())) {
|
|
|
+ try {
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String current = df.format(new Date());
|
|
|
+ String useTime = vipCoupon.getUseTime();
|
|
|
+ // 0未生效 1已生效 2已关闭 3已失效
|
|
|
+ if (df.parse(useTime).after(df.parse(current))) {
|
|
|
+ // 未生效
|
|
|
+ vipCoupon.setStatus("0");
|
|
|
+ } else if (df.parse(useTime).before(df.parse(current))) {
|
|
|
+ // 已失效
|
|
|
+ vipCoupon.setStatus("3");
|
|
|
+ } else {
|
|
|
+ // 生效
|
|
|
+ vipCoupon.setStatus("1");
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置4张券的表单数据
|
|
|
*/
|