|
|
@@ -1,5 +1,8 @@
|
|
|
package org.jeecg.modules.business.controller;
|
|
|
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -9,11 +12,20 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.business.dto.CouponsGenerateDto;
|
|
|
+import org.jeecg.modules.business.dto.PostDataDto;
|
|
|
import org.jeecg.modules.business.entity.BusMarketCoupons;
|
|
|
+import org.jeecg.modules.business.entity.BusMarketCouponsCashUsed;
|
|
|
import org.jeecg.modules.business.entity.BusMarketMealCoupons;
|
|
|
import org.jeecg.modules.business.entity.BusMarketMealCouponsUsed;
|
|
|
import org.jeecg.modules.business.enums.CouponsStatusEnum;
|
|
|
@@ -26,6 +38,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import org.jeecg.modules.business.vo.MealCouponStatVo;
|
|
|
+import org.jeecg.modules.business.vo.MemberCardStatVo;
|
|
|
+import org.jeecg.modules.rooms.entity.CesMealCoupon;
|
|
|
+import org.jeecg.modules.rooms.entity.CesStockType;
|
|
|
+import org.jeecg.modules.rooms.service.CesMealCouponServiceImpl;
|
|
|
+import org.jeecg.modules.rooms.service.CesStockTypeServiceImpl;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.service.ISysUserService;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
@@ -58,6 +78,10 @@ public class BusMarketMealCouponsUsedController extends JeecgController<BusMarke
|
|
|
private IBusMarketMealCouponsUsedService busMarketMealCouponsUsedService;
|
|
|
@Autowired
|
|
|
private IBusMarketMealCouponsService busMarketMealCouponsService;
|
|
|
+ @Autowired
|
|
|
+ private CesMealCouponServiceImpl cesMealCouponService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
|
@@ -80,16 +104,69 @@ public class BusMarketMealCouponsUsedController extends JeecgController<BusMarke
|
|
|
pageList.getRecords().forEach(item -> {
|
|
|
BusMarketMealCoupons coupons = busMarketMealCouponsService.getById(item.getCouponsId());
|
|
|
if (coupons != null) {
|
|
|
- item.setConponsName(coupons.getName());
|
|
|
+ item.setCouponsName(coupons.getName());
|
|
|
+ item.setCost(coupons.getCost());
|
|
|
+ if (ObjectUtils.isNotEmpty(coupons.getType())) {
|
|
|
+ CesMealCoupon cesMealCoupon = cesMealCouponService.getById(coupons.getType());
|
|
|
+ if (cesMealCoupon != null) {
|
|
|
+ item.setTypeName(cesMealCoupon.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CouponsStatusEnum couponsStatusEnum = CouponsStatusEnum.val(item.getStatus());
|
|
|
if (couponsStatusEnum != null) {
|
|
|
item.setStatusName(couponsStatusEnum.getTitle());
|
|
|
}
|
|
|
+ if (ObjectUtils.isNotEmpty(item.getUsedUserId())) {
|
|
|
+ SysUser sysUser = sysUserService.getById(item.getUsedUserId());
|
|
|
+ if (sysUser != null) {
|
|
|
+ item.setUsedUserName(sysUser.getUsername());
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 核销列表
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param hotelId
|
|
|
+ * @param type
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="核销列表", notes="核销列表")
|
|
|
+ @GetMapping(value = "/verifyList")
|
|
|
+ public Result<IPage<BusMarketMealCouponsUsed>> verifyPageList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ @RequestParam(name="hotelId", required = true) String hotelId,
|
|
|
+ @RequestParam(name="type", defaultValue="") String type,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Page<BusMarketMealCouponsUsed> page = new Page<BusMarketMealCouponsUsed>(pageNo, pageSize);
|
|
|
+ IPage<BusMarketMealCouponsUsed> pageList = busMarketMealCouponsUsedService.verifyList(page, hotelId, type);
|
|
|
+ pageList.getRecords().forEach(item -> {
|
|
|
+ if (ObjectUtils.isNotEmpty(item.getUsedUserId())) {
|
|
|
+ SysUser sysUser = sysUserService.getById(item.getUsedUserId());
|
|
|
+ if (sysUser != null) {
|
|
|
+ item.setUsedUserName(sysUser.getUsername());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 核销各种统计
|
|
|
+ * @param hotelId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/stat")
|
|
|
+ public Result stat(@RequestParam(name="hotelId") String hotelId,@RequestParam(name="type",required = false) String type) {
|
|
|
+ MealCouponStatVo vo = busMarketMealCouponsUsedService.stat(hotelId,type);
|
|
|
+ return Result.OK(vo);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
|
@@ -118,6 +195,66 @@ public class BusMarketMealCouponsUsedController extends JeecgController<BusMarke
|
|
|
Result res = busMarketMealCouponsUsedService.generate(dto);
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 核销
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "核销")
|
|
|
+ @ApiOperation(value="核销", notes="核销")
|
|
|
+ @RequestMapping(value = "/verify", method = {RequestMethod.POST})
|
|
|
+ public Result<String> verify(@RequestBody PostDataDto dto) {
|
|
|
+ BusMarketMealCouponsUsed busMarketMealCouponsUsed = busMarketMealCouponsUsedService.getById(dto.getId());
|
|
|
+ if (busMarketMealCouponsUsed == null) {
|
|
|
+ return Result.error("此券不存在!");
|
|
|
+ }
|
|
|
+ if (busMarketMealCouponsUsed.getStatus() != CouponsStatusEnum.received.getKey()) {
|
|
|
+ CouponsStatusEnum couponsStatusEnum = CouponsStatusEnum.val(busMarketMealCouponsUsed.getStatus());
|
|
|
+ String statusName = "";
|
|
|
+ if (couponsStatusEnum != null) {
|
|
|
+ statusName = couponsStatusEnum.getTitle();
|
|
|
+ }
|
|
|
+ return Result.error("此券状态" + statusName + ",不可核销!");
|
|
|
+ }
|
|
|
+ BusMarketMealCoupons busMarketMealCoupons = busMarketMealCouponsService.getById(busMarketMealCouponsUsed.getCouponsId());
|
|
|
+ if (busMarketMealCoupons == null) {
|
|
|
+ return Result.error("此券活动不存在!");
|
|
|
+ }
|
|
|
+ CesMealCoupon cesMealCoupon = cesMealCouponService.getById(busMarketMealCoupons.getType());
|
|
|
+ if (cesMealCoupon == null) {
|
|
|
+ return Result.error("此券类型不存在!");
|
|
|
+ }
|
|
|
+ DateTime dateTime = DateTime.now();
|
|
|
+ DateFormat startDateFormat = new SimpleDateFormat("yyyy-MM-dd " + cesMealCoupon.getStartDate().trim());
|
|
|
+ String startDateStr = startDateFormat.format(dateTime);
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ try {
|
|
|
+ if (dateTime.compareTo(dateFormat.parse(startDateStr)) < 0) {
|
|
|
+ return Result.error("此券未到核销时间!");
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ return Result.error("此券类型开始时间格式错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ DateFormat endDateFormat = new SimpleDateFormat("yyyy-MM-dd " + cesMealCoupon.getEndDate().trim());
|
|
|
+ String endDateStr = endDateFormat.format(dateTime);
|
|
|
+ try {
|
|
|
+ if (dateTime.compareTo(dateFormat.parse(endDateStr)) > 0) {
|
|
|
+ return Result.error("此券已超过核销时间!");
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ return Result.error("此券类型截至时间格式错误!");
|
|
|
+ }
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
+ LambdaUpdateWrapper<BusMarketMealCouponsUsed> updateWrapper = new UpdateWrapper().lambda();
|
|
|
+ updateWrapper.set(BusMarketMealCouponsUsed::getStatus, CouponsStatusEnum.used.getKey());
|
|
|
+ updateWrapper.set(BusMarketMealCouponsUsed::getUsedUserId, user.getId());
|
|
|
+ updateWrapper.set(BusMarketMealCouponsUsed::getUsedTime, DateTime.now());
|
|
|
+ updateWrapper.eq(BusMarketMealCouponsUsed::getId, dto.getId());
|
|
|
+ busMarketMealCouponsUsedService.update(updateWrapper);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 编辑
|