gqx 2 lat temu
rodzic
commit
5986d10929

+ 139 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusMarketMealCouponsUsedController.java

@@ -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("编辑成功!");
+	 }
 	
 	/**
 	 *  编辑

+ 7 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusMarketMealCouponsUsed.java

@@ -101,8 +101,13 @@ public class BusMarketMealCouponsUsed implements Serializable {
     private String gainUserId;
 
     @TableField(exist = false)
-    private String conponsName;
-
+    private String couponsName;
+    @TableField(exist = false)
+    private BigDecimal cost;
+    @TableField(exist = false)
+    private String typeName;
     @TableField(exist = false)
     private String statusName;
+    @TableField(exist = false)
+    private String usedUserName;
 }

+ 36 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusMarketMealCouponsUsedMapper.java

@@ -2,9 +2,15 @@ package org.jeecg.modules.business.mapper;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.business.entity.BusMarketCoupons;
+import org.jeecg.modules.business.entity.BusMarketMealCoupons;
 import org.jeecg.modules.business.entity.BusMarketMealCouponsUsed;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.business.vo.MealCouponStatVo;
+import org.jeecg.modules.business.vo.MemberCardStatVo;
 
 /**
  * @Description: bus_market_meal_coupons_used
@@ -13,5 +19,35 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  */
 public interface BusMarketMealCouponsUsedMapper extends BaseMapper<BusMarketMealCouponsUsed> {
+    /**
+     * 已核销餐券列表
+     * @param hotelId
+     * @param status
+     * @param type
+     * @return
+     */
+    @Select("<script>select u.*,c.name as coupons_name,cmc.name as type_name from bus_market_meal_coupons_used u\n" +
+            "left join bus_market_meal_coupons_info c on c.id=u.coupons_id\n" +
+            "left join ces_meal_coupon cmc on cmc.id=c.type where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and u.hotel_id = #{hotelId} </if>"+
+            "<if test='status >-1'> and u.status = #{status} </if>"+
+            "<if test='type != null and type !=\"\"'> and c.type = #{type} </if>"+
+            "</script>")
+    public List<BusMarketMealCouponsUsed> verifyList(Page<BusMarketMealCouponsUsed> page, String hotelId, Integer status, String type);
 
+    /**
+     * 统计
+     * @param hotelId
+     * @return
+     */
+    @Select("<script>select ifnull(sum(CASE WHEN DATEDIFF(enable_date,now())=0 THEN 1 ELSE 0 END),0) as day_count,\n" +
+            "ifnull(sum(CASE WHEN DATEDIFF(used_time,now())=0 THEN 1 ELSE 0 END),0) as day_used_count,\n" +
+            "ifnull(sum(CASE WHEN DATEDIFF(gain_time,now())=0 THEN 1 ELSE 0 END),0) as day_received_count,\n" +
+            "ifnull(sum(CASE WHEN DATEDIFF(voided_time,now())=0 THEN 1 ELSE 0 END),0) as day_voided_count\n" +
+            "from bus_market_meal_coupons_used u\n"+
+            "left join bus_market_meal_coupons_info c on c.id=u.coupons_id\n" +
+            "where u.hotel_id = #{hotelId}\n"+
+            "<if test='type != null and type !=\"\"'> and c.type = #{type} </if>"+
+            "</script>")
+    public MealCouponStatVo stat(String hotelId,String type);
 }

+ 16 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusMarketMealCouponsUsedService.java

@@ -1,9 +1,11 @@
 package org.jeecg.modules.business.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.business.dto.CouponsGenerateDto;
 import org.jeecg.modules.business.entity.BusMarketMealCouponsUsed;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.business.vo.MealCouponStatVo;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -19,4 +21,18 @@ public interface IBusMarketMealCouponsUsedService extends IService<BusMarketMeal
      * @return
      */
     public Result generate(CouponsGenerateDto dto) ;
+    /**
+     * 已核销餐券列表
+     * @param hotelId
+     * @param type
+     * @return
+     */
+    public Page<BusMarketMealCouponsUsed> verifyList(Page<BusMarketMealCouponsUsed> page, String hotelId, String type);
+
+    /**
+     * 统计
+     * @param hotelId
+     * @return
+     */
+    public MealCouponStatVo stat(String hotelId,String type);
 }

+ 28 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusMarketMealCouponsUsedServiceImpl.java

@@ -1,7 +1,9 @@
 package org.jeecg.modules.business.service.impl;
 
 import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.TokenUtils;
 import org.jeecg.modules.business.dto.CouponsGenerateDto;
@@ -9,10 +11,13 @@ import org.jeecg.modules.business.entity.BusMarketCouponsCash;
 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;
 import org.jeecg.modules.business.mapper.BusMarketCouponsCashMapper;
 import org.jeecg.modules.business.mapper.BusMarketMealCouponsMapper;
 import org.jeecg.modules.business.mapper.BusMarketMealCouponsUsedMapper;
 import org.jeecg.modules.business.service.IBusMarketMealCouponsUsedService;
+import org.jeecg.modules.business.vo.MealCouponStatVo;
+import org.jeecg.modules.business.vo.MemberCardStatVo;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -34,6 +39,8 @@ import java.util.UUID;
 public class BusMarketMealCouponsUsedServiceImpl extends ServiceImpl<BusMarketMealCouponsUsedMapper, BusMarketMealCouponsUsed> implements IBusMarketMealCouponsUsedService {
     @Resource
     private BusMarketMealCouponsMapper busMarketMealCouponsMapper;
+    @Resource
+    private BusMarketMealCouponsUsedMapper busMarketMealCouponsUsedMapper;
     /**
      * 生成16位数字+prefix
      * @param prefix
@@ -75,4 +82,25 @@ public class BusMarketMealCouponsUsedServiceImpl extends ServiceImpl<BusMarketMe
         this.saveBatch(busMarketMealCouponsUsedList);
         return Result.ok("创建成功");
     }
+
+
+
+    /**
+     * 已核销餐券列表
+     * @param hotelId
+     * @param type
+     * @return
+     */
+    public Page<BusMarketMealCouponsUsed> verifyList(Page<BusMarketMealCouponsUsed> page, String hotelId,String type) {
+        return page.setRecords(busMarketMealCouponsUsedMapper.verifyList(page, hotelId, CouponsStatusEnum.used.getKey(),type));
+    }
+
+    /**
+     * 统计
+     * @param hotelId
+     * @return
+     */
+    public MealCouponStatVo stat(String hotelId,String type) {
+        return busMarketMealCouponsUsedMapper.stat(hotelId, type);
+    }
 }

+ 24 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/vo/MealCouponStatVo.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.business.vo;
+
+import lombok.Data;
+
+
+@Data
+public class MealCouponStatVo {
+    /**
+     * 餐券当天总数
+     */
+    private Integer dayCount;
+    /**
+     * 餐券当天已核销总数
+     */
+    private Integer dayUsedCount;
+    /**
+     * 餐券当天待核销总数
+     */
+    private Integer dayReceivedCount;
+    /**
+     * 餐券当天作废总数
+     */
+    private Integer dayVoidedCount;
+}