yuhaitao14 6 years ago
parent
commit
8f61678ecd

+ 16 - 2
shop/src/main/java/com/zskk/shop/controller/api/TJCallbackController.java

@@ -8,6 +8,8 @@
 
 package com.zskk.shop.controller.api;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,8 +44,20 @@ public class TJCallbackController {
 	
 	@RequestMapping("pushReport")
 	@ResponseBody
-	public ControllerResult pushReport(@RequestParam("phone") String phone, @RequestParam("reportid") Integer reportid){
-		userCenterService.pushReportMsg(phone, reportid);
+	public ControllerResult pushReport(
+			@RequestParam("phone") String phone, 
+			@RequestParam("title") String title,
+			@RequestParam("name") String name,
+			@RequestParam("reportid") String reportid,
+			@RequestParam("date") String tjdate,
+			@RequestParam("position") String position,
+			@RequestParam("remark") String remark
+			){
+		List<String> uids = familyPeopleService.queryPeopleByPhone(phone);
+		if (uids.isEmpty()){
+			return new ControllerResult(Boolean.FALSE);
+		}
+		userCenterService.pushReportMsg(uids, title, name, reportid, tjdate, position, remark);
 		return new ControllerResult(Boolean.TRUE);
 	}
 }

+ 2 - 0
shop/src/main/java/com/zskk/shop/dao/FamilyPeopleMapper.java

@@ -39,4 +39,6 @@ public interface FamilyPeopleMapper {
 	public int setAppointmentStatus(Appointment appointment);
 	
 	public Integer queryAppointmentCountByStatus(@Param("uid") String uid, @Param("statusList") List<Integer> statusList);
+
+	List<FamilyPeople> queryPeopleByPhone(@Param("phone") String phone);
 }

+ 16 - 0
shop/src/main/java/com/zskk/shop/service/FamilyPeopleService.java

@@ -11,8 +11,10 @@ package com.zskk.shop.service;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -317,4 +319,18 @@ public class FamilyPeopleService {
 	public Integer queryExportCount(String uid){
 		return familyPeopleMapper.queryAppointmentCountByStatus(uid, Arrays.asList(APPOINTMENT_STATUS_EXPORT));
 	}
+	
+	/**
+	 * 查询手机号对应的用户
+	 * @param phone
+	 * @return
+	 */
+	public List<String> queryPeopleByPhone(String phone){
+		List<FamilyPeople> list = familyPeopleMapper.queryPeopleByPhone(phone);
+		Set<String> uids = new HashSet<>();
+		for (FamilyPeople p: list){
+			uids.add(p.getUid());
+		}
+		return new ArrayList<>(uids);
+	}
 }

+ 24 - 5
shop/src/main/java/com/zskk/shop/service/UserCenterService.java

@@ -17,6 +17,7 @@ import java.util.UUID;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -180,15 +181,33 @@ public class UserCenterService {
 		return uccenter + "callback/h5Pay?companyid=" + companyid + "&apporderid=" + order.getOrderid() + "&sign=" + sign; 
 	}
 	
-	public ControllerResult pushReportMsg(String phone, Integer reportid){
-		Map<String, Object> data = new HashMap<>();
-		return this.sendTemplateMsg(companyid, phone, reprotPushTemplateId, myhost + "rjreport/" + reportid, JSON.toJSONString(data));
+	public ControllerResult pushReportMsg(List<String> uids, String title, String name, String reportid,
+			String tjdate, String position, String remark){
+		for (String uid: uids){
+			Map<String, Object> data = new HashMap<>();
+			data.put("first", this.getMsgItem(title));
+			data.put("keyword1", this.getMsgItem(name));
+			data.put("keyword2", this.getMsgItem(reportid));
+			data.put("keyword3", this.getMsgItem(tjdate));
+			data.put("keyword4", this.getMsgItem(position));
+			data.put("remark", this.getMsgItem(remark));
+			
+			this.sendTemplateMsg(companyid, uid, reprotPushTemplateId, myhost + "rjreport/" + reportid, JSON.toJSONString(data));
+		}
+		return new ControllerResult(Boolean.TRUE);
+	}
+	
+	private Map<String, Object> getMsgItem(String value){
+		Map<String, Object> item = new HashMap<>();
+		item.put("value", value);
+		item.put("color", "#173177");
+		return item;
 	}
 	
-	public ControllerResult sendTemplateMsg(String companyid, String phone, String templateid, String url, String data){
+	public ControllerResult sendTemplateMsg(String companyid, String uid, String templateid, String url, String data){
 		Map<String, String> params = new HashMap<>();
 		params.put("companyid", this.companyid);
-		params.put("phone", phone);
+		params.put("uid", uid);
 		params.put("templateid", templateid);
 		params.put("url", url);
 		params.put("data", data);

+ 2 - 2
shop/src/main/resource/application-dev.properties

@@ -14,13 +14,13 @@ zskk.shopmanagehost=http://localhost:8080/
 zskk.secret=6244c0f6da164d4db51fdb27cff15c95
 zskk.tjcenter=http://kunlun.pacsonline.cn/
 zskk.tjkey=Kq2gNG2WnWeJG3ug1SedNo2oGZHujs49
-zskk.uccenter=http://testucserver.pacsonline.cn/
+zskk.uccenter=http://localhost:10000/
 zskk.uclongin=http://testuc.pacsonline.cn/
 zskk.companyid=1
 zskk.oss.alikey=LTAIfulyaIRNgIqK
 zskk.oss.alisecret=2yI2WnebGumCXZxC0QJifcS8mqxJ0y
 zskk.oss.alibucketname=kun-shop
 zskk.oss.alihost=//kun-shop.oss-cn-beijing.aliyuncs.com
-zskk.report.push.templateid=001
+zskk.report.push.templateid=IZpPtCuhSbsyOQGYtoQPjG8fds4docKdajbJyYyZ6vY
 
 logging.level.com.zskk.shop.dao=DEBUG

+ 6 - 0
shop/src/main/resource/mapper/FamilyPeopleMapper.xml

@@ -72,4 +72,10 @@
 			#{status}
 		</foreach>
 	</select>
+	
+	<select id="queryPeopleByPhone" resultType="com.zskk.shop.dao.entry.FamilyPeople">
+		select <include refid="select"></include>
+		from family_people 
+		where phone=#{phone}
+	</select>
 </mapper>