From cc69c78e3e405d919f11f571074de4032529888b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=90=E5=A4=A9=E5=A4=A7=E5=9C=A3?= <17615834396@163.com> Date: Thu, 21 Dec 2023 17:48:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E6=9C=89=E7=A4=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActiveNewlywedsRecordsController.java | 8 +- .../entity/ActiveNewlywedsRecords.java | 105 ++-------------- .../ActiveNewlywedsRecordsService.java | 6 + .../ActiveNewlywedsRecordsServiceImpl.java | 86 +++++++++++++ .../ActiveRecommendRecordsController.java | 21 ++-- .../entity/ActiveRecommendRecords.java | 12 ++ .../ActiveRecommendRecordsService.java | 22 ++++ .../ActiveRecommendRecordsServiceImpl.java | 119 ++++++++++++++++++ .../impl/ActiveRecommendServiceImpl.java | 8 +- .../vo/ActiveRecommendRecordsVO.java | 11 ++ .../controller/CardFavorableController.java | 20 ++- .../CardFavorableRecordController.java | 20 +++ .../service/CardFavorableRecordService.java | 13 ++ .../impl/CardFavorableRecordServiceImpl.java | 60 ++++++++- gasStation-uni/pages/index/index.vue | 81 ++++++++++-- gasStation-uni/pages/my/my.vue | 7 +- gasStation-uni/pagesHome/activeIn/index.vue | 9 +- gasStation-uni/pagesMy/Coupons/Coupons.vue | 70 +++++++++-- 18 files changed, 538 insertions(+), 140 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/vo/ActiveRecommendRecordsVO.java diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/controller/ActiveNewlywedsRecordsController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/controller/ActiveNewlywedsRecordsController.java index 2cd6dbf7f..96c783786 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/controller/ActiveNewlywedsRecordsController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/controller/ActiveNewlywedsRecordsController.java @@ -59,12 +59,12 @@ public class ActiveNewlywedsRecordsController extends BaseController { @GetMapping("applet") public ResponseObject isJoined(@Param("activeNewlywedsRecords") ActiveNewlywedsRecords activeNewlywedsRecords) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(ActiveNewlywedsRecords::getInviteeUserId,TokenUtil.getNowAccountInfo().getId()); + queryWrapper.eq(ActiveNewlywedsRecords::getUserId,TokenUtil.getNowAccountInfo().getId()); List list = this.activeNewlywedsRecordsService.list(queryWrapper); if (list.size() == 0){ - return getSuccessResult("可以参加新人活动"); + return getSuccessResult("1"); }else { - return getSuccessResult("不可以参加新人活动"); + return getSuccessResult("0"); } } @@ -87,7 +87,7 @@ public class ActiveNewlywedsRecordsController extends BaseController { */ @PostMapping public ResponseObject insert(@RequestBody ActiveNewlywedsRecords activeNewlywedsRecords) { - return getSuccessResult(this.activeNewlywedsRecordsService.save(activeNewlywedsRecords)); + return getSuccessResult(this.activeNewlywedsRecordsService.add(activeNewlywedsRecords)); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/entity/ActiveNewlywedsRecords.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/entity/ActiveNewlywedsRecords.java index 3a777b50e..1d2423184 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/entity/ActiveNewlywedsRecords.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/entity/ActiveNewlywedsRecords.java @@ -1,7 +1,13 @@ package com.fuint.business.marketingActivity.activeNewlyweds.entity; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + import java.io.Serializable; /** @@ -11,8 +17,10 @@ import java.io.Serializable; * @since 2023-12-20 14:12:54 */ @SuppressWarnings("serial") +@Data public class ActiveNewlywedsRecords extends Model { //主键id + @TableId(type = IdType.AUTO) private Integer id; //活动id private Integer activeNewlywedsId; @@ -21,107 +29,16 @@ public class ActiveNewlywedsRecords extends Model { //所属店铺id private Integer storeId; //用户id - private String userId; - //被邀请人id - private String inviteeUserId; + private Integer userId; //创建者 private String createBy; //创建时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; //更新者 private String updateBy; //更新时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; - - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getActiveNewlywedsId() { - return activeNewlywedsId; - } - - public void setActiveNewlywedsId(Integer activeNewlywedsId) { - this.activeNewlywedsId = activeNewlywedsId; - } - - public Integer getChainStoreId() { - return chainStoreId; - } - - public void setChainStoreId(Integer chainStoreId) { - this.chainStoreId = chainStoreId; - } - - public Integer getStoreId() { - return storeId; - } - - public void setStoreId(Integer storeId) { - this.storeId = storeId; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getInviteeUserId() { - return inviteeUserId; - } - - public void setInviteeUserId(String inviteeUserId) { - this.inviteeUserId = inviteeUserId; - } - - public String getCreateBy() { - return createBy; - } - - public void setCreateBy(String createBy) { - this.createBy = createBy; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public String getUpdateBy() { - return updateBy; - } - - public void setUpdateBy(String updateBy) { - this.updateBy = updateBy; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/ActiveNewlywedsRecordsService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/ActiveNewlywedsRecordsService.java index 840cb84ce..509436b60 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/ActiveNewlywedsRecordsService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/ActiveNewlywedsRecordsService.java @@ -11,5 +11,11 @@ import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlywe */ public interface ActiveNewlywedsRecordsService extends IService { + /** + * 新增数据 + * @param activeNewlywedsRecords + * @return + */ + boolean add(ActiveNewlywedsRecords activeNewlywedsRecords); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/impl/ActiveNewlywedsRecordsServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/impl/ActiveNewlywedsRecordsServiceImpl.java index 893a38682..db9a238ce 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/impl/ActiveNewlywedsRecordsServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeNewlyweds/service/impl/ActiveNewlywedsRecordsServiceImpl.java @@ -1,10 +1,30 @@ package com.fuint.business.marketingActivity.activeNewlyweds.service.impl; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.marketingActivity.activeNewlyweds.controller.vo.ActiveNewlywedsVO; +import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlyweds; +import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlywedsChild; import com.fuint.business.marketingActivity.activeNewlyweds.mapper.ActiveNewlywedsRecordsMapper; import com.fuint.business.marketingActivity.activeNewlyweds.entity.ActiveNewlywedsRecords; import com.fuint.business.marketingActivity.activeNewlyweds.service.ActiveNewlywedsRecordsService; +import com.fuint.business.marketingActivity.activeNewlyweds.service.ActiveNewlywedsService; +import com.fuint.business.marketingActivity.cardExchange.entity.CardExchangeRecord; +import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeRecordService; +import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; +import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableRecordMapper; +import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService; +import com.fuint.business.userManager.service.LJUserService; +import com.fuint.business.userManager.vo.LJUserVo; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; +import com.sun.xml.bind.v2.TODO; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; /** * 新人有礼记录表(ActiveNewlywedsRecords)表服务实现类 @@ -15,5 +35,71 @@ import org.springframework.stereotype.Service; @Service("activeNewlywedsRecordsService") public class ActiveNewlywedsRecordsServiceImpl extends ServiceImpl implements ActiveNewlywedsRecordsService { + @Resource + private ActiveNewlywedsService activeNewlywedsService; + @Resource + private CardFavorableRecordService cardFavorableRecordService; + @Resource + private CardExchangeRecordService cardExchangeRecordService; + @Resource + private LJUserService userService; + /** + * 新增数据 + * @param activeNewlywedsRecords + * @return + */ + @Override + @Transactional + public boolean add(ActiveNewlywedsRecords activeNewlywedsRecords) { + boolean save = false; + //用户信息 + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer userId = nowAccountInfo.getId(); + LJUserVo ljUserVo = userService.selectUserById(userId); + //保存新人有礼记录 + ActiveNewlywedsVO activeNewlyweds = activeNewlywedsService.getOneById(1); + activeNewlywedsRecords.setActiveNewlywedsId(activeNewlyweds.getId()); + activeNewlywedsRecords.setChainStoreId(nowAccountInfo.getChainStoreId()); + activeNewlywedsRecords.setStoreId(nowAccountInfo.getStoreId()); + activeNewlywedsRecords.setUserId(userId); + save = save(activeNewlywedsRecords); + //优惠券 + CardFavorableRecord cardFavorableRecord = new CardFavorableRecord(); + List activeNewlywedsChildList = activeNewlyweds.getActiveNewlywedsChildList(); + if (CollectionUtils.isNotEmpty(activeNewlywedsChildList)){ + for (ActiveNewlywedsChild activeNewlywedsChild : activeNewlywedsChildList) { + if (activeNewlywedsChild.getActiveGift().equals("1")){ + cardFavorableRecord.setCardFavorableId(activeNewlywedsChild.getActiveNewlywedsId()); + cardFavorableRecord.setChainStorId(nowAccountInfo.getChainStoreId()); + cardFavorableRecord.setStoreId(nowAccountInfo.getStoreId()); + cardFavorableRecord.setMtUserId(userId); + cardFavorableRecord.setName(ljUserVo.getName()); + cardFavorableRecord.setMobile(ljUserVo.getMobile()); + cardFavorableRecord.setName(nowAccountInfo.getRealName()); + cardFavorableRecord.setExchangeFrom("新人发券"); + save = cardFavorableRecordService.save(cardFavorableRecord); + }else { + //兑换券 + CardExchangeRecord cardExchangeRecord = new CardExchangeRecord(); + cardExchangeRecord.setCardExchangeId(activeNewlywedsChild.getActiveNewlywedsId()); + cardExchangeRecord.setChainStorId(nowAccountInfo.getChainStoreId()); + cardExchangeRecord.setStoreId(nowAccountInfo.getStoreId()); + cardExchangeRecord.setMtUserId(userId); + cardExchangeRecord.setName(ljUserVo.getName()); + cardExchangeRecord.setMobile(ljUserVo.getMobile()); + cardExchangeRecord.setExchangeName(activeNewlywedsChild.getGiftCardName()); + cardExchangeRecord.setExchangeFrom("新人领券"); + cardExchangeRecord.setGiftName(activeNewlywedsChild.getGiftCardName()); + cardExchangeRecord.setDescription(activeNewlywedsChild.getGiftCardDetail()); + save = cardExchangeRecordService.save(cardExchangeRecord); + } + } + //积分 + //成长值 TODO + } + // + + return save; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/controller/ActiveRecommendRecordsController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/controller/ActiveRecommendRecordsController.java index a9bb4b1d8..f22f8664f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/controller/ActiveRecommendRecordsController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/controller/ActiveRecommendRecordsController.java @@ -2,9 +2,6 @@ package com.fuint.business.marketingActivity.activeRecommend.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendRecords; import com.fuint.business.marketingActivity.activeRecommend.service.ActiveRecommendRecordsService; @@ -33,7 +30,7 @@ public class ActiveRecommendRecordsController extends BaseController { private ActiveRecommendRecordsService activeRecommendRecordsService; /** - * 分页查询所有数据 + * 小程序端查询邀请记录 * @param pageNo * @param pageSize * @param activeRecommendRecords @@ -44,7 +41,16 @@ public class ActiveRecommendRecordsController extends BaseController { @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, @Param("activeRecommendRecords") ActiveRecommendRecords activeRecommendRecords) { Page page = new Page(pageNo, pageSize); - return getSuccessResult(this.activeRecommendRecordsService.page(page, new QueryWrapper<>(activeRecommendRecords))); + return getSuccessResult(this.activeRecommendRecordsService.select(page, activeRecommendRecords)); + } + + /** + * 小程序端查询券总额 + * @return + */ + @GetMapping("selectAllAmount") + public ResponseObject selectAllAmount() { + return getSuccessResult(this.activeRecommendRecordsService.selectAllAmount()); } /** @@ -59,14 +65,13 @@ public class ActiveRecommendRecordsController extends BaseController { } /** - * 新增数据 - * + * 新增邀请记录接口 * @param activeRecommendRecords 实体对象 * @return 新增结果 */ @PostMapping public ResponseObject insert(@RequestBody ActiveRecommendRecords activeRecommendRecords) { - return getSuccessResult(this.activeRecommendRecordsService.save(activeRecommendRecords)); + return getSuccessResult(this.activeRecommendRecordsService.add(activeRecommendRecords)); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/entity/ActiveRecommendRecords.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/entity/ActiveRecommendRecords.java index 9de2253b3..de9da036c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/entity/ActiveRecommendRecords.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/entity/ActiveRecommendRecords.java @@ -1,7 +1,13 @@ package com.fuint.business.marketingActivity.activeRecommend.entity; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + import java.io.Serializable; /** @@ -11,8 +17,10 @@ import java.io.Serializable; * @since 2023-12-20 14:13:16 */ @SuppressWarnings("serial") +@Data public class ActiveRecommendRecords extends Model { //主键id + @TableId(type = IdType.AUTO) private Integer id; //活动id private Integer activeNewlywedsId; @@ -24,13 +32,17 @@ public class ActiveRecommendRecords extends Model { private String userId; //被邀请人id private String inviteeUserId; + //被邀请人姓名 + private String inviteeUserName; //创建者 private String createBy; //创建时间 + @JsonFormat(pattern = "yyyy-MM-dd ") private Date createTime; //更新者 private String updateBy; //更新时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/ActiveRecommendRecordsService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/ActiveRecommendRecordsService.java index af06d3de9..9c9957f34 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/ActiveRecommendRecordsService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/ActiveRecommendRecordsService.java @@ -1,5 +1,7 @@ package com.fuint.business.marketingActivity.activeRecommend.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendRecords; @@ -11,5 +13,25 @@ import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecomme */ public interface ActiveRecommendRecordsService extends IService { + /** + * 小程序端查询邀请记录 + * @param page + * @param activeRecommendRecords + * @return + */ + IPage select(Page page, ActiveRecommendRecords activeRecommendRecords); + + /** + * 小程序端查询券总额 + * @return + */ + double selectAllAmount(); + + /** + * 新增邀请记录接口 + * @param activeRecommendRecords + * @return + */ + boolean add(ActiveRecommendRecords activeRecommendRecords); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendRecordsServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendRecordsServiceImpl.java index 31a3a97f4..5a493dce4 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendRecordsServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendRecordsServiceImpl.java @@ -1,11 +1,27 @@ package com.fuint.business.marketingActivity.activeRecommend.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendChild; import com.fuint.business.marketingActivity.activeRecommend.mapper.ActiveRecommendRecordsMapper; import com.fuint.business.marketingActivity.activeRecommend.entity.ActiveRecommendRecords; import com.fuint.business.marketingActivity.activeRecommend.service.ActiveRecommendRecordsService; +import com.fuint.business.marketingActivity.activeRecommend.service.ActiveRecommendService; +import com.fuint.business.marketingActivity.activeRecommend.vo.ActiveRecommendRecordsVO; +import com.fuint.business.marketingActivity.activeRecommend.vo.ActiveRecommendVO; +import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + /** * 邀请有礼记录表(ActiveRecommendRecords)表服务实现类 * @@ -15,5 +31,108 @@ import org.springframework.stereotype.Service; @Service("activeRecommendRecordsService") public class ActiveRecommendRecordsServiceImpl extends ServiceImpl implements ActiveRecommendRecordsService { + @Resource + private ActiveRecommendService activeRecommendService; + @Resource + private CardFavorableService cardFavorableService; + /** + * 小程序端查询邀请记录 + * @param page + * @param activeRecommendRecords + * @return + */ + @Override + public IPage select(Page page, ActiveRecommendRecords activeRecommendRecords) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer userId = nowAccountInfo.getId(); + Integer storeId = nowAccountInfo.getStoreId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActiveRecommendRecords::getUserId,userId); + queryWrapper.eq(ActiveRecommendRecords::getStoreId,storeId); + /*IPage page1 = page(page, queryWrapper); + List records = page1.getRecords(); + List collect = records.stream().map(s -> { + ActiveRecommendRecordsVO activeRecommendRecordsVO = new ActiveRecommendRecordsVO(); + + s.getActiveNewlywedsId() + BeanUtils.copyProperties(s, activeRecommendRecordsVO); + return activeRecommendRecordsVO; + }).collect(Collectors.toList()); + page1.setRecords(collect);*/ + /*//券总额 + double discountAmount = 0.0; + //推荐有礼活动 + ActiveRecommendVO activeRecommendVO = activeRecommendService.getOneById(1); + //活动所送推荐人的优惠券 + List activeRecommendChildList = activeRecommendVO.getActiveRecommendChildList(); + if(CollectionUtils.isNotEmpty(activeRecommendChildList)){ + for (ActiveRecommendChild activeRecommendChild : activeRecommendChildList) { + if (activeRecommendChild.getActiveGift().equals("0")){ + //券数量 + Integer giftCardTotal = activeRecommendChild.getGiftCardTotal(); + //券id + Integer vouchersId = activeRecommendChild.getVouchersId(); + //券总额 + discountAmount += (cardFavorableService.getById(vouchersId).getDiscountAmount() * giftCardTotal); + } + } + } + IPage page1 = page(page, queryWrapper); + List records = page1.getRecords();*/ + return page(page, queryWrapper); + } + + @Override + public double selectAllAmount() { + //券总额 + double discountAmount = 0.0; + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer userId = nowAccountInfo.getId(); + Integer storeId = nowAccountInfo.getStoreId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActiveRecommendRecords::getUserId,userId); + queryWrapper.eq(ActiveRecommendRecords::getStoreId,storeId); + List list = list(queryWrapper); + if (CollectionUtils.isNotEmpty(list)){ + //邀请人数 + int size = list.size(); + //推荐有礼活动 + ActiveRecommendVO activeRecommendVO = activeRecommendService.getOneById(1); + //活动所送推荐人的优惠券 + List activeRecommendChildList = activeRecommendVO.getActiveRecommendChildList(); + if(CollectionUtils.isNotEmpty(activeRecommendChildList)){ + for (ActiveRecommendChild activeRecommendChild : activeRecommendChildList) { + if (activeRecommendChild.getActiveGift().equals("1")){ + //券数量 + Integer giftCardTotal = activeRecommendChild.getGiftCardTotal(); + //券id + Integer vouchersId = activeRecommendChild.getVouchersId(); + //券总额 + discountAmount += (cardFavorableService.getById(vouchersId).getDiscountAmount() * giftCardTotal * size); + } + } + } + } + return discountAmount; + } + + /** + * 新增邀请记录接口 + * @param activeRecommendRecords + * @return + */ + @Override + public boolean add(ActiveRecommendRecords activeRecommendRecords) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer userId = nowAccountInfo.getId(); + Integer storeId = nowAccountInfo.getStoreId(); + //邀请人id TODO + activeRecommendRecords.setUserId(userId.toString()); + activeRecommendRecords.setStoreId(storeId); + //被邀请人id + activeRecommendRecords.setInviteeUserId(userId.toString()); + activeRecommendRecords.setInviteeUserName(nowAccountInfo.getRealName()); + return save(activeRecommendRecords); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendServiceImpl.java index 9e9445459..073a350dc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeRecommend/service/impl/ActiveRecommendServiceImpl.java @@ -197,9 +197,13 @@ public class ActiveRecommendServiceImpl extends ServiceImpl idList) { + return getSuccessResult(this.cardFavorableRecordService.drawDown(idList)); + } + + /** + * 小程序端判断是否领取优惠券 + * @return 新增结果 + */ + @GetMapping("isDrawDown") + public ResponseObject isDrawDown() { + return getSuccessResult(this.cardFavorableRecordService.isDrawDown()); + } + /** * 修改数据 * diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/CardFavorableRecordService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/CardFavorableRecordService.java index fca3063fa..337b0c8d1 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/CardFavorableRecordService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/CardFavorableRecordService.java @@ -7,6 +7,7 @@ import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRe import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableRecordVO; import java.io.Serializable; +import java.util.List; import java.util.Map; /** @@ -34,5 +35,17 @@ public interface CardFavorableRecordService extends IService selectCount(CardFavorableRecord cardFavorableRecord); + /** + * 小程序端优惠券领取接口 + * @param idList + * @return + */ + boolean drawDown(List idList); + + /** + * 小程序端判断是否领取优惠券 + * @return + */ + boolean isDrawDown(); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableRecordServiceImpl.java index 5aa184c39..cb5898ce3 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableRecordServiceImpl.java @@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFavorable.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable; @@ -9,6 +10,9 @@ import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableRe import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService; import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableRecordVO; +import com.fuint.business.userManager.service.LJUserService; +import com.fuint.business.userManager.vo.LJUserVo; +import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; @@ -30,6 +34,8 @@ public class CardFavorableRecordServiceImpl extends ServiceImpl idList) { + boolean save = false; + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer userId = nowAccountInfo.getId(); + LJUserVo ljUserVo = userService.selectUserById(userId); + //优惠券 + for (Integer id : idList) { + CardFavorableRecord cardFavorableRecord = new CardFavorableRecord(); + cardFavorableRecord.setCardFavorableId(id); + cardFavorableRecord.setChainStorId(nowAccountInfo.getChainStoreId()); + cardFavorableRecord.setStoreId(nowAccountInfo.getStoreId()); + cardFavorableRecord.setMtUserId(userId); + cardFavorableRecord.setName(ljUserVo.getName()); + cardFavorableRecord.setMobile(ljUserVo.getMobile()); + cardFavorableRecord.setName(nowAccountInfo.getRealName()); + cardFavorableRecord.setExchangeFrom("店铺发券"); + save = save(cardFavorableRecord); + } + return save; + } + + /** + * 小程序端判断是否领取优惠券 + * @return + */ + @Override + public boolean isDrawDown() { + boolean isDrawDown = false; + //登录用户信息 + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardFavorableRecord::getMtUserId,nowAccountInfo.getId()); + queryWrapper.eq(CardFavorableRecord::getStoreId,nowAccountInfo.getStoreId()); + //如果领过券 就不让领了 + List list = list(queryWrapper); + if (CollectionUtils.isNotEmpty(list) && list.size() == 0){ + isDrawDown = true; + } + return isDrawDown; + } } diff --git a/gasStation-uni/pages/index/index.vue b/gasStation-uni/pages/index/index.vue index 1753e0357..ec2ae5b13 100644 --- a/gasStation-uni/pages/index/index.vue +++ b/gasStation-uni/pages/index/index.vue @@ -104,7 +104,7 @@ - + 立即领取 @@ -122,9 +122,10 @@ export default { data() { return { + joinmsg: '', msg: "1", show: false, - shows: true, + shows: '', title: '', oilTypeList: '', columns: [ @@ -184,12 +185,66 @@ this.getOilType(); }, onShow() { + this.isJoined() // this.isExistStoreId(); }, components: { tabbar }, methods: { + //判断是否是新人 + isJoined() { + request({ + url: 'business/marketingActivity/activeNewlywedsRecords/applet', + method: 'get', + }).then(res => { + console.log("11111" + res) + if (res.code == 200 && res.data == 1) { + this.shows = true + } else { + this.shows = false + } + }) + }, + //立即领取 + drawDown() { + /* this.shows = false */ + request({ + url: 'business/marketingActivity/activeNewlywedsRecords', + method: 'post', + data: { + + } + }).then(res => { + console.log("11111" + res) + if (res.code == 200 && res.data == true) { + this.shows = false + uni.showToast({ + title: '领取成功!' + }) + } else { + this.shows = false + uni.showToast({ + title: '领取失败!' + }) + } + + /* if (res.code == 200 && res.data == 1) { + this.shows = true + } else { + this.shows = false + } */ + }) + }, + //查询新人有礼礼品 + selectActiveNewlyweds() { + request({ + url: 'business/marketingActivity/activeNewlyweds/applet', + method: 'get', + }).then(res => { + console.log("11111" + res) + }) + }, isExistStoreId() { if (uni.getStorageSync("storeId") != "") { this.getStore(uni.getStorageSync("storeId")); @@ -243,7 +298,8 @@ _this.welfare.push(response.data.welfare) } } - if (response.data.doorstepPhoto != undefined && response.data.doorstepPhoto != null && response.data.doorstepPhoto != ""){ + if (response.data.doorstepPhoto != undefined && response.data + .doorstepPhoto != null && response.data.doorstepPhoto != "") { let list = JSON.parse(response.data.doorstepPhoto) _this.list3 = []; list.forEach(item => { @@ -275,14 +331,18 @@ "lat": res.latitude }, }).then((response) => { - _this.distance = (Math.ceil(response.data.distance)).toFixed(1) + _this.distance = (Math.ceil(response.data.distance)) + .toFixed(1) _this.store = response.data.store uni.setStorageSync("storeId", response.data.store.id) - uni.setStorageSync("chainStoreId", response.data.store.chainStoreId) + uni.setStorageSync("chainStoreId", response.data.store + .chainStoreId) let welfare = response.data.store.welfare - if (welfare != undefined && welfare != null && welfare != "") { + if (welfare != undefined && welfare != null && + welfare != "") { if (welfare.includes(",")) { - _this.welfare = response.data.store.welfare.split(",") + _this.welfare = response.data.store.welfare + .split(",") } else { _this.welfare.push(response.data.store.welfare) } @@ -349,12 +409,13 @@ cancel() { this.show = false }, - onOverlay() { + /* onOverlay() { + this.drawDown(); this.shows = false uni.showToast({ title: '领取成功' }) - }, + }, */ goActivity() { // 去活动页 uni.navigateTo({ @@ -674,4 +735,4 @@ color: white; margin: 0 auto; } - + \ No newline at end of file diff --git a/gasStation-uni/pages/my/my.vue b/gasStation-uni/pages/my/my.vue index e1f8055ee..6662e6e09 100644 --- a/gasStation-uni/pages/my/my.vue +++ b/gasStation-uni/pages/my/my.vue @@ -266,9 +266,10 @@ // console.log(res,111222) if (res.code == 200) { this.cardBalance = res.data.cardBalance, - if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){ + /* if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){ + this.refuelMoney = JSON.parse(res.data.refuelMoney); + } */ this.refuelMoney = JSON.parse(res.data.refuelMoney); - } } }) }, @@ -293,7 +294,7 @@ chainStoreId: this.chainStoreId } }).then((res) => { - if (res.code == 200 && res.data!=null) { + if (res.code == 200 && res.data != null) { this.myPoints = res.data.points } }) diff --git a/gasStation-uni/pagesHome/activeIn/index.vue b/gasStation-uni/pagesHome/activeIn/index.vue index 9aaf11b90..f27f34cfd 100644 --- a/gasStation-uni/pagesHome/activeIn/index.vue +++ b/gasStation-uni/pagesHome/activeIn/index.vue @@ -158,7 +158,7 @@ - + 去参与