diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/controller/MktCouponController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/controller/MktCouponController.java index 054df3ad..93b57226 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/controller/MktCouponController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/controller/MktCouponController.java @@ -2,6 +2,7 @@ package com.bonus.canteen.core.marketing.coupon.controller; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import com.bonus.canteen.core.marketing.dto.GroupCuponDto; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.canteen.core.marketing.coupon.param.MktCouponMobileUsableParam; import com.bonus.canteen.core.marketing.coupon.service.MktCouponService; @@ -32,6 +33,12 @@ public class MktCouponController { @Lazy private MktCouponService mktCouponService; + @ApiOperation("获取电子餐券列表") + @PostMapping({"/list-electron-mobile-group"}) + public AjaxResult listElecMobileGroup(@RequestBody GroupCuponDto dto) { + return AjaxResult.success(this.mktCouponService.listElecMobileGroup(dto)); + } + @ApiOperation("获取可用的电子餐券列表") @PostMapping({"/list-electron-mobile-usable"}) // @RequiresGuest diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/MktCouponService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/MktCouponService.java index 4530630a..226c446b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/MktCouponService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/MktCouponService.java @@ -6,12 +6,16 @@ import com.bonus.canteen.core.marketing.coupon.model.MktCouponMacPayModel; import com.bonus.canteen.core.marketing.coupon.model.MktCouponPayModel; import com.bonus.canteen.core.marketing.coupon.param.MktCouponMobileUsableParam; import com.bonus.canteen.core.marketing.coupon.vo.MktCouponMobileUsableVO; +import com.bonus.canteen.core.marketing.dto.GroupCuponDto; +import com.bonus.canteen.core.marketing.vo.MktGroupVo; import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; public interface MktCouponService extends IService { + + public MktGroupVo listElecMobileGroup(GroupCuponDto groupCuponDto); List listElecMobileUsable(MktCouponMobileUsableParam param); MktCouponPayModel getCouponAmountForMacPay(MktCouponMacPayModel macPayModel); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/impl/MktCouponServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/impl/MktCouponServiceImpl.java index 261b0752..e3366986 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/impl/MktCouponServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/coupon/service/impl/MktCouponServiceImpl.java @@ -2,16 +2,17 @@ package com.bonus.canteen.core.marketing.coupon.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.canteen.core.marketing.dto.GroupByCouponStateDto; +import com.bonus.canteen.core.marketing.dto.GroupCuponDto; +import com.bonus.canteen.core.marketing.vo.MktCouponMobileVO; +import com.bonus.canteen.core.marketing.vo.MktCouponTmplBackVO; +import com.bonus.canteen.core.marketing.vo.MktGroupVo; import com.bonus.common.core.exception.ServiceException; import com.bonus.canteen.core.allocation.canteen.mapper.AllocCanteenMapper; import com.bonus.canteen.core.marketing.coupon.constants.MktCouponStateEnum; @@ -34,7 +35,6 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; - import javax.annotation.Resource; import java.lang.invoke.SerializedLambda; import java.math.BigDecimal; @@ -59,6 +59,34 @@ public class MktCouponServiceImpl extends ServiceImpl() : couponList; } + public MktGroupVo listElecMobileGroup(GroupCuponDto groupCuponDto) { + MktGroupVo mktGroupVo = new MktGroupVo(); + List groupByCouponState = ((MktCouponMapper)this.baseMapper).getGroupByCouponState(groupCuponDto.getCustId()); + mktGroupVo.putNum(groupByCouponState); + Page page = new Page(groupCuponDto.getCurrent(), groupCuponDto.getSize()); + this.page(page, Wrappers.lambdaQuery(MktCoupon.class).eq(MktCoupon::getCustId, groupCuponDto.getCustId()) + .eq(MktCoupon::getCouponState, groupCuponDto.getCouponState()) + .eq(MktCoupon::getCouponType, MktCouponTypeEnum.ELECTRON_COUPON.getKey()).orderByDesc(MktCoupon::getId)); + List resultMobileVOList = new ArrayList(); + Iterator var6 = page.getRecords().iterator(); + + while(var6.hasNext()) { + MktCoupon mktCoupon = (MktCoupon)var6.next(); + MktCouponTmplBackVO tmplBackVO = this.mktCouponTmplBackService.getBackRelationName(mktCoupon.getBackId(), MktCouponTypeEnum.ELECTRON_COUPON); + MktCouponMobileVO mobileVO = new MktCouponMobileVO(); + BeanUtils.copyProperties(mktCoupon, mobileVO); + mobileVO.setCanteenNameStr(tmplBackVO.getCanteenNameStr()); + mobileVO.setShopstallNameStr(tmplBackVO.getShopstallNameStr()); + mobileVO.setIntervalNameStr(tmplBackVO.getIntervalNameStr()); + resultMobileVOList.add(mobileVO); + } + + Page result = (Page)BeanUtil.copyProperties(page, Page.class, new String[0]); + result.setRecords(resultMobileVOList); + mktGroupVo.setPage(result); + return mktGroupVo; + } + public List listElecMobileUsable(MktCouponMobileUsableParam param) { List couponList = this.listUsableElecCouponByCustId(param.getCustId()); Long canteenId = (Long)param.getCanteenIdSet().stream().findFirst().orElse(null); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupByCouponStateDto.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupByCouponStateDto.java new file mode 100644 index 00000000..24cb4b9a --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupByCouponStateDto.java @@ -0,0 +1,23 @@ +package com.bonus.canteen.core.marketing.dto; + +public class GroupByCouponStateDto { + private Integer couponState; + private Integer num; + + public Integer getCouponState() { + return this.couponState; + } + + public Integer getNum() { + return this.num; + } + + public void setCouponState(final Integer couponState) { + this.couponState = couponState; + } + + public void setNum(final Integer num) { + this.num = num; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupCuponDto.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupCuponDto.java new file mode 100644 index 00000000..20722e9b --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/dto/GroupCuponDto.java @@ -0,0 +1,27 @@ +package com.bonus.canteen.core.marketing.dto; + +import com.bonus.canteen.core.common.page.PageDTO; +import io.swagger.annotations.ApiModelProperty; + +public class GroupCuponDto extends PageDTO { + private Long custId; + @ApiModelProperty("餐券状态 1-未生效 2-未使用 3-已使用 4-已过期 5-已作废") + private Integer couponState; + + public Long getCustId() { + return this.custId; + } + + public Integer getCouponState() { + return this.couponState; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + public void setCouponState(final Integer couponState) { + this.couponState = couponState; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponMobileVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponMobileVO.java new file mode 100644 index 00000000..d0a1b6ea --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponMobileVO.java @@ -0,0 +1,130 @@ +package com.bonus.canteen.core.marketing.vo; + +import com.bonus.canteen.core.common.utils.SysUtil; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.time.LocalDate; + +public class MktCouponMobileVO { + @ApiModelProperty("餐券编号") + private String couponNum; + @ApiModelProperty("餐券名称") + private String couponName; + @ApiModelProperty("单位名称") + private String companyName; + @ApiModelProperty("有效期") + private LocalDate effectDateStart; + @ApiModelProperty("有效期") + private LocalDate effectDateEnd; + @ApiModelProperty("餐券金额") + private BigDecimal couponAmount; + @ApiModelProperty("餐券图片链接") + private String couponImgUrl; + @ApiModelProperty("限定使用次数") + private Integer limitTimes; + @ApiModelProperty("已使用次数") + private Integer usedTimes; + @ApiModelProperty("食堂名称") + private String canteenNameStr; + @ApiModelProperty("档口名称") + private String shopstallNameStr; + @ApiModelProperty("餐次名称") + private String intervalNameStr; + + public String getCouponImgUrl() { + return SysUtil.getCutFileUrl(this.couponImgUrl); + } + + public String getCouponNum() { + return this.couponNum; + } + + public String getCouponName() { + return this.couponName; + } + + public String getCompanyName() { + return this.companyName; + } + + public LocalDate getEffectDateStart() { + return this.effectDateStart; + } + + public LocalDate getEffectDateEnd() { + return this.effectDateEnd; + } + + public BigDecimal getCouponAmount() { + return this.couponAmount; + } + + public Integer getLimitTimes() { + return this.limitTimes; + } + + public Integer getUsedTimes() { + return this.usedTimes; + } + + public String getCanteenNameStr() { + return this.canteenNameStr; + } + + public String getShopstallNameStr() { + return this.shopstallNameStr; + } + + public String getIntervalNameStr() { + return this.intervalNameStr; + } + + public void setCouponNum(final String couponNum) { + this.couponNum = couponNum; + } + + public void setCouponName(final String couponName) { + this.couponName = couponName; + } + + public void setCompanyName(final String companyName) { + this.companyName = companyName; + } + + public void setEffectDateStart(final LocalDate effectDateStart) { + this.effectDateStart = effectDateStart; + } + + public void setEffectDateEnd(final LocalDate effectDateEnd) { + this.effectDateEnd = effectDateEnd; + } + + public void setCouponAmount(final BigDecimal couponAmount) { + this.couponAmount = couponAmount; + } + + public void setCouponImgUrl(final String couponImgUrl) { + this.couponImgUrl = couponImgUrl; + } + + public void setLimitTimes(final Integer limitTimes) { + this.limitTimes = limitTimes; + } + + public void setUsedTimes(final Integer usedTimes) { + this.usedTimes = usedTimes; + } + + public void setCanteenNameStr(final String canteenNameStr) { + this.canteenNameStr = canteenNameStr; + } + + public void setShopstallNameStr(final String shopstallNameStr) { + this.shopstallNameStr = shopstallNameStr; + } + + public void setIntervalNameStr(final String intervalNameStr) { + this.intervalNameStr = intervalNameStr; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponTmplBackVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponTmplBackVO.java new file mode 100644 index 00000000..4ce2786e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktCouponTmplBackVO.java @@ -0,0 +1,119 @@ +package com.bonus.canteen.core.marketing.vo; + +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; + +public class MktCouponTmplBackVO { + @ApiModelProperty("餐券模板备份id") + private Long backId; + @ApiModelProperty("餐券模板id") + private Long tmplId; + @ApiModelProperty("单位名称") + private String companyName; + @ApiModelProperty("餐券名称") + private String couponName; + @ApiModelProperty("餐券金额") + private BigDecimal couponAmount; + @ApiModelProperty("食堂名称") + private String canteenNameStr; + @ApiModelProperty("档口名称") + private String shopstallNameStr; + @ApiModelProperty("餐次名称") + private String intervalNameStr; + @ApiModelProperty("食堂id") + private Long canteenId; + @ApiModelProperty("档口id") + private Long shopstallId; + @ApiModelProperty("餐次id") + private Long intervalId; + + public Long getBackId() { + return this.backId; + } + + public Long getTmplId() { + return this.tmplId; + } + + public String getCompanyName() { + return this.companyName; + } + + public String getCouponName() { + return this.couponName; + } + + public BigDecimal getCouponAmount() { + return this.couponAmount; + } + + public String getCanteenNameStr() { + return this.canteenNameStr; + } + + public String getShopstallNameStr() { + return this.shopstallNameStr; + } + + public String getIntervalNameStr() { + return this.intervalNameStr; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public Long getShopstallId() { + return this.shopstallId; + } + + public Long getIntervalId() { + return this.intervalId; + } + + public void setBackId(final Long backId) { + this.backId = backId; + } + + public void setTmplId(final Long tmplId) { + this.tmplId = tmplId; + } + + public void setCompanyName(final String companyName) { + this.companyName = companyName; + } + + public void setCouponName(final String couponName) { + this.couponName = couponName; + } + + public void setCouponAmount(final BigDecimal couponAmount) { + this.couponAmount = couponAmount; + } + + public void setCanteenNameStr(final String canteenNameStr) { + this.canteenNameStr = canteenNameStr; + } + + public void setShopstallNameStr(final String shopstallNameStr) { + this.shopstallNameStr = shopstallNameStr; + } + + public void setIntervalNameStr(final String intervalNameStr) { + this.intervalNameStr = intervalNameStr; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setShopstallId(final Long shopstallId) { + this.shopstallId = shopstallId; + } + + public void setIntervalId(final Long intervalId) { + this.intervalId = intervalId; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktGroupVo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktGroupVo.java new file mode 100644 index 00000000..590f6c66 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/marketing/vo/MktGroupVo.java @@ -0,0 +1,95 @@ +package com.bonus.canteen.core.marketing.vo; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bonus.canteen.core.marketing.dto.GroupByCouponStateDto; +import io.swagger.annotations.ApiModelProperty; +import java.util.Iterator; +import java.util.List; + +public class MktGroupVo { + @ApiModelProperty("未生效") + private Integer notTakeEffect; + @ApiModelProperty("未使用") + private Integer notUse; + @ApiModelProperty("已使用") + private Integer used; + @ApiModelProperty("已过期") + private Integer expired; + @ApiModelProperty("已作废") + private Integer cancellation; + private Page page; + + public void putNum(List groupByCouponState) { + Iterator var2 = groupByCouponState.iterator(); + + while(var2.hasNext()) { + GroupByCouponStateDto groupByCouponStateDto = (GroupByCouponStateDto)var2.next(); + switch (groupByCouponStateDto.getCouponState()) { + case 1: + this.notTakeEffect = groupByCouponStateDto.getNum(); + break; + case 2: + this.notUse = groupByCouponStateDto.getNum(); + break; + case 3: + this.used = groupByCouponStateDto.getNum(); + break; + case 4: + this.expired = groupByCouponStateDto.getNum(); + break; + case 5: + this.cancellation = groupByCouponStateDto.getNum(); + } + } + + } + + public Integer getNotTakeEffect() { + return this.notTakeEffect; + } + + public Integer getNotUse() { + return this.notUse; + } + + public Integer getUsed() { + return this.used; + } + + public Integer getExpired() { + return this.expired; + } + + public Integer getCancellation() { + return this.cancellation; + } + + public Page getPage() { + return this.page; + } + + public void setNotTakeEffect(final Integer notTakeEffect) { + this.notTakeEffect = notTakeEffect; + } + + public void setNotUse(final Integer notUse) { + this.notUse = notUse; + } + + public void setUsed(final Integer used) { + this.used = used; + } + + public void setExpired(final Integer expired) { + this.expired = expired; + } + + public void setCancellation(final Integer cancellation) { + this.cancellation = cancellation; + } + + public void setPage(final Page page) { + this.page = page; + } + +}