订单页优惠券查询
邀请页 是否可邀请 是否可领取
This commit is contained in:
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CouponDto {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
||||
boolean isUse = true;
|
||||
TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId());
|
||||
StringBuilder useRestrictions = new StringBuilder("每天 ");
|
||||
if (tbShopCoupon.getType().equals(1)) {
|
||||
if (amount != null && tbShopCoupon.getType().equals(1)) {
|
||||
if (amount.compareTo(tbShopCoupon.getFullAmount()) < 0) {
|
||||
isUse = false;
|
||||
}
|
||||
@@ -125,39 +125,29 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
||||
if (param.getOrderId() != null) {
|
||||
|
||||
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString());
|
||||
TbOrderInfo tbOrderInfo = orderInfoMapper.selectByPrimaryKey(param.getOrderId());
|
||||
List<TbOrderDetail> tbOrderDetails = orderDetailMapper.selectAllByOrderId(param.getOrderId());
|
||||
Set<Integer> pros = tbOrderDetails.stream().map(TbOrderDetail::getProductId).collect(Collectors.toSet());
|
||||
if (CollectionUtil.isNotEmpty(tbOrderDetails)) {
|
||||
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), param.getShopId());
|
||||
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
||||
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||
LocalTime now = LocalTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), param.getShopId());
|
||||
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
||||
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||
LocalTime now = LocalTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
|
||||
//券id 券使用描述
|
||||
Map<Integer, JsonObject> coupons = new HashMap<>();
|
||||
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
||||
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
|
||||
setCouponInfo(coupons, tbUserCouponVo, tbOrderInfo.getAmount(), week, now, formatter);
|
||||
}
|
||||
JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
|
||||
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
||||
if (tbUserCouponVo.getType().equals(1)) {
|
||||
tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean());
|
||||
} else if (tbUserCouponVo.getType().equals(2) && couponJson.get("isUse").getAsBoolean()) {
|
||||
if (!pros.contains(tbUserCouponVo.getProId())) {
|
||||
tbUserCouponVo.setUse(false);
|
||||
}
|
||||
}
|
||||
//券id 券使用描述
|
||||
Map<Integer, JsonObject> coupons = new HashMap<>();
|
||||
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
||||
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
|
||||
setCouponInfo(coupons, tbUserCouponVo, null, week ,now, formatter);
|
||||
}
|
||||
tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime));
|
||||
return new Result(CodeEnum.SUCCESS, tbUserCouponVos);
|
||||
JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
|
||||
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
||||
tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean());
|
||||
|
||||
}
|
||||
tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime));
|
||||
return new Result(CodeEnum.SUCCESS, tbUserCouponVos);
|
||||
}
|
||||
} else {
|
||||
List<TbShopUser> tbShopUser = shopUserMapper.selectAllByUserId(param.getUserId().toString());
|
||||
if(CollectionUtil.isNotEmpty(tbShopUser)){
|
||||
if (CollectionUtil.isNotEmpty(tbShopUser)) {
|
||||
List<Integer> ids = tbShopUser.stream().map(TbShopUser::getId).map(Integer::valueOf).collect(Collectors.toList());
|
||||
if (param.getStatus().equals(1)) {
|
||||
return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopId(ids, param.getShopId()));
|
||||
@@ -189,7 +179,7 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
||||
TbShopShareRecord shareRecord = shareRecordMapper.queryById(inRecord.getSourceActId());
|
||||
if (shareRecord.getMethod().equals("use")) {
|
||||
shareRecord.setStatus(3);
|
||||
shareRecordService.give(shareRecord,shareRecord.getInvitedId());
|
||||
shareRecordService.give(shareRecord, shareRecord.getInvitedId());
|
||||
shareRecordMapper.update(shareRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
||||
@Override
|
||||
public Map query(TbShopShareRecord tbShopShareRecord) {
|
||||
Map<String, Object> result = tbShopShareRecordMapper.statisticsRecord(tbShopShareRecord);
|
||||
if(CollectionUtil.isEmpty(result)){
|
||||
result=new HashMap<>();
|
||||
result.put("isSuccess",0);
|
||||
result.put("isFail",0);
|
||||
if (CollectionUtil.isEmpty(result)) {
|
||||
result = new HashMap<>();
|
||||
result.put("isSuccess", 0);
|
||||
result.put("isFail", 0);
|
||||
}
|
||||
PageHelper.startPage(tbShopShareRecord.getPage(), tbShopShareRecord.getSize());
|
||||
|
||||
List<TbShopShareRecord> records;
|
||||
if(tbShopShareRecord.isSuccess()){
|
||||
if (tbShopShareRecord.isSuccess()) {
|
||||
records = tbShopShareRecordMapper.queryIsSuccess(tbShopShareRecord);
|
||||
}else {
|
||||
} else {
|
||||
records = tbShopShareRecordMapper.queryIsNoSuccess(tbShopShareRecord);
|
||||
}
|
||||
for (TbShopShareRecord shareRecord : records) {
|
||||
shareRecord.setBeInvitedName(userInfoMapper.selectNameByPrimaryKey(shareRecord.getBeInvitedId()));
|
||||
}
|
||||
result.put("records",new PageInfo<>());
|
||||
result.put("records", new PageInfo<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
||||
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
|
||||
tbShopShareRecord.setCreateTime(new Date());
|
||||
tbShopShareRecord.setUpdateTime(new Date());
|
||||
}else {
|
||||
} else {
|
||||
query.setUpdateTime(new Date());
|
||||
}
|
||||
if (shopUserInfo == null) {
|
||||
@@ -139,7 +139,7 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
||||
}
|
||||
saveShopUser(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
|
||||
} else {
|
||||
if (query == null){
|
||||
if (query == null) {
|
||||
tbShopShareRecord.setStatus(0);
|
||||
tbShopShareRecordMapper.insert(tbShopShareRecord);
|
||||
}
|
||||
@@ -150,6 +150,9 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
||||
for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) {
|
||||
TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId());
|
||||
if (coupon != null) {
|
||||
if (coupon.getLeftNumber() <= 0) {
|
||||
query.setStatus(0);
|
||||
}
|
||||
if (coupon.getType() == 1) {
|
||||
//满减
|
||||
newCoupon.setType(1);
|
||||
@@ -286,6 +289,8 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
||||
}
|
||||
}
|
||||
activateInRecordMapper.insertBatch(actGiveRecords);
|
||||
tbShopCoupon.setLeftNumber(tbShopCoupon.getLeftNumber()-newCoupon.getCouponNum());
|
||||
couponMapper.update(tbShopCoupon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public class TbShopShareServiceImpl implements TbShopShareService {
|
||||
for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) {
|
||||
TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId());
|
||||
if (coupon != null) {
|
||||
if (coupon.getLeftNumber() <= 0) {
|
||||
tbShopShare.setStatus(0);
|
||||
}
|
||||
if (coupon.getType() == 1) {
|
||||
//满减
|
||||
newCoupon.setType(1);
|
||||
|
||||
Reference in New Issue
Block a user