Parcourir la source

Merge branch 'master' into pre

# Conflicts:
#	netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java
zoujiajian il y a 3 ans
Parent
commit
d442667894

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserFollowRelationMapper.java

@@ -16,4 +16,6 @@ public interface CorpUserFollowRelationMapper extends BaseMapper<CorpUserFollowR
 	String selectCorpCustomers(@Param("unionid") String unionid, @Param("wxCorpId") Long wxCorpId);
 
 	List<CorpUserFollowRelationDto> selectCorpUserFollowRelationByTagIds(@Param("list") List<String> tagIds, @Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> followIds);
+
+	List<CorpUserFollowRelationDto> selectCorpUserFollowRelation(@Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> service_follow_ids);
 }

+ 20 - 0
netflix-dao/src/main/java/com/cyksj/model/request/CorpActiveBulkMsg.java

@@ -0,0 +1,20 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: CorpActiveBulkMsg
+ *创建者: JavaZou
+ *创建时间:2023/8/28 16:51
+ */
+@Getter
+@Setter
+public class CorpActiveBulkMsg {
+	private String content;
+
+	private String img;
+
+	private Long wxCorpId;
+}

+ 18 - 0
netflix-dao/src/main/resources/mapper/CorpUserFollowRelationMapper.xml

@@ -26,6 +26,24 @@
         left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
         left join `corp_user` cu on cu.id = ca.corp_user_id
         where cufr.wx_corp_id = #{wxCorpId} and cu.user_id != 0
+        and ca.wx_corp_id = #{wxCorpId}
+        <if test="followIds != null and followIds.size() > 0">
+            and cufr.follow_id in
+            <foreach collection="followIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by cufr.corp_user_id
+    </select>
+
+    <select id="selectCorpUserFollowRelation" resultType="com.cyksj.model.dto.CorpUserFollowRelationDto">
+        select cufr.corp_user_id,
+        any_value(cufr.follow_id) as follow_id,
+        any_value(cu.user_id) as user_id
+        from `corp_user_follow_relation` cufr left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
+        left join `corp_user` cu on cu.id = ca.corp_user_id
+        where cufr.wx_corp_id = #{wxCorpId} and cu.user_id != 0
+        and ca.wx_corp_id = #{wxCorpId}
         <if test="followIds != null and followIds.size() > 0">
             and cufr.follow_id in
             <foreach collection="followIds" item="item" open="(" separator="," close=")">

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpMsgBulkTaskService.java

@@ -3,6 +3,7 @@ package com.cyksj.service.corp;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.cyksj.model.entity.CorpMsgBulkTask;
 import com.cyksj.model.entity.CorpTag;
+import com.cyksj.model.request.CorpActiveBulkMsg;
 
 import java.util.List;
 import java.util.Map;
@@ -21,4 +22,6 @@ public interface CorpMsgBulkTaskService extends IService<CorpMsgBulkTask> {
 	Map<String, List<CorpTag>> getTagDetail(Long id) throws Exception;
 
 	void executeDynamicRuleTagTask(Long tagId) throws Exception;
+
+	void sendActiveCorpBulkMsg(CorpActiveBulkMsg msg);
 }

+ 64 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpMsgBulkTaskServiceImpl.java

@@ -21,6 +21,7 @@ import com.cyksj.mapper.manage.coupon.CouponMapper;
 import com.cyksj.model.dto.CornMetaDto;
 import com.cyksj.model.dto.CorpUserFollowRelationDto;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.request.CorpActiveBulkMsg;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.model.request.corp.CorpMsgTemplate;
 import com.cyksj.model.request.corp.Text;
@@ -161,6 +162,69 @@ public class CorpMsgBulkTaskServiceImpl extends ServiceImpl<CorpMsgBulkTaskMappe
 		XxlJobResult xxlJobResult = XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(taskId, String.valueOf(tagId)).toString());
 	}
 
