| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private WxShopLogisticsQueryService wxShopLogisticsQueryService; |
| | | @Autowired |
| | | private ScoreVipDetailService scoreVipDetailService; |
| | | @Autowired |
| | | private ShopCouponDao shopCouponDao; |
| | | @Autowired |
| | | private WxShopCouponUtil wxShopCouponUtil; |
| | | @Autowired |
| | | private ShopCouponRecordDao shopCouponRecordDao; |
| | | |
| | | @ApiOperation(value = "获取签到基本信息", notes = "") |
| | | @ApiResponses({ |
| | |
| | | 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); |
| | |
| | | //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(); |
| | |
| | | DateTime offsetDay = DateUtil.offsetDay(date, -i); |
| | | return getCumulativeDay(actId,userId,offsetDay,i); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取累计的签到奖品 |
| | | * |