wangzhuo 3 лет назад
Родитель
Сommit
1aedcfb0c3

+ 9 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/feign/IWechatClient.java

@@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 @FeignClient(
 	value = LauncherConstant.APPLICATION_CLIENT_NAME
@@ -20,6 +22,13 @@ public interface IWechatClient {
 	String API_PREFIX = "/client";
 	String API_NEW_PUSH = "/newPush";
 	String BID_WINNING_PUSH = "/bidWinningPush";
+	String GET_ALL_UNION_IDS = "/getAllUnionIds";
+
+	/**
+	 * 获得所有关注用户
+	 */
+	@GetMapping(GET_ALL_UNION_IDS)
+	List<Map<String, String>> getAllUnionIds();
 
 	/**
 	 * 发布标书推送消息

+ 6 - 0
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/entity/Biding.java

@@ -306,4 +306,10 @@ public class Biding implements Serializable {
 	 */
 	@TableField(exist = false)
 	private Integer agentStatus;
+
+	/**
+	 * 区分明细(0明细信息,1标书对比)
+	 */
+	@TableField(exist = false)
+	private Integer distinguish;
 }

+ 79 - 79
blade-service/blade-client/src/main/java/org/springblade/client/wechat/feign/WechatClient.java

@@ -40,110 +40,109 @@ public class WechatClient implements IWechatClient {
 	// 中标模板id
 	private static final String WINNING_TEMPLATE_ID = "x_oQaCsWi0n9hq3MNpd8hRvXqB8sc2E_DzIbrk1IRs0";
 
-
 	/**
-	 * 发布标书发送模板消息
-	 *
-	 * @param unionId  接收此消息的openId
+	 * 发布标书获得所有关注用户
 	 * @return 结果
 	 */
 	@Override
-	public String newsPush(String unionId, String contractNo, String departureHarbor, String objectiveHarbor,String boxTypeQuantity, String loadingTime) {
+	public List<Map<String, String>> getAllUnionIds() {
 		//获得token
 		Map<String,String> tokenMap = this.getToken();
 		//获得用户列表
 		Map<String, Object> openIdMap = this.getUserOpenId(tokenMap.get("accessToken"));
 		List<String> openIdsList = (List<String>) openIdMap.get("openIds");
+		List<Map<String, String>> unionIdMapList = new ArrayList<>();
 		//获得用户unionId
 		for (int i = 0; i < openIdsList.size(); i++ ){
 			String openid = openIdsList.get(i);
 			//获得unionId
 			Map<String, String > userMap = this.getUserInfo(tokenMap.get("accessToken"),openid);
-			if (userMap.get("unionid").equals(unionId)){
-				//1,配置
-				WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();
-				wxStorage.setAppId(appId);
-				wxStorage.setSecret(appSecret);
-				WxMpService wxMpService = new WxMpServiceImpl();
-				wxMpService.setWxMpConfigStorage(wxStorage);
-
-				List<WxMpTemplateData> data = Arrays.asList(
-					new WxMpTemplateData("first", "您收到一条新的标书,请及时处理!"),
-					new WxMpTemplateData("keyword1", contractNo),
-					new WxMpTemplateData("keyword2", departureHarbor),
-					new WxMpTemplateData("keyword3", objectiveHarbor),
-					new WxMpTemplateData("keyword4", boxTypeQuantity),
-					new WxMpTemplateData("keyword5", loadingTime),
-					new WxMpTemplateData("remark", "感谢您的使用。")
-				);
-				//2,推送消息
-				WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
-					.toUser(openid)//要推送的用户openid
-					.templateId(RELEASE_TEMPLATE_ID)//发布标书模版id
-					.miniProgram(new WxMpTemplateMessage.MiniProgram(APP_ID, "pages/index"))
-					.data(data)
-					.build();
-				try {
-					wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
-				} catch (Exception e) {
-					System.out.println("推送失败:" + e.getMessage());
-					e.printStackTrace();
-				}
-			}
+			unionIdMapList.add(userMap);
+		}
+		return unionIdMapList;
+	}
+
+	/**
+	 * 发布标书发送模板消息
+	 *
+	 * @param openid  接收此消息的openId
+	 * @return 结果
+	 */
+	@Override
+	public String newsPush(String openid, String contractNo, String departureHarbor, String objectiveHarbor,String boxTypeQuantity, String loadingTime) {
+
+		//1,配置
+		WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();
+		wxStorage.setAppId(appId);
+		wxStorage.setSecret(appSecret);
+		WxMpService wxMpService = new WxMpServiceImpl();
+		wxMpService.setWxMpConfigStorage(wxStorage);
+
+		List<WxMpTemplateData> data = Arrays.asList(
+			new WxMpTemplateData("first", "您收到一条新的标书,请及时处理!"),
+			new WxMpTemplateData("keyword1", contractNo),
+			new WxMpTemplateData("keyword2", departureHarbor),
+			new WxMpTemplateData("keyword3", objectiveHarbor),
+			new WxMpTemplateData("keyword4", boxTypeQuantity),
+			new WxMpTemplateData("keyword5", loadingTime),
+			new WxMpTemplateData("remark", "感谢您的使用。")
+		);
+		//2,推送消息
+		WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
+			.toUser(openid)//要推送的用户openid
+			.templateId(RELEASE_TEMPLATE_ID)//发布标书模版id
+			.miniProgram(new WxMpTemplateMessage.MiniProgram(APP_ID, "pages/index"))
+			.data(data)
+			.build();
+		try {
+			wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
+		} catch (Exception e) {
+			System.out.println("推送失败:" + e.getMessage());
+			e.printStackTrace();
 		}
+
 		return null;
 	}
 
 	/**
 	 * 中标发送模板消息
 	 *
-	 * @param unionId  接收此消息的openId
+	 * @param openid  接收此消息的openId
 	 * @return 结果
 	 */
 	@Override
-	public String bidWinningPush(String unionId, String contractNo, String departureHarbor, String objectiveHarbor,String boxTypeQuantity, String offer) {
-		//获得token
-		Map<String,String> tokenMap = this.getToken();
-		//获得用户列表
-		Map<String, Object> openIdMap = this.getUserOpenId(tokenMap.get("accessToken"));
-		List<String> openIdsList = (List<String>) openIdMap.get("openIds");
-		//获得用户unionId
-		for (int i = 0; i < openIdsList.size(); i++ ){
-			String openid = openIdsList.get(i);
-			//获得unionId
-			Map<String, String > userMap = this.getUserInfo(tokenMap.get("accessToken"),openid);
-			if (userMap.get("unionid").equals(unionId)){
-				//1,配置
-				WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();
-				wxStorage.setAppId(appId);
-				wxStorage.setSecret(appSecret);
-				WxMpService wxMpService = new WxMpServiceImpl();
-				wxMpService.setWxMpConfigStorage(wxStorage);
-
-				List<WxMpTemplateData> data = Arrays.asList(
-					new WxMpTemplateData("first", "恭喜中标,合作愉快!"),
-					new WxMpTemplateData("keyword1", contractNo),
-					new WxMpTemplateData("keyword2", departureHarbor),
-					new WxMpTemplateData("keyword3", objectiveHarbor),
-					new WxMpTemplateData("keyword4", boxTypeQuantity),
-					new WxMpTemplateData("keyword5", offer),
-					new WxMpTemplateData("remark", "感谢您的使用。")
-				);
-				//2,推送消息
-				WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
-					.toUser(openid)//要推送的用户openid
-					.templateId(WINNING_TEMPLATE_ID)//中标模版id
-					.miniProgram(new WxMpTemplateMessage.MiniProgram(APP_ID, "pages/index"))
-					.data(data)
-					.build();
-				try {
-					wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
-				} catch (Exception e) {
-					System.out.println("推送失败:" + e.getMessage());
-					e.printStackTrace();
-				}
-			}
+	public String bidWinningPush(String openid, String contractNo, String departureHarbor, String objectiveHarbor,String boxTypeQuantity, String offer) {
+
+		//1,配置
+		WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();
+		wxStorage.setAppId(appId);
+		wxStorage.setSecret(appSecret);
+		WxMpService wxMpService = new WxMpServiceImpl();
+		wxMpService.setWxMpConfigStorage(wxStorage);
+
+		List<WxMpTemplateData> data = Arrays.asList(
+			new WxMpTemplateData("first", "恭喜中标,合作愉快!"),
+			new WxMpTemplateData("keyword1", contractNo),
+			new WxMpTemplateData("keyword2", departureHarbor),
+			new WxMpTemplateData("keyword3", objectiveHarbor),
+			new WxMpTemplateData("keyword4", boxTypeQuantity),
+			new WxMpTemplateData("keyword5", offer),
+			new WxMpTemplateData("remark", "感谢您的使用。")
+		);
+		//2,推送消息
+		WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
+			.toUser(openid)//要推送的用户openid
+			.templateId(WINNING_TEMPLATE_ID)//中标模版id
+			.miniProgram(new WxMpTemplateMessage.MiniProgram(APP_ID, "pages/index"))
+			.data(data)
+			.build();
+		try {
+			wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
+		} catch (Exception e) {
+			System.out.println("推送失败:" + e.getMessage());
+			e.printStackTrace();
 		}
+
 		return null;
 	}
 
@@ -217,6 +216,7 @@ public class WechatClient implements IWechatClient {
 				if (ObjectUtil.isEmpty(unionid)){
 					throw new RuntimeException("获取unionid出现异常");
 				}else {
+					userMap.put("openid", openId);
 					userMap.put("unionid", unionid);
 				}
 			}else {

+ 10 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/BidingItemsMapper.java

@@ -2,8 +2,13 @@ package org.springblade.purchase.sales.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.purchase.sales.entity.Biding;
 import org.springblade.purchase.sales.entity.BidingItems;
 
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * 标书明细表 Mapper 接口
  *
@@ -18,4 +23,9 @@ public interface BidingItemsMapper extends BaseMapper<BidingItems> {
 	 * @param id
 	 */
 	void updateByPid(@Param("id") Long id);
+
+	/**
+	 * 获得明细详情
+	 */
+	List<BidingItems> selectPcList(@Param("biding") Biding biding);
 }

+ 5 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/BidingItemsMapper.xml

@@ -27,4 +27,9 @@
     <update id="updateByPid" parameterType="long">
         UPDATE business_biding_items SET is_deleted = '1' WHERE pid = #{id}
     </update>
+
+    <select id="selectPcList" resultMap="bidingItemsResultMap">
+        select * from business_biding_items where is_deleted = 0 and pid = #{biding.id}
+        and distinguish = #{biding.distinguish}
+    </select>
 </mapper>

+ 1 - 1
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IBidingItemsService.java

@@ -27,7 +27,7 @@ public interface IBidingItemsService extends IService<BidingItems> {
 	 * @param distinguish	区分标识
 	 * @return
 	 */
-	List<BidingItems> getBidingItems(Biding biding, Integer distinguish);
+	List<BidingItems> getBidingItems(Biding biding, Integer distinguish, String appOrPc);
 
 	/**
 	 * 删除订单明细

+ 24 - 8
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingItemsServiceImpl.java

@@ -25,8 +25,10 @@ import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 标书明细表 服务实现类
@@ -122,12 +124,20 @@ public class BidingItemsServiceImpl extends ServiceImpl<BidingItemsMapper, Bidin
 	 * @return
 	 */
 	@Override
-	public List<BidingItems> getBidingItems(Biding biding, Integer distinguish){
-		List<BidingItems> list = baseMapper.selectList(new LambdaQueryWrapper<BidingItems>()
-			.eq(BidingItems::getPid, biding.getId())
-			.eq(BidingItems::getDistinguish, distinguish)
-			.eq(BidingItems::getIsDeleted, 0)
-			.eq(BidingItems::getTenantId, AuthUtil.getTenantId()));
+	public List<BidingItems> getBidingItems(Biding biding, Integer distinguish, String appOrPc){
+
+		List<BidingItems> list = new ArrayList<>();
+
+		if ("app".equals(appOrPc)){
+			list = baseMapper.selectList(new LambdaQueryWrapper<BidingItems>()
+				.eq(BidingItems::getPid, biding.getId())
+				.eq(BidingItems::getDistinguish, distinguish)
+				.eq(BidingItems::getIsDeleted, 0)
+				.eq(BidingItems::getTenantId, AuthUtil.getTenantId()));
+		}else if ("pc".equals(appOrPc)){
+			biding.setDistinguish(distinguish);
+			list = baseMapper.selectPcList(biding);
+		}
 
 		if (distinguish.equals(1)){
 			if (ObjectUtil.isNotEmpty(list)){
@@ -227,6 +237,8 @@ public class BidingItemsServiceImpl extends ServiceImpl<BidingItemsMapper, Bidin
 		lambdaQueryWrapper.in(BidingAgent::getAgentId, items.getCorpsAttnId());
 		BidingAgent bidingAgent = bidingAgentMapper.selectOne(lambdaQueryWrapper);
 
+		//获得所有关注用户
+		List<Map<String, String >> unionIdMapList = wechatClient.getAllUnionIds();
 		if (ObjectUtil.isNotEmpty(bidingAgent)){
 			//根据代理客户的客户联系人进行消息推送
 			//获得所有代理客户
@@ -238,8 +250,12 @@ public class BidingItemsServiceImpl extends ServiceImpl<BidingItemsMapper, Bidin
 				R<User> user = userClient.userInfoById(corpsAttn.getUserId());
 				if (ObjectUtil.isNotEmpty(user)){
 					if (ObjectUtil.isNotEmpty(user.getData().getUnionId())){
-						wechatClient.bidWinningPush(user.getData().getUnionId(),
-							biding.getContractNo(), departureHarbor, objectiveHarbor, boxTypeQuantity, offer);
+						unionIdMapList.forEach(union -> {
+							if (union.get("unionid").equals(user.getData().getUnionId())){
+								wechatClient.bidWinningPush(user.getData().getUnionId(),
+									biding.getContractNo(), departureHarbor, objectiveHarbor, boxTypeQuantity, offer);
+							}
+						});
 					}
 				}
 			});

+ 11 - 5
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingServiceImpl.java

@@ -40,6 +40,7 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 标书表 服务实现类
@@ -76,7 +77,7 @@ public class BidingServiceImpl extends ServiceImpl<BidingMapper, Biding> impleme
 		}
 
 		//根据主表id获得明细信息
-		List<BidingItems> bidingItemsList = bidingItemsService.getBidingItems(bidingMassage, 0);
+		List<BidingItems> bidingItemsList = bidingItemsService.getBidingItems(bidingMassage, 0, "pc");
 		bidingMassage.setItemsList(bidingItemsList);
 
 		//获得代理明细
@@ -84,7 +85,7 @@ public class BidingServiceImpl extends ServiceImpl<BidingMapper, Biding> impleme
 		bidingMassage.setAgentList(agentList);
 
 		//获得标书对比明细
-		List<BidingItems> contrastList = bidingItemsService.getBidingItems(bidingMassage, 1);
+		List<BidingItems> contrastList = bidingItemsService.getBidingItems(bidingMassage, 1, "pc");
 		bidingMassage.setContrastList(contrastList);
 
 		return bidingMassage;
@@ -110,7 +111,7 @@ public class BidingServiceImpl extends ServiceImpl<BidingMapper, Biding> impleme
 		}
 
 		//获得标书对比明细
-		List<BidingItems> contrastList = bidingItemsService.getBidingItems(bidingMassage, 1);
+		List<BidingItems> contrastList = bidingItemsService.getBidingItems(bidingMassage, 1, "app");
 		bidingMassage.setContrastList(contrastList);
 
 		return bidingMassage;
@@ -280,6 +281,8 @@ public class BidingServiceImpl extends ServiceImpl<BidingMapper, Biding> impleme
 		//箱型箱量
 		String boxTypeQuantity = salesBiding.getBoxTypeQuantity();
 
+		//获得所有关注用户
+		List<Map<String, String >> unionIdMapList = wechatClient.getAllUnionIds();
 		//根据代理客户的客户联系人进行消息推送
 		//获得所有代理客户
 		List<BidingAgent> agentList = bidingAgentService.getBidingAgent(salesBiding);;
@@ -295,8 +298,11 @@ public class BidingServiceImpl extends ServiceImpl<BidingMapper, Biding> impleme
 						R<User> user = userClient.userInfoById(corpsAttn.getUserId());
 						if (ObjectUtil.isNotEmpty(user.getData())){
 							if (ObjectUtil.isNotEmpty(user.getData().getUnionId())){
-								wechatClient.newsPush(user.getData().getUnionId(),
-									salesBiding.getContractNo(), departureHarbor, objectiveHarbor, boxTypeQuantity, loadingTime);
+								unionIdMapList.forEach(union -> {
+									if (union.get("unionid").equals(user.getData().getUnionId())){
+										wechatClient.newsPush(union.get("openid"),salesBiding.getContractNo(), departureHarbor, objectiveHarbor, boxTypeQuantity, loadingTime);
+									}
+								});
 							}
 						}
 					});