+	@Override
+	public void sendActiveCorpBulkMsg(CorpActiveBulkMsg msg) {
+		String content = msg.getContent();
+		if (StrUtil.isEmpty(content)) {
+			throw BusinessRuntimeException.getInstance("群发内容为空");
+		}
+		String img = msg.getImg();
+		Long wxCorpId = Optional.ofNullable(msg.getWxCorpId()).orElse(2l);
+		WxCorpApp wxCorpApp = wxCorpAppMapper.selectById(wxCorpId);
+		Assert.notNull(wxCorpApp, "企业微信未配置");
+		//客服集合
+		List<String> service_follow_ids = null;
+		SysConfig serviceConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+				.eq(SysConfig::getSysKey, Constant.CORP_SERVICE_FOLLOWS_KEY).last("limit 1"));
+		if (serviceConfig != null && StrUtil.isNotBlank(serviceConfig.getSysValue())) {
+			try {
+				service_follow_ids = Jsons.parseList(serviceConfig.getSysValue(), String.class);
+			} catch (Exception e) {
+			}
+		}
+		List<CorpUserFollowRelationDto> corpUserFollowRelations = corpUserFollowRelationMapper.selectCorpUserFollowRelation(wxCorpApp.getId(), service_follow_ids);
+		//将成员与客户相同关联聚合
+		Map<String, List<CorpUserFollowRelationDto>> collect = corpUserFollowRelations.stream().collect(Collectors.groupingBy(CorpUserFollowRelationDto::getFollowId));
+		//附件
+		LinkedList<Attachments> attachments = null;
+		if (StrUtil.isNotEmpty(img)) {
+			attachments = new LinkedList<>();
+			Attachments attachment = new Attachments();
+			Attachments.Image image = new Attachments.Image();
+			image.setPicUrl(img);
+			attachment.setImage(image);
+			attachments.add(corpService.updateMaterial(attachment, wxCorpApp.getCorpId(), 1));
+		}
+		CorpMsgTemplate corpMsgTemplate = new CorpMsgTemplate();
+		corpMsgTemplate.setAttachments(attachments);
+		corpMsgTemplate.setChatType("single");
+		if (StringUtils.isNotBlank(content)) {
+			Text text = new Text();
+			text.setContent(content);
+			corpMsgTemplate.setText(text);
+		}
+		collect.forEach((followId, val) -> {
+			try {
+				List<String> extendIds = new ArrayList<>(val.size());
+				List<Long> userIds = null;
+				for (CorpUserFollowRelationDto dto : val) {
+					extendIds.add(dto.getCorpUserId());
+					if (userIds != null && dto.getUserId() != null) {
+						userIds.add(dto.getUserId());
+					}
+				}
+				List<List<String>> split = CollectionUtil.split(extendIds, LIMIT);
+				for (List<String> corpUserIdList : split) {
+					corpMsgTemplate.setSender(followId);
+					corpMsgTemplate.setExternalUserid(corpUserIdList);
+					CorpMsgTemplateAddResult result = corpOps.addMsgTemplate(wxCorpApp.getCorpId(), corpMsgTemplate);
+				}
+			} catch (Exception e) {
+				log.error("发送企业微信失败:{}", StringUtil.getErrorText(e));
+			}
+		});
+	}
+
 	/**
 	 * 创建企业群发
 	 */

+ 2 - 2
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSpecServiceImpl.java

@@ -461,8 +461,8 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
 						List<Integer> specIdsList = Jsons.parseList(sku.getSpecIds(), Integer.class);
 						if (specIdsList.contains(dbNode.getId())) {
 							if (isUpdateTitle.get()) {
-								sku.setSpecJson(sku.getSpecJson().replaceAll(dbNode.getValue(), e.getValue()));
-								sku.setSpecVal(sku.getSpecVal().replaceAll(dbNode.getValue(), e.getValue()));
+								sku.setSpecJson(StrUtil.replace(sku.getSpecJson(), dbNode.getValue(), e.getValue()));
+								sku.setSpecVal(StrUtil.replace(sku.getSpecVal(), dbNode.getValue(), e.getValue()));
 							}
 							if (isUpdatePrice.get()) {
 								sku.setPrice(sku.getPrice().subtract(dbNode.getPrice()).add(e.getPrice()));

+ 10 - 9
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -170,9 +170,18 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             }
             orderDon.setStatus(OrderDon.Status.transport);
             updateById(orderDon);
+
+            GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
+            //库存扣减逻辑
+            List<GoodsSkuStockRelate> relateList = skuStockRelateMapper.selectList(Wrappers.lambdaQuery(GoodsSkuStockRelate.class).eq(GoodsSkuStockRelate::getSkuId,orderDon.getSkuId()));
+            if(!relateList.isEmpty()){
+                relateList.forEach((relate)->{
+                    goodsDonStockService.upStockRelate(relate.getStockId(),orderDon.getId(),"transport");
+                });
+            }
+
             //发放实物购买权益
             Boolean isReceivedAll = true;
-            GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
             if (sku != null) {
                 if (sku.getIsBenefits()) {
                     if (StrUtil.isNotEmpty(sku.getBenefitsList())) {
@@ -181,19 +190,11 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                             //自购实物 获取权益
                             isReceivedAll = userRealOrderBenefitsService.getPayRealGoodsBenefits(orderDon.getUserId(), orderDon.getId(), goodsDonSkus);
                         } catch (Exception e) {
-
                         }
                     }
                 }
             }
             final Boolean flag = isReceivedAll;
-            //库存扣减逻辑
-            List<GoodsSkuStockRelate> relateList = skuStockRelateMapper.selectList(Wrappers.lambdaQuery(GoodsSkuStockRelate.class).eq(GoodsSkuStockRelate::getSkuId,orderDon.getSkuId()));
-            if(!relateList.isEmpty()){
-                relateList.forEach((relate)->{
-                    goodsDonStockService.upStockRelate(relate.getStockId(),orderDon.getId(),"transport");
-                });
-            }
 
             //发送微信模板消息
 //            TASK_POOL.execute(()->{

+ 8 - 6
netflix-service/src/main/java/com/cyksj/service/order/impl/UserRealOrderBenefitsImpl.java

@@ -73,20 +73,22 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 			List<GroupsRelationView> relationViewList = groupsRelationMapper.selectRelationByGoodsId(goodsId, userId);
 			//是否有该规格车票,若无直接发放车票
 			if (CollUtil.isEmpty(relationViewList)) {
+				log.info("用户userId:{}未有skuId:{}车票,获取对应车票", userId, sku.getId());
 				//领取权益时,没有车票的用户自动上车,获得对应车票
 				GroupsRelation relation = exchangeCodeService.getGroupTripsTicket(sku, userId, null, OrderDon.Type.PAY_EQUIPMENT);
-				//多给三天
-				DateTime expiryTime = DateUtil.offsetDay(relation.getExpiryTime(), 3);
-				groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
-						.set(GroupsRelation::getExpiryTime, expiryTime)
-						.eq(GroupsRelation::getId, relation.getId()));
+//				//多给三天
+//				DateTime expiryTime = DateUtil.offsetDay(relation.getExpiryTime(), 3);
+//				groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
+//						.set(GroupsRelation::getExpiryTime, expiryTime)
+//						.eq(GroupsRelation::getId, relation.getId()));
 				saveReceiveBenefitsRecord(userId, skuId, orderId, relation.getOrderId(), relation.getId(), sku.getMonths(), sku.getDays(), 1);
+				log.info("用户userId:{}获取对应skuId:{}车票成功", userId, sku.getId());
 			} else if (relationViewList.size() == 1) {
 				//若有且只有一张增加时长
 				GroupsRelationView groupsRelationView = relationViewList.get(0);
 				Date expiryTime = groupsRelationView.getExpiryTime();
 				if (expiryTime == null) {
-					throw BusinessRuntimeException.getInstance("该车位暂未发车,请发车后再领取权益");
+					throw BusinessRuntimeException.getInstance("用户存在未发车的车票,请发车后再进行发货");
 				}
 				DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, sku.getMonths());
 				updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/coupon/CouponFrontController.java

@@ -327,7 +327,7 @@ public class CouponFrontController {
 		}
 		List<CouponView> couponViews = beanSearcher.searchAll(CouponView.class, MapUtils.builder()
 				.field(CouponView::getId, couponIds).op(Operator.InList)
-				.orderBy(CouponView ::getId).desc()
+				.orderBy(CouponView::getId).desc()
 				.build());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(couponViews);
 	}

+ 7 - 3
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -286,7 +286,6 @@ public class GoodsDonController {
      */
     @GetMapping("/get/{id}")
     public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
-        Long userId = null;
         Long fUid = StpUserUtil.getUserIdAfterLogin();
         GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
 
@@ -303,7 +302,12 @@ public class GoodsDonController {
                         .field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
                         .build()));
             }
-            if (fUid != null && views.getIsSp()) {
+            if (views.getIsSp()) {
+                if (fUid == null) {
+                    sku.setSpecificPrice(null);
+                    sku.setSpecificGoodsIds(null);
+                    return;
+                }
                 //设置特定价格
                 if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
                     sku.setSpecificGoodsIds(null);
@@ -475,7 +479,7 @@ public class GoodsDonController {
             list.forEach(data -> {
                 if (data.getIsSp()) {
                     //查找所有特定规格最小价格 满足条件
-                    String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "specific:" + data.getId();
+                    String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + data.getId();
                     Object speciObj = redisService.get(specificGoodsKey);
                     List<GoodsDonSku> specificSkus = null;
                     if (speciObj != null) {

+ 10 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpMsgBulkTaskController.java

@@ -16,6 +16,7 @@ import com.cyksj.model.dto.CornMetaDto;
 import com.cyksj.model.entity.CorpMsgBulkTask;
 import com.cyksj.model.entity.CorpTag;
 import com.cyksj.model.excel.ExcelCorpMsgBulkTaskSendRecordData;
+import com.cyksj.model.request.CorpActiveBulkMsg;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.model.views.CorpMsgBulkTaskCorpFollowSendRecordView;
 import com.cyksj.model.views.CorpMsgBulkTaskSendRecordView;
@@ -234,4 +235,13 @@ public class CorpMsgBulkTaskController {
 		corpMsgBulkTaskService.executeDynamicRuleTagTask(tagId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+	/**
+	 * 群发任务通知
+	 */
+	@PostMapping("/send/active/corpBulkMsg")
+	public Result<String> sendActiveCorpBulkMsg(@RequestBody CorpActiveBulkMsg msg) {
+		corpMsgBulkTaskService.sendActiveCorpBulkMsg(msg);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
 }