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