Commit c8f6be45 authored by hezhen's avatar hezhen

123

parent 0b4efbef
package com.xxfc.platform.universal.constant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 跳转页面类型
*/
public enum PushJumpType {
ALL(0,"app首页"),
VEHICLE_ORDER_DETAIL(1,"租车订单详情页"),
TOUR_ORDER_DETAIL(2,"旅游订单详情页"),
VEHICLE_ORDER_SCORE(3,"租车订单评价页"),
TOUR_ORDER_SCORE(4,"旅游订单评价页面"),
MEMBER_ORDER_DETAIL(5,"会员订单详情页"),
;
/**
* 编码
*/
private Integer code;
/**
* 类型描述
*/
private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
private static List<Map<String,Object>> list = new ArrayList<>();
static{
for(PushJumpType pushJumpType : PushJumpType.values()){
codeAndDesc.put(pushJumpType.getCode(),pushJumpType.getDesc());
Map<String,Object> map=new HashMap<>();
map.put("code",pushJumpType.getCode());
map.put("value",pushJumpType.getDesc());
list.add(map);
}
}
PushJumpType(Integer code, String desc){
this.code=code;
this.desc=desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static String getByCode(Integer code) {
switch (code) {
case 1:
return ALL.getDesc();
case 2:
return VEHICLE_ORDER_DETAIL.getDesc();
case 3:
return VEHICLE_ORDER_SCORE.getDesc();
case 4:
return TOUR_ORDER_SCORE.getDesc();
case 5:
return MEMBER_ORDER_DETAIL.getDesc();
}
return "";
}
public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code);
}
public static List<Map<String,Object>> getList(){
return list;
}
}
package com.xxfc.platform.universal.constant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 系统发送类型
*/
public enum PushSendType {
ALL(0,"全部"),
VEHICLE_PAY(1,"租车预定成功"),
TOUR_PAY(2,"旅游预订成功"),
VEHICLE_CANCEL(3,"租车取消预订"),
TOUR_CANCEL(4,"旅游取消预订"),
TAKE_VEHICLE(5,"取车提醒"),
ALSO_VEHICLE(6,"还车提醒"),
GET_VEHICLE(7,"上车提醒"),
VEHICLE_FINISH(8, "租车订单完成"),
TOUR_FINISH(9, "旅游订单完成"),
MEMBER_PAY(10, "会员购买成功")
;
/**
* 编码
*/
private Integer code;
/**
* 类型描述
*/
private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
private static List<Map<String,Object>> list = new ArrayList<>();
static{
for(PushSendType pushSendType : PushSendType.values()){
codeAndDesc.put(pushSendType.getCode(),pushSendType.getDesc());
Map<String,Object> map=new HashMap<>();
map.put("code",pushSendType.getCode());
map.put("value",pushSendType.getDesc());
list.add(map);
}
}
PushSendType(Integer code, String desc){
this.code=code;
this.desc=desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static String getByCode(Integer code) {
return codeAndDesc.get(code);
}
public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code);
}
public static List<Map<String,Object>> getList(){
return list;
}
}
...@@ -64,6 +64,10 @@ public class MessagePush implements Serializable { ...@@ -64,6 +64,10 @@ public class MessagePush implements Serializable {
@ApiModelProperty(value = "指定跳转页面") @ApiModelProperty(value = "指定跳转页面")
private String intent; private String intent;
@Column(name = "jump_type")
@ApiModelProperty(value = "跳转页面类型:0-进入app;其他见枚举")
private Integer jumpType;
@Column(name = "crt_time") @Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true ) @ApiModelProperty(value = "创建时间", hidden = true )
......
...@@ -89,6 +89,12 @@ ...@@ -89,6 +89,12 @@
<groupId>antlr</groupId> <groupId>antlr</groupId>
<artifactId>antlr</artifactId> <artifactId>antlr</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.andrewoma.dexx</groupId>
<artifactId>dexx-collections</artifactId>
<version>0.2</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -20,6 +20,8 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO; ...@@ -20,6 +20,8 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.xxfc.platform.universal.constant.PushJumpType;
import com.xxfc.platform.universal.constant.PushSendType;
import com.xxfc.platform.universal.entity.MessagePush; import com.xxfc.platform.universal.entity.MessagePush;
import com.xxfc.platform.universal.mapper.MessagePushMapper; import com.xxfc.platform.universal.mapper.MessagePushMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -27,6 +29,9 @@ import org.apache.commons.lang3.StringUtils; ...@@ -27,6 +29,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
@Slf4j @Slf4j
...@@ -126,10 +131,10 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> { ...@@ -126,10 +131,10 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
//推送 //推送
public ObjectRestResponse jpushToAlias(Integer id,String userIds){ public ObjectRestResponse jpushToAlias(Integer id,String userIds,String orderNo){
ClientConfig clientConfig = ClientConfig.getInstance(); ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig); final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = buildPushObject_android_id(id,userIds); PushPayload payload = buildPushObject_android_id(id,userIds,orderNo);
if (payload==null){ if (payload==null){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数无效"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数无效");
} }
...@@ -152,7 +157,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> { ...@@ -152,7 +157,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
} }
public PushPayload buildPushObject_android_id(Integer id,String userIds) { public PushPayload buildPushObject_android_id(Integer id,String userIds,String orderNo) {
Example example =new Example(MessagePush.class); Example example =new Example(MessagePush.class);
example.createCriteria().andEqualTo("id",id).andEqualTo("isDel",0); example.createCriteria().andEqualTo("id",id).andEqualTo("isDel",0);
MessagePush messagePush=mapper.selectOneByExample(example); MessagePush messagePush=mapper.selectOneByExample(example);
...@@ -172,6 +177,11 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> { ...@@ -172,6 +177,11 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
if (StringUtils.isNotBlank(messagePush.getIntent())){ if (StringUtils.isNotBlank(messagePush.getIntent())){
intent= getJsonObject(messagePush.getIntent()); intent= getJsonObject(messagePush.getIntent());
} }
Map<String, String> extras = new HashMap<String, String>();
extras.put("onclickType",messagePush.getJumpType()+"");
if (StringUtils.isNotBlank(orderNo)){
extras.put("orderNo",orderNo);
}
Notification notification = Notification.newBuilder() Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder() .addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(messagePush.getAlert()) .setAlert(messagePush.getAlert())
...@@ -184,6 +194,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> { ...@@ -184,6 +194,7 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
.setTitle(messagePush.getTitle()) .setTitle(messagePush.getTitle())
.setPriority(1) .setPriority(1)
.setIntent(intent) .setIntent(intent)
.addExtras(extras)
.build()) .build())
.build(); .build();
return PushPayload.newBuilder() return PushPayload.newBuilder()
...@@ -238,6 +249,16 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> { ...@@ -238,6 +249,16 @@ public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
return ObjectRestResponse.succ(PageDataVO.pageInfo(page, limit, ()->mapper.selectByExample(example))); return ObjectRestResponse.succ(PageDataVO.pageInfo(page, limit, ()->mapper.selectByExample(example)));
} }
//获取枚举列表
public List<Map<String,Object>> getSendTypes(){
return PushSendType.getList();
}
//获取枚举列表
public List<Map<String,Object>> getJumpTypes(){
return PushJumpType.getList();
}
} }
...@@ -36,8 +36,9 @@ public class JPushController { ...@@ -36,8 +36,9 @@ public class JPushController {
@RequestMapping(value = "/stype", method = RequestMethod.GET) @RequestMapping(value = "/stype", method = RequestMethod.GET)
public ObjectRestResponse stype(@RequestParam(value = "id",defaultValue = "0") Integer id, public ObjectRestResponse stype(@RequestParam(value = "id",defaultValue = "0") Integer id,
@RequestParam(value = "userIds",defaultValue = "") String userIds) throws Exception { @RequestParam(value = "userIds",defaultValue = "") String userIds,
return jPushBiz.jpushToAlias(id,userIds); @RequestParam(value = "orderNo",defaultValue = "") String orderNo) throws Exception {
return jPushBiz.jpushToAlias(id,userIds,orderNo);
} }
@RequestMapping(value = "/addMessagePush", method = RequestMethod.POST) @RequestMapping(value = "/addMessagePush", method = RequestMethod.POST)
...@@ -68,5 +69,18 @@ public class JPushController { ...@@ -68,5 +69,18 @@ public class JPushController {
return ObjectRestResponse.succ(jPushBiz.selectById(id)); return ObjectRestResponse.succ(jPushBiz.selectById(id));
} }
@RequestMapping(value = "/sendTpyes", method = RequestMethod.GET)
public ObjectRestResponse sendTpyes(){
return ObjectRestResponse.succ(jPushBiz.getSendTypes());
}
@RequestMapping(value = "/jumpTpyes", method = RequestMethod.GET)
public ObjectRestResponse jumpTpyes(){
return ObjectRestResponse.succ(jPushBiz.getJumpTypes());
}
} }
...@@ -58,29 +58,7 @@ public enum BookType { ...@@ -58,29 +58,7 @@ public enum BookType {
} }
public static String getByCode(Integer code) { public static String getByCode(Integer code) {
switch (code) { return codeAndDesc.get(code);
case 2:
return EMPLOYEE_APPLY.getDesc();
case 1:
return USER_RENT.getDesc();
case 3:
return REPAIRING.getDesc();
case 4:
return SHOW.getDesc();
case 5:
return TOUR.getDesc();
case 6:
return MAINTAIN.getDesc();
case 7:
return BOOKING.getDesc();
case 8:
return DISABLE.getDesc();
case 9:
return CUSTOMER_APPLY.getDesc();
case 10:
return OTHER.getDesc();
}
return "";
} }
public static Boolean exists(Integer code){ public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code); return codeAndDesc.containsKey(code);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment