|
@@ -0,0 +1,68 @@
|
|
|
+package com.xynet.marketing.service.impl;
|
|
|
+
|
|
|
+import com.xynet.marketing.service.EnquiryService;
|
|
|
+import com.xynet.marketing.service.factory.coupon.merc.MercCouponFactory;
|
|
|
+import com.xynet.marketing.service.factory.promotion.PromotionFactory;
|
|
|
+import com.xynet.marketing.utils.Emptys;
|
|
|
+import com.xynet.marketing.utils.FactoryUtils;
|
|
|
+import com.xynet.marketing.utils.collections.map.JHashMap;
|
|
|
+import com.xynet.marketing.utils.collections.map.JMap;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 询价服务
|
|
|
+ *
|
|
|
+ * @author hechunping
|
|
|
+ * @date 2025/2/20
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@AllArgsConstructor
|
|
|
+public class EnquiryServiceImpl implements EnquiryService {
|
|
|
+
|
|
|
+ public JMap<String, Object> goodsListPrice(JMap<String, Object> param) {
|
|
|
+ //查询当前促销活动
|
|
|
+ PromotionFactory promotionFactory = FactoryUtils.getService(PromotionFactory.class, "promotion_base");
|
|
|
+ param = promotionFactory.goodsListPrice(param);
|
|
|
+
|
|
|
+ //是否使用优惠券
|
|
|
+ if (Emptys.check(param.get("couponId"))) {
|
|
|
+ //查询优惠券
|
|
|
+ MercCouponFactory mercCouponFactory = FactoryUtils.getService(MercCouponFactory.class, "merc_coupon_base");
|
|
|
+ mercCouponFactory.goodsListPrice(param);
|
|
|
+ }
|
|
|
+ List<JMap<String, Object>> goodsList = param.getListMap("goodsList");
|
|
|
+ JMap<String, Object> result = new JHashMap<>();
|
|
|
+ List<JMap<String, Object>> resultGoodsList = new ArrayList<>();
|
|
|
+ Integer orderOldAmount = 0;
|
|
|
+ Integer orderAmount = 0;
|
|
|
+ for (int g = 0; g < goodsList.size(); g++) {
|
|
|
+ JMap<String, Object> goods = goodsList.get(g);
|
|
|
+ JMap<String, Object> resultGoods = new JHashMap<>();
|
|
|
+ resultGoods.set("goodsId", goods.get("goodsId"))
|
|
|
+ .set("price", goods.get("price"))
|
|
|
+ .set("priceOnsale", goods.get("priceOnsale"))
|
|
|
+ .set("num", goods.get("num"))
|
|
|
+ .set("msg", goods.get("msg"))
|
|
|
+ .set("amount", goods.getInt("priceOnsale") * goods.getInt("num"))
|
|
|
+ ;
|
|
|
+ resultGoodsList.add(resultGoods);
|
|
|
+ orderOldAmount += goods.getInt("price") * goods.getInt("num");
|
|
|
+ orderAmount += goods.getInt("priceOnsale") * goods.getInt("num");
|
|
|
+ }
|
|
|
+ //订单原价
|
|
|
+ result.put("orderOldAmount", orderOldAmount);
|
|
|
+ //订单总价
|
|
|
+ result.put("orderAmount", orderAmount);
|
|
|
+ result.put("couponId", param.getString("couponId"));
|
|
|
+ result.put("resultGoodsList", resultGoodsList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|