|
@@ -0,0 +1,126 @@
|
|
|
|
+package com.caimei365.commodity.service.impl;
|
|
|
|
+
|
|
|
|
+import com.caimei365.commodity.mapper.PriceMapper;
|
|
|
|
+import com.caimei365.commodity.mapper.PromotionsMapper;
|
|
|
|
+import com.caimei365.commodity.model.ResponseJson;
|
|
|
|
+import com.caimei365.commodity.model.vo.PriceVo;
|
|
|
|
+import com.caimei365.commodity.service.PriceService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Description
|
|
|
|
+ *
|
|
|
|
+ * @author : Charles
|
|
|
|
+ * @date : 2021/4/9
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class PriceServiceImpl implements PriceService {
|
|
|
|
+ @Resource
|
|
|
|
+ private PriceMapper priceMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private PromotionsMapper promotionsMapper;
|
|
|
|
+ /**
|
|
|
|
+ * 获取商品详情价格
|
|
|
|
+ *
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
+ * @param productId 商品Id
|
|
|
|
+ * @return PriceVo
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
|
|
|
|
+ // 数据库获取基本价格信息
|
|
|
|
+ PriceVo price = priceMapper.getDetailPrice(productId);
|
|
|
|
+ // 根据用户id设置详细价格
|
|
|
|
+ //setPriceByUserId(price, userId);
|
|
|
|
+ // 屏蔽成本价
|
|
|
|
+ price.setCostProportional(0d);
|
|
|
|
+ price.setCostPrice(0d);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取商品列表价格
|
|
|
|
+ *
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
+ * @param productIds 商品Id
|
|
|
|
+ * @return List<PriceVo>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// private void setPriceByUserId(PriceVo price, Integer userId) {
|
|
|
|
+// // 默认非促销活动状态
|
|
|
|
+// price.setActStatus(0);
|
|
|
|
+// // 设置划线价
|
|
|
|
+// price.setOriginalPrice(price.getPrice());
|
|
|
|
+// // 根据商品id查询商品活动
|
|
|
|
+// PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
|
|
|
|
+// //促销活动价
|
|
|
|
+// if (null != promotions) {
|
|
|
|
+// if (promotions.getMode() == 3) {
|
|
|
|
+// // 获取赠品
|
|
|
|
+// List<CartItem> giftList = promotionsMapper.getProductGifts(promotions.getId());
|
|
|
|
+// promotions.setGiftList(giftList);
|
|
|
|
+// }
|
|
|
|
+// price.setActStatus(1);
|
|
|
|
+// price.setPromotions(promotions);
|
|
|
|
+// price.setLadderPriceFlag(0);
|
|
|
|
+// if (promotions.getType() == 1 && promotions.getMode() == 1 && null != promotions.getTouchPrice()) {
|
|
|
|
+// price.setPrice(promotions.getTouchPrice().doubleValue());
|
|
|
|
+// //添加税费
|
|
|
|
+// if ("0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()))) {
|
|
|
|
+// BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), price.getTaxRate()), BigDecimal.valueOf(100));
|
|
|
|
+// promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(),addedValueTax));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// if (null != user) {
|
|
|
|
+// if (1 == price.getLadderPriceFlag()) {
|
|
|
|
+// // 阶梯价
|
|
|
|
+// LadderPrice ladderPrice = priceMapper.findLowerLadderPrice(price.getProductId());
|
|
|
|
+// LadderPrice ladderPrice2 = priceMapper.findMaxLadderPrice(price.getProductId());
|
|
|
|
+// if (null != ladderPrice) {
|
|
|
|
+// price.setPrice(ladderPrice.getBuyPrice());
|
|
|
|
+// if (null != ladderPrice2){
|
|
|
|
+// price.setMinBuyNumber(ladderPrice2.getBuyNum());
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// price.setLadderPriceFlag(0);
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// // 复购价
|
|
|
|
+// Double repurchase = priceMapper.getRepurchasePrice(price.getProductId(), user.getUserID());
|
|
|
|
+// if (null != repurchase && repurchase > 0) {
|
|
|
|
+// price.setPrice(repurchase);
|
|
|
|
+// price.setLadderPriceFlag(0);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// //添加税费
|
|
|
|
+// if ("0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()))) {
|
|
|
|
+// price.setPrice(price.getPrice() + (price.getPrice().doubleValue() * price.getTaxRate().doubleValue()) /100);
|
|
|
|
+// }
|
|
|
|
+// if (null == user) {
|
|
|
|
+// price.setPrice(0d);
|
|
|
|
+// price.setCostPrice(0d);
|
|
|
|
+// price.setUserIdentity(0);
|
|
|
|
+// } else {
|
|
|
|
+// // 用户身份: 2-会员机构, 4-普通机构
|
|
|
|
+// price.setUserIdentity(user.getUserIdentity());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|