| | |
| | | import com.mzl.flower.dto.response.payment.OrderSalesItemChargeDTO; |
| | | import com.mzl.flower.entity.customer.Customer; |
| | | import com.mzl.flower.entity.flower.*; |
| | | import com.mzl.flower.entity.menber.Member; |
| | | import com.mzl.flower.entity.partner.Partner; |
| | | import com.mzl.flower.entity.payment.FeeService; |
| | | import com.mzl.flower.entity.payment.OrderItemSales; |
| | |
| | | import com.mzl.flower.entity.supplier.Supplier; |
| | | import com.mzl.flower.mapper.customer.CustomerMapper; |
| | | import com.mzl.flower.mapper.flower.FlowerCategoryMapper; |
| | | import com.mzl.flower.mapper.member.MemberMapper; |
| | | import com.mzl.flower.mapper.partner.PartnerMapper; |
| | | import com.mzl.flower.mapper.supplier.SupplierMapper; |
| | | import com.mzl.flower.mapper.system.UserMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Autowired |
| | | private FlowerCategoryMapper flowerCategoryMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | protected Member getMember(Long levelId){ |
| | | return memberMapper.selectById(levelId); |
| | | } |
| | | |
| | | @Autowired |
| | | private StringCacheClient stringCacheClient; |
| | |
| | | return p; |
| | | } |
| | | |
| | | /** |
| | | * 计算会员单价 |
| | | * |
| | | * @param price |
| | | * @param member |
| | | * @return |
| | | */ |
| | | protected BigDecimal calculateMemberPrice(BigDecimal price, Member member){ |
| | | if(price == null || member == null){ |
| | | return price; |
| | | } |
| | | BigDecimal r = price; |
| | | |
| | | String discountType = member.getDiscountType(); |
| | | if(Constants.DISCOUNT_TYPE.ratio.name().equals(discountType)){ |
| | | BigDecimal discountRatio = getAmount(member.getDiscountRatio()); |
| | | r = price.multiply(discountRatio).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
| | | } else if (Constants.DISCOUNT_TYPE.amount.name().equals(discountType)){ |
| | | BigDecimal discountAmount = getAmount(member.getDiscountAmount()); |
| | | r = price.subtract(discountAmount); |
| | | } |
| | | |
| | | if(r.doubleValue() < 0){ |
| | | r = new BigDecimal(0); |
| | | } |
| | | |
| | | return r; |
| | | } |
| | | |
| | | protected Customer getCustomerByUserId(String userId){ |
| | | Customer p = customerMapper.selectOne(new QueryWrapper<Customer>() |
| | | .eq("user_id", userId)); |
| | | if(p == null){ |
| | | throw new ValidationException("客户不存在"); |
| | | } |
| | | |
| | | return p; |
| | | } |
| | | |
| | | protected Customer getCustomer(Long id){ |
| | | Customer p = customerMapper.selectById(id); |
| | | |
| | | if(p == null){ |
| | | throw new ValidationException("商户不存在"); |
| | | } |
| | | |
| | | return p; |
| | | } |
| | | |
| | | public Partner getCurrentPartner(){ |
| | | String userId = SecurityUtils.getUserId(); |
| | | Partner p = partnerMapper.selectOne(new QueryWrapper<Partner>() |