Explorar el Código

Merge branch 'ad_shop_show' into pre

zoujiajian hace 2 años
padre
commit
2a8ef5c786

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserAuthMapper.java

@@ -2,10 +2,13 @@ package com.cyksj.mapper.corp;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.cyksj.model.entity.CorpUserAuth;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * @author chan
  * @date 2022/4/8 上午11:06
  */
 public interface CorpUserAuthMapper extends BaseMapper<CorpUserAuth> {
+	@Select("select unionid from corp_user where id = (select corp_user_id from corp_user_auth where external_userid = #{externalUserId} limit 1) limit 1")
+	String getUnionIdByExternalUserId(String externalUserId);
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/YhShopInfo.java

@@ -34,5 +34,10 @@ public class YhShopInfo {
 
 	private String reason;
 
+	/**
+	 * 是否展示广告
+	 */
+	private Boolean isShowAd;
+
 	private Date createdTime;
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/YhShop.java

@@ -32,6 +32,11 @@ public class YhShop extends BaseEntity {
 	 */
 	private String customId;
 
+	/**
+	 * 用户是否展示广告位 默认false
+	 */
+	private Boolean isShowAd;
+
 	/**
 	 * 商务id
 	 */

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/request/HomeManageConfigReq.java

@@ -33,6 +33,11 @@ public class HomeManageConfigReq {
 
 	private HomeManagementConfig.AdType adType;
 
+	/**
+	 * 广告是否店铺展示 默认false
+	 */
+	private Boolean isShop;
+
 	private HomeManagementConfig.RgType rgType;
 
 	private BigDecimal rgPrice;

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementConfigView.java

@@ -45,6 +45,9 @@ public class HomeManagementConfigView {
 	@DbField("hc.ad_type")
 	private HomeManagementConfig.AdType adType;
 
+	@DbField("hc.is_shop")
+	private Boolean isShop;
+
 	@DbField("hc.rg_type")
 	private HomeManagementConfig.AdType rgType;
 

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/views/HomeManagementFrontView.java

@@ -54,6 +54,9 @@ public class HomeManagementFrontView {
 	@DbField("hc.ad_type")
 	private HomeManagementConfig.AdType adType;
 
+	@DbField("hc.is_shop")
+	private Boolean isShop;
+
 	@DbField("hc.rg_type")
 	private HomeManagementConfig.RgType rgType;
 

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/model/views/YhShopDetailView.java

@@ -38,6 +38,9 @@ public class YhShopDetailView {
 	@DbField("ys.custom_id")
 	private String customId;
 
+	@DbField("ys.is_show_ad")
+	private Boolean isShowAd;
+
 	/**
 	 * 是否审核通过
 	 */

+ 6 - 3
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -3,7 +3,6 @@ package com.cyksj.service.chatgpt.impl;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.UUID;
-import cn.hutool.core.util.RandomUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
@@ -354,6 +353,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
             chatgptUser.setUserToken(UUID.randomUUID().toString());
             chatgptUserMapper.insert(chatgptUser);
         } catch (DuplicateKeyException e) {
+            log.error("重复插入镜像用户:{}token,errmsg:{}", user.getNickname(), StringUtil.getErrorText(e));
         }
         return chatgptUser;
     }
@@ -384,6 +384,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
             chatgptUserTokenPrepareMapper.updateById(prepare);
             log.info("用户激活userToken:{}成功", prepare.getUserToken());
         } catch (DuplicateKeyException e) {
+            log.error("重复插入镜像车队用户:{}token,errmsg:{}" + chatgptUser.getId(), StringUtil.getErrorText(e));
         }
         return chatgptUser;
     }
@@ -799,8 +800,10 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                     .eq(ChatgptUserConversationRecord::getUserToken, userToken)
                     .orderByDesc(ChatgptUserConversationRecord::getId)
                     .last(" limit 1"));
-            chatgptUserConversationRecord.setConversationId(conversationId);
-            chatgptUserConversationRecordMapper.updateById(chatgptUserConversationRecord);
+            if (chatgptUserConversationRecord != null) {
+                chatgptUserConversationRecord.setConversationId(conversationId);
+                chatgptUserConversationRecordMapper.updateById(chatgptUserConversationRecord);
+            }
         }
     }
 

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -595,6 +595,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 			return null;
 		}
 		CorpCustomerAcquisitionLinkPopularize corpCustomerAcquisitionLinkPopularize = corpCustomerAcquisitionLinkPopularizeMapper.selectOne(Wrappers.lambdaQuery(CorpCustomerAcquisitionLinkPopularize.class)
+				.eq(CorpCustomerAcquisitionLinkPopularize::getIsChat, 1)
 				.eq(CorpCustomerAcquisitionLinkPopularize::getCustomerAcquistionLinkId, linkId).last("limit 1"));
 		if (corpCustomerAcquisitionLinkPopularize != null) {
 			//callback
@@ -684,6 +685,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 
 		//存在被删除的标签
 		if (CollUtil.isNotEmpty(exists_tagIds)) {
+			log.info("需删除用户:{}对应客服:{}关联已删除的标签:{}", externalUserid, relation.getFollowId(), exists_tagIds);
 			corpUserTagMapper.delete(Wrappers.lambdaQuery(CorpUserTag.class)
 					.in(CorpUserTag::getTagId, exists_tagIds)
 					.eq(CorpUserTag::getRelationId, relation.getId()));

+ 6 - 0
netflix-service/src/main/java/com/cyksj/service/mange/RefreshCacheService.java

@@ -22,4 +22,10 @@ public interface RefreshCacheService {
 	 * 清除补贴商品缓存
 	 */
 	void refreshGoodsSkuSubsidyPageCache();
+
+
+	/**
+	 * 清除用户店铺缓存
+	 */
+	void refreshUserShopMangeCache(String customId);
 }

+ 19 - 4
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -500,6 +500,9 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         relation.setNewRelationId(newRelation.getId());
         relationClearService.clearTicket(relation, source);
 
+        //是否是GPT镜像规格
+        delGptUser(orderDon.getGoodsId(), orderDon.getRelationId());
+
         if (plusPurchaseSkuRelation != null && plus_relationList != null) {
             plus_relationList.remove(relationId);
             plus_relationList.add(newRelation.getId());
@@ -847,10 +850,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                 giftCardOrderUseRecordService.returnGiftCardCash(orderDon.getId());
             }
             //是否是GPT镜像规格
-            if (orderDon.getGoodsId() == 18 && sku.getIsMirror()) {
-                chatgptUserMapper.delete(Wrappers.lambdaQuery(ChatgptUser.class)
-                        .eq(ChatgptUser::getRelationId, orderDon.getRelationId()));
-            }
+            delGptUser(orderDon.getGoodsId(), orderDon.getRelationId());
             //是否是分销订单
             //处理下级渠道分销提成
             handleSubRewards(orderDon);
@@ -1123,4 +1123,19 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         }
         return relation;
     }
+
+    /**
+     * 删除gptUser
+     */
+    public void delGptUser(Long goodsId, Long relationId) {
+        //gpt镜像
+        if (goodsId != null && goodsId == 18) {
+            Integer selectCount = chatgptUserMapper.selectCount(Wrappers.lambdaQuery(ChatgptUser.class)
+                    .eq(ChatgptUser::getRelationId, relationId));
+            if (selectCount > 0) {
+                chatgptUserMapper.delete(Wrappers.lambdaQuery(ChatgptUser.class)
+                        .eq(ChatgptUser::getRelationId, relationId));
+            }
+        }
+    }
 }

+ 6 - 0
netflix-service/src/main/java/com/cyksj/service/mange/impl/RefreshCacheServiceImpl.java

@@ -35,4 +35,10 @@ public class RefreshCacheServiceImpl implements RefreshCacheService {
 		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "subsidy" + "*");
 		redisService.del(keys.toArray(String[]::new));
 	}
+
+	@Override
+	public void refreshUserShopMangeCache(String customId) {
+		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + "*");
+		redisService.del(keys.toArray(String[]::new));
+	}
 }

+ 24 - 0
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -1216,4 +1216,28 @@ public class GoodsDonController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonSkuSubsidyAvailableViews);
 	}
 
+	/**
+	 * 获取用户店铺首页配置列表
+	 */
+	@GetMapping("/get/homeManage")
+	public Result<Map<String, List<HomeManagementFrontView>>> getShopHomeManageConfig(String customId) {
+		//是否同意展示对应首页广告位
+		String key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + ":homeManage";
+		Object o = redisService.get(key);
+		if (o == null) {
+			MapBuilder builder = MapUtils.builder()
+					.field(HomeManagementFrontView::getType, HomeManagementConfig.Type.ad.name())
+					.field(HomeManagementFrontView::getIsShop, 1);
+			List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
+			if (homeManagementFrontViews == null) {
+				return GatewayResponse.SUCCESS.newBuilder().toResult();
+			}
+			Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
+			map.putIfAbsent(HomeManagementConfig.Type.ad.name(), homeManagementFrontViews);
+			redisService.setNx(key, map, 50 * 60l);
+			o = redisService.get(key);
+		}
+		Map map = Jsons.parseObject(o, Map.class);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(map);
+	}
 }

+ 16 - 14
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -18,10 +18,13 @@ import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.GroupsRelationExpiryRecordMapper;
-import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.corp.CorpUserTagMapper;
 import com.cyksj.model.dto.AuthRedirect;
-import com.cyksj.model.entity.*;
+import com.cyksj.model.entity.CorpCustomerAcquistionCallback;
+import com.cyksj.model.entity.CorpFollow;
+import com.cyksj.model.entity.CorpMsgFollowAssociation;
+import com.cyksj.model.entity.QyMsgContent;
 import com.cyksj.model.manage.views.CorpQyMsgAuditChatView;
 import com.cyksj.model.request.corp.CorpCommonReq;
 import com.cyksj.model.views.CorpUserIntentionView;
@@ -78,7 +81,7 @@ public class WxCorpController {
 
 	private final CorpUserTagMapper corpUserTagMapper;
 
-	private final UserMapper userMapper;
+	private final CorpUserAuthMapper corpUserAuthMapper;
 
 	private final static String CORP_UUID = "corp-uuid";
 
@@ -323,18 +326,17 @@ public class WxCorpController {
 	 * @Param unionId 用户unionId
 	 */
 	@GetMapping("/acquistionLinkCallback")
-	public Result<CorpCustomerAcquistionCallback> getAcquistionLinkCallback(Long userId) {
-		MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
-		if (userId != null) {
-			User user = userMapper.selectById(userId);
-			if (user != null && StrUtil.isNotBlank(user.getUnionid())) {
-				builder.field(CorpCustomerAcquistionCallback::getUnionId, user.getUnionid());
-			}
-
-			CorpCustomerAcquistionCallback corpCustomerAcquistionCallback = beanSearcher.searchFirst(CorpCustomerAcquistionCallback.class, builder.build());
-			return GatewayResponse.SUCCESS.newBuilder().toResult(corpCustomerAcquistionCallback);
+	public Result<CorpCustomerAcquistionCallback> getAcquistionLinkCallback(String externalUserId) {
+		if (StrUtil.isEmpty(externalUserId)) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
 		}
-		return GatewayResponse.SUCCESS.newBuilder().toResult();
+		String unionId = corpUserAuthMapper.getUnionIdByExternalUserId(externalUserId);
+		if (StrUtil.isEmpty(unionId)) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap()).field(CorpCustomerAcquistionCallback::getUnionId, unionId);
+		CorpCustomerAcquistionCallback corpCustomerAcquistionCallback = beanSearcher.searchFirst(CorpCustomerAcquistionCallback.class, builder.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(corpCustomerAcquistionCallback);
 	}
 
 	/**

+ 21 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopUserController.java

@@ -14,7 +14,7 @@ import com.cyksj.model.entity.*;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.model.views.*;
 import com.cyksj.service.cps.shop.YhShopManageService;
-import com.cyksj.service.mange.GoodsDonCategoryService;
+import com.cyksj.service.mange.RefreshCacheService;
 import com.cyksj.web.util.StpYhShopManageUser;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -54,7 +54,7 @@ public class YhShopUserController {
 
 	private final YhShopApplyRecordMapper yhShopApplyRecordMapper;
 
-	private final GoodsDonCategoryService goodsDonCategoryService;
+	private final RefreshCacheService refreshCacheService;
 
 	/**
 	 * 店铺 信息详情
@@ -85,6 +85,25 @@ public class YhShopUserController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 设置是否展示广告位
+	 */
+	@PutMapping("/set/shop/ad")
+	public Result<String> setShopAd(@RequestBody YhShop yhShop) {
+		long userId = StpYhShopManageUser.getLoginIdAsLong();
+		YhShop dbShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getUserId, userId).last("limit 1"));
+		if (dbShop == null) {
+			throw BusinessRuntimeException.getInstance("店铺不存在");
+		}
+		if (yhShop.getIsShowAd() != null && dbShop.getIsShowAd() != yhShop.getIsShowAd()) {
+			dbShop.setIsShowAd(yhShop.getIsShowAd());
+			yhShopMapper.updateById(dbShop);
+			refreshCacheService.refreshUserShopMangeCache(dbShop.getCustomId());
+		}
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
 	/**
 	 * 申请修改
 	 */