| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.system.common.init.UserCacheManager; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.activity.dao.ActivitySignAwardSetDao; |
| | |
| | | import com.matrix.system.activity.entity.ActivitySignReceiveRecord; |
| | | import com.matrix.system.activity.entity.ActivitySignRecord; |
| | | import com.matrix.system.activity.entity.ActivitySignWriteoff; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.score.entity.ScoreVipDetail; |
| | | import com.matrix.system.score.service.ScoreVipDetailService; |
| | | import com.matrix.system.shopXcx.api.dto.SeeAwardTextDto; |
| | | import com.matrix.system.shopXcx.api.dto.SignAwardDto; |
| | | import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; |
| | | import com.matrix.system.shopXcx.api.tools.WxShopCouponUtil; |
| | | import com.matrix.system.shopXcx.api.vo.*; |
| | | import com.matrix.system.shopXcx.bean.ShopActivities; |
| | | import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; |
| | | import com.matrix.system.shopXcx.bean.ShopLogisticsInfo; |
| | | import com.matrix.system.shopXcx.bean.ShopReceiveAddress; |
| | | import com.matrix.system.shopXcx.dao.ShopActivitiesDao; |
| | | import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopReceiveAddressDao; |
| | | import com.matrix.system.shopXcx.bean.*; |
| | | import com.matrix.system.shopXcx.dao.*; |
| | | import com.matrix.system.shopXcx.vo.SalesOrderVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | private ShopActivitiesDao shopActivitiesDao; |
| | | |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | | private UserCacheManager userCacheManager; |
| | | |
| | | @Autowired |
| | | private ActivitySignAwardSetDao activitySignAwardSetDao; |
| | |
| | | |
| | | @Autowired |
| | | private WxShopLogisticsQueryService wxShopLogisticsQueryService; |
| | | @Autowired |
| | | private ScoreVipDetailService scoreVipDetailService; |
| | | @Autowired |
| | | private ShopCouponDao shopCouponDao; |
| | | @Autowired |
| | | private WxShopCouponUtil wxShopCouponUtil; |
| | | @Autowired |
| | | private ShopCouponRecordDao shopCouponRecordDao; |
| | | |
| | | @ApiOperation(value = "获取签到基本信息", notes = "") |
| | | @ApiResponses({ |
| | |
| | | @GetMapping(value = "/getSignBasicInfo") |
| | | public AjaxResult getSignBasicInfo() { |
| | | //获取登录人信息 |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | Long companyId = loginUser.getCompanyId(); |
| | | Long userId = loginUser.getId(); |
| | | //获取签到活动的信息 |
| | |
| | | @ResponseBody |
| | | public AjaxResult getSignRecord(@PathVariable("actId") long actId,@PathVariable("month") String dateStr) { |
| | | //获取登录人信息 |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | Long companyId = loginUser.getCompanyId(); |
| | | Long userId = loginUser.getId(); |
| | | Date date = DateUtil.parse(dateStr); |
| | |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult clickSign(@PathVariable("actId") long actId) { |
| | | SysVipInfo user = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo user = userCacheManager.getLoginUser(); |
| | | Long userId = user.getId(); |
| | | Long companyId = user.getCompanyId(); |
| | | /** |
| | |
| | | * 查询是否有签到奖品 |
| | | * 日常奖励和自定义奖品 |
| | | */ |
| | | SignSuccessVo signSuccessVo = new SignSuccessVo(); |
| | | List<SignSuccessVo> signSuccessVos = new ArrayList<>(); |
| | | //日常奖励,新增奖品领取记录 |
| | | QueryWrapper<ActivitySignAwardSet> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("award_rule",ActivitySignAwardSet.AWARDRULE_NORMAL); |
| | |
| | | activitySignReceiveRecord.setUpdateTime(new Date()); |
| | | activitySignReceiveRecordDao.insert(activitySignReceiveRecord); |
| | | |
| | | SignSuccessVo signSuccessVo = new SignSuccessVo(); |
| | | signSuccessVo.setType(1); |
| | | signSuccessVo.setScoreCnt(activitySignAwardSetNormal.getScoreCnt()); |
| | | signSuccessVo.setNormalAwardName(activitySignAwardSetNormal.getAwardName()); |
| | | signSuccessVo.setNormalAwardImg(activitySignAwardSetNormal.getIntroduceImg()); |
| | | signSuccessVo.setAwardName(activitySignAwardSetNormal.getAwardName()); |
| | | signSuccessVo.setAwardImg(activitySignAwardSetNormal.getIntroduceImg()); |
| | | signSuccessVos.add(signSuccessVo); |
| | | |
| | | //日常奖励积分,对应用户积分加减 |
| | | int awardType = activitySignAwardSetNormal.getAwardType(); |
| | | if(ActivitySignAwardSet.AWARDTYPE_SCORE == awardType){ |
| | | int scoreCnt = activitySignAwardSetNormal.getScoreCnt(); |
| | | if(scoreCnt > 0){ |
| | | scoreVipDetailService.addScore(userId,null,null,scoreCnt, |
| | | activitySignReceiveRecord.getId(), ScoreVipDetail.SCORE_VIP_TYPE_JOIN_ACTIVE,"签到积分"); |
| | | } |
| | | } |
| | | //获取优惠券 |
| | | if(ActivitySignAwardSet.AWARDTYPE_COUPON == awardType){ |
| | | //获取优惠券 |
| | | int couponId = Integer.parseInt(activitySignAwardSetNormal.getCouponId()); |
| | | ShopCoupon shopCoupon = shopCouponDao.selectById(couponId); |
| | | // 如果没有找到该优惠券 |
| | | if (shopCoupon == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "没有找到该优惠券!"); |
| | | } |
| | | // 如果优惠券有数量限制并且已经领完 |
| | | if (shopCoupon.getMaxQuantity() >= 0 && (shopCoupon.getMaxQuantity() <= shopCoupon.getQuantityReceive())) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "优惠券已领完!"); |
| | | } |
| | | boolean newPeople = wxShopCouponUtil.verifyIsNewPeople(userId); |
| | | // 如果改券是新人专属且当前用户不是新人 |
| | | if (AppConstance.COUPON_GET_LIMT_NEW.equals(shopCoupon.getGetLimit()) && !newPeople) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "该优惠券为新人专享优惠券!"); |
| | | } |
| | | ShopCouponRecord insertRecord = new ShopCouponRecord(); |
| | | insertRecord.setCreateBy(AppConstance.SYSTEM_USER); |
| | | insertRecord.setUpdateBy(AppConstance.SYSTEM_USER); |
| | | insertRecord.setCId(couponId); |
| | | insertRecord.setUserId(userId); |
| | | insertRecord.setIsUsing(2); |
| | | int i = shopCouponRecordDao.insert(insertRecord); |
| | | // 如果插入领取记录表失败 |
| | | if (i < 0) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "优惠券领取失败!"); |
| | | } |
| | | shopCoupon.setQuantityReceive(shopCoupon.getQuantityReceive() + 1); |
| | | shopCouponDao.updateByModel(shopCoupon); |
| | | } |
| | | } |
| | | //获取当前累计天数 |
| | | int cumulativeDay = getCumulativeDay(actId, userId, date, 0); |
| | |
| | | if (ObjectUtil.isNotEmpty(activitySignReceiveRecordDone)) { |
| | | String awardNameCumulativeDay = activitySignAwardSetCumulativeDay.getAwardName(); |
| | | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance(awardNameCumulativeDay+"已经领取过了"); |
| | | ajaxResult.setData(signSuccessVo); |
| | | ajaxResult.setData(signSuccessVos); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | SignSuccessVo signSuccessVo = new SignSuccessVo(); |
| | | signSuccessVo.setType(2); |
| | | signSuccessVo.setAwardType(activitySignAwardSetCumulativeDay.getAwardType()); |
| | | signSuccessVo.setAwardName(activitySignAwardSetCumulativeDay.getAwardName()); |
| | | signSuccessVo.setAwardImg(activitySignAwardSetCumulativeDay.getIntroduceImg()); |
| | | signSuccessVo.setAwardState(activitySignAwardSetCumulativeDay.getAwardState()); |
| | | //新增奖品领取记录 |
| | | ActivitySignReceiveRecord activitySignReceiveRecord = new ActivitySignReceiveRecord(); |
| | | activitySignReceiveRecord.setUserId(userId); |
| | |
| | | * 获取对应奖品的领取方式(兑奖方式(1:线下兑换2:物流配送3:客服兑换) |
| | | */ |
| | | signSuccessVo.setWriteOffCode(randomString); |
| | | signSuccessVo.setAwardType(activitySignAwardSetCumulativeDay.getAwardType()); |
| | | signSuccessVo.setAwardName(activitySignAwardSetCumulativeDay.getAwardName()); |
| | | signSuccessVo.setAwardImg(activitySignAwardSetCumulativeDay.getIntroduceImg()); |
| | | signSuccessVo.setAwardWay(activitySignAwardSetCumulativeDay.getAwardWay()); |
| | | signSuccessVo.setAwardState(activitySignAwardSetCumulativeDay.getAwardState()); |
| | | //2:物流配送 |
| | | signSuccessVo.setOperationTip(activitySignAwardSetCumulativeDay.getOperationTip()); |
| | | //1:线下兑换 |
| | |
| | | //3:优惠券 |
| | | if(ActivitySignAwardSet.AWARDTYPE_COUPON == activitySignAwardSetCumulativeDay.getAwardType()) { |
| | | signSuccessVo.setCouponName(activitySignAwardSetCumulativeDay.getCouponName()); |
| | | //获取优惠券 |
| | | int couponId = Integer.parseInt(activitySignAwardSetCumulativeDay.getCouponId()); |
| | | ShopCoupon shopCoupon = shopCouponDao.selectById(couponId); |
| | | // 如果没有找到该优惠券 |
| | | if (shopCoupon == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "没有找到该优惠券!"); |
| | | } |
| | | // 如果优惠券有数量限制并且已经领完 |
| | | if (shopCoupon.getMaxQuantity() >= 0 && (shopCoupon.getMaxQuantity() <= shopCoupon.getQuantityReceive())) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "优惠券已领完!"); |
| | | } |
| | | boolean newPeople = wxShopCouponUtil.verifyIsNewPeople(userId); |
| | | // 如果改券是新人专属且当前用户不是新人 |
| | | if (AppConstance.COUPON_GET_LIMT_NEW.equals(shopCoupon.getGetLimit()) && !newPeople) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "该优惠券为新人专享优惠券!"); |
| | | } |
| | | ShopCouponRecord insertRecord = new ShopCouponRecord(); |
| | | insertRecord.setCreateBy(AppConstance.SYSTEM_USER); |
| | | insertRecord.setUpdateBy(AppConstance.SYSTEM_USER); |
| | | insertRecord.setCId(couponId); |
| | | insertRecord.setUserId(userId); |
| | | insertRecord.setIsUsing(2); |
| | | int i = shopCouponRecordDao.insert(insertRecord); |
| | | // 如果插入领取记录表失败 |
| | | if (i < 0) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "优惠券领取失败!"); |
| | | } |
| | | shopCoupon.setQuantityReceive(shopCoupon.getQuantityReceive() + 1); |
| | | shopCouponDao.updateByModel(shopCoupon); |
| | | } |
| | | activitySignReceiveRecordDao.insert(activitySignReceiveRecord); |
| | | //累计奖励积分,对应用户积分加减 |
| | | if(ActivitySignAwardSet.AWARDTYPE_SCORE == activitySignAwardSetCumulativeDay.getAwardType()) { |
| | | int awardType = activitySignAwardSetCumulativeDay.getAwardType(); |
| | | if(ActivitySignAwardSet.AWARDTYPE_SCORE == awardType){ |
| | | int scoreCnt = activitySignAwardSetCumulativeDay.getScoreCnt(); |
| | | if(scoreCnt > 0){ |
| | | scoreVipDetailService.addScore(userId,null,null,scoreCnt, |
| | | activitySignReceiveRecord.getId(), ScoreVipDetail.SCORE_VIP_TYPE_JOIN_ACTIVE,"签到积分"); |
| | | } |
| | | } |
| | | } |
| | | //生成核销记录 |
| | | if(ActivitySignAwardSet.AWARDTYPE_CUSTOMIZE == activitySignAwardSetCumulativeDay.getAwardType()) { |
| | | ActivitySignWriteoff activitySignWriteoff = new ActivitySignWriteoff(); |
| | |
| | | activitySignWriteoff.setUpdateTime(new Date()); |
| | | activitySignWriteoffDao.insert(activitySignWriteoff); |
| | | } |
| | | signSuccessVos.add(signSuccessVo); |
| | | } |
| | | } |
| | | } |
| | | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("签到成功"); |
| | | ajaxResult.setData(signSuccessVo); |
| | | ajaxResult.setData(signSuccessVos); |
| | | return ajaxResult; |
| | | } |
| | | /** |
| | |
| | | DateTime offsetDay = DateUtil.offsetDay(date, -i); |
| | | return getCumulativeDay(actId,userId,offsetDay,i); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取累计的签到奖品 |
| | | * |
| | |
| | | @ApiResponse(code = 200, message = "ok", response = SignAwardListVo.class) |
| | | }) |
| | | public AjaxResult getSignAwardList(@RequestBody @Validated SignAwardDto signAwardDto) { |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | Page<SalesOrderVo> page=new Page<>(signAwardDto.getPageNum(),signAwardDto.getPageSize()); |
| | | if(StringUtils.isBlank(signAwardDto.getSort())){ |
| | | signAwardDto.setSort("create_time"); |
| | |
| | | @ApiResponse(code = 200, message = "ok", response = SeeAwardTextVo.class) |
| | | }) |
| | | public AjaxResult seeAwardText(@RequestBody @Validated SeeAwardTextDto seeAwardTextDto) { |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | seeAwardTextDto.setUserId(loginUser.getId()); |
| | | seeAwardTextDto.setCompanyId(loginUser.getCompanyId()); |
| | | SeeAwardTextVo seeAwardTextVO = activitySignReceiveRecordDao.selectSeeAwardTextVOById(seeAwardTextDto); |
| | |
| | | @ApiResponse(code = 200, message = "ok", response = SeeAwardTextVo.class) |
| | | }) |
| | | public AjaxResult logisticsInsure(@RequestBody @Validated SeeAwardTextDto seeAwardTextDto) { |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | seeAwardTextDto.setUserId(loginUser.getId()); |
| | | seeAwardTextDto.setCompanyId(loginUser.getCompanyId()); |
| | | SeeAwardTextVo seeAwardTextVO = activitySignReceiveRecordDao.selectSeeAwardTextVOById(seeAwardTextDto); |