Ver código fonte

百度投放链接下单优惠

zoujiajian 2 anos atrás
pai
commit
d11e0b9f5e

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -155,6 +155,11 @@ public interface Constant {
 	 */
 	String CHANNEL_360_DISCOUNT = "channel_360_discount";
 
+	/**
+	 * 百度渠道 投放链接优惠下单 系统配置key
+	 */
+	String CHANNEL_BAIDU_DISCOUNT_KEY = "channel_baidu_discount_key";
+
 	/**
 	 * GPT 平台账号重复
 	 */

+ 21 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/dto/ChannelBaiDuDiscountDto.java

@@ -0,0 +1,21 @@
+package com.cyksj.model.manage.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: ChannelBaiDuDiscount
+ * 创建者: JavaZou
+ * 创建时间:2023/10/24 14:48
+ */
+@Getter
+@Setter
+public class ChannelBaiDuDiscountDto {
+	private List<Long> popularizeIds;
+
+	private BigDecimal discount;
+}

+ 31 - 6
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -51,6 +51,7 @@ import com.cyksj.mapper.market.task.UserBindDetailMapper;
 import com.cyksj.mapper.shop.YhShopGoodsSkuMapper;
 import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.dto.ChannelBaiDuDiscountDto;
 import com.cyksj.model.manage.dto.GiftCardDto;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.manage.views.OrderDonView;
@@ -1998,14 +1999,38 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		if (orderDon.getPopularizeId() != null && orderDon.getPopularizeId() != 0L) {
 			//使用了优惠券 不再使用360渠道 折扣
 			if (couponUser == null && goodsType == 1) {
-				String name = channelPopularizeMapper.selectChannelByPid(orderDon.getPopularizeId());
-				if (Constant.CHANNEL_NAME_360.equals(name)) {
-					SysConfig sysConfig = sysConfigService.getBaseMapper().selectOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, Constant.CHANNEL_360_DISCOUNT));
-					if (sysConfig != null) {
-						BigDecimal discountMoney = orderDon.getMoney().multiply(BigDecimal.valueOf(Double.valueOf(sysConfig.getSysValue())));
-						orderDon.setMoney(discountMoney);
+				//百度渠道 专门优惠链接
+				SysConfig baiduConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+						.eq(SysConfig::getSysKey, Constant.CHANNEL_BAIDU_DISCOUNT_KEY).last("limit 1"));
+				if (baiduConfig != null) {
+					String sysValue = baiduConfig.getSysValue();
+					if (StrUtil.isNotBlank(sysValue)) {
+						try {
+							ChannelBaiDuDiscountDto baiDuDiscountDto = Jsons.parseObject(sysValue, ChannelBaiDuDiscountDto.class);
+							List<Long> baiduPopularizeIds = baiDuDiscountDto.getPopularizeIds();
+							BigDecimal discount = baiDuDiscountDto.getDiscount();
+							if (CollUtil.isNotEmpty(baiduPopularizeIds) && discount != null && discount.compareTo(BigDecimal.ZERO) > 0) {
+								if (baiduPopularizeIds.contains(orderDon.getPopularizeId())) {
+									BigDecimal discountMoney = orderDon.getMoney().multiply(discount);
+									orderDon.setMoney(discountMoney);
+								}
+							}
+
+						} catch (Exception e) {
+						}
+					}
+				} else {
+					//百度
+					String name = channelPopularizeMapper.selectChannelByPid(orderDon.getPopularizeId());
+					if (Constant.CHANNEL_NAME_360.equals(name)) {
+						SysConfig sysConfig = sysConfigService.getBaseMapper().selectOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, Constant.CHANNEL_360_DISCOUNT));
+						if (sysConfig != null) {
+							BigDecimal discountMoney = orderDon.getMoney().multiply(BigDecimal.valueOf(Double.valueOf(sysConfig.getSysValue())));
+							orderDon.setMoney(discountMoney);
+						}
 					}
 				}
+
 			}
 		}