Merge branch 'feature/my-invitation' into preview
commit
2385b58bb0
|
@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -140,4 +141,16 @@ public class MemberController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据会员等级和活动计算支付金额
|
||||
*/
|
||||
@GetMapping("calculatePayment")
|
||||
public AjaxResult calculatePayment(@NotNull(message = "请选择会员") Long memberLevelId, @RequestParam(required = false) Long promotionId) {
|
||||
MemberLevel memberLevel = memberLevelService.getById(memberLevelId);
|
||||
Double unitPrice = memberLevel.getUnitPrice();
|
||||
unitPrice = memberService.calculatePayment(unitPrice, promotionId);
|
||||
return AjaxResult.success(unitPrice);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mcwl.memberCenter.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.memberCenter.domain.Member;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
public interface MemberService extends IService<Member> {
|
||||
|
@ -41,4 +42,6 @@ public interface MemberService extends IService<Member> {
|
|||
* @param consumePoints 消费积分
|
||||
*/
|
||||
void consumePoints(Double consumePoints);
|
||||
|
||||
Double calculatePayment(Double unitPrice, Long promotionId);
|
||||
}
|
||||
|
|
|
@ -214,6 +214,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double calculatePayment(Double unitPrice, Long promotionId) {
|
||||
if (Objects.isNull(promotionId)) {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
Promotion promotion = promotionMapper.selectById(promotionId);
|
||||
if (Objects.isNull(promotion)) {
|
||||
return unitPrice;
|
||||
}
|
||||
PromotionEnum activityType = promotion.getActivityType();
|
||||
if (activityType == PromotionEnum.DISCOUNT) {
|
||||
return unitPrice * promotion.getActivityValue();
|
||||
}
|
||||
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
private void saveMemberConsume(Double consumePoints, Long userId, double points) {
|
||||
MemberConsume memberConsume = new MemberConsume();
|
||||
memberConsume.setUserId(userId);
|
||||
|
|
|
@ -85,4 +85,9 @@ public class ModelImage extends BaseEntity {
|
|||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否置顶
|
||||
*/
|
||||
private Integer isTop;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
|||
BeanUtil.copyProperties(modelImageRes, modelImage);
|
||||
modelImage.setUserId(SecurityUtils.getUserId());
|
||||
modelImage.setCreateBy(SecurityUtils.getUsername());
|
||||
modelImage.setCreateTime(new Date());
|
||||
modelImage.setUpdateBy(SecurityUtils.getUsername());
|
||||
modelImage.setUpdateTime(new Date());
|
||||
modelImage.setStatus(3);
|
||||
|
|
Loading…
Reference in New Issue