Commit b76e343f by weijiguang

push

parent c356a5a0
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Machine; import com.soss.system.domain.Machine;
import com.soss.system.domain.Shop; import com.soss.system.domain.Shop;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.push.impl.PushServiceImpl;
import com.soss.system.service.ICustomerService; import com.soss.system.service.ICustomerService;
import com.soss.system.service.impl.MachineServiceImpl; import com.soss.system.service.impl.MachineServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl; import com.soss.system.service.impl.OrderServiceImpl;
...@@ -30,7 +31,7 @@ public class ApplicationController { ...@@ -30,7 +31,7 @@ public class ApplicationController {
@Autowired @Autowired
MachineServiceImpl machineService; MachineServiceImpl machineService;
@Autowired @Autowired
JiGuangPushServiceImpl jiGuangPushService; PushServiceImpl pushService;
@Autowired @Autowired
OrderTakingServiceImpl orderTakingService; OrderTakingServiceImpl orderTakingService;
@Autowired @Autowired
...@@ -89,7 +90,7 @@ public class ApplicationController { ...@@ -89,7 +90,7 @@ public class ApplicationController {
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("seqNo", redisKey); data.put("seqNo", redisKey);
jgBody.put("data", data); jgBody.put("data", data);
jiGuangPushService.push(Integer.parseInt(machine.getId()), screenNo, jgBody); pushService.push(machine.getCode(), screenNo, JSON.toJSONString(jgBody));
// stringRedisTemplate.delete(redisKey); // stringRedisTemplate.delete(redisKey);
return AjaxResult.success("处理成功", redisJson.toJSONString()); return AjaxResult.success("处理成功", redisJson.toJSONString());
} }
......
package com.soss.framework.config; //package com.soss.framework.config;
//
import cn.jpush.api.JPushClient; //import cn.jpush.api.JPushClient;
import org.springframework.beans.factory.annotation.Value; //import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties; //import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
//
@Configuration //@Configuration
@ConfigurationProperties //@ConfigurationProperties
public class JiGuangConfig { //public class JiGuangConfig {
// 极光官网-个人管理中心-appkey // // 极光官网-个人管理中心-appkey
@Value("${push.appkey}") // @Value("${push.appkey}")
private String appkey; // private String appkey;
// 极光官网-个人管理中心-点击查看-secret // // 极光官网-个人管理中心-点击查看-secret
@Value("${push.secret}") // @Value("${push.secret}")
private String secret; // private String secret;
//
// 获取推送客户端 // // 获取推送客户端
@Bean // @Bean
public JPushClient getJPushClient() { // public JPushClient getJPushClient() {
JPushClient jPushClient = new JPushClient(secret, appkey); // JPushClient jPushClient = new JPushClient(secret, appkey);
return jPushClient; // return jPushClient;
} // }
} //}
\ No newline at end of file \ No newline at end of file
...@@ -75,11 +75,11 @@ ...@@ -75,11 +75,11 @@
<artifactId>aliyun-java-sdk-dysmsapi</artifactId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version> <version>1.1.0</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>cn.jpush.api</groupId> <!-- <groupId>cn.jpush.api</groupId>-->
<artifactId>jpush-client</artifactId> <!-- <artifactId>jpush-client</artifactId>-->
<version>3.2.9</version> <!-- <version>3.2.9</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
......
package com.soss.system.jiguang;
import com.soss.system.domain.vo.PushBean;
/**
* 推送服务
* 封装业务功能相关
*/
public interface JiGuangPushService {
boolean pushAll(PushBean pushBean);
boolean pushIos(PushBean pushBean);
boolean pushIos(PushBean pushBean, String... registids);
boolean pushAndroid(PushBean pushBean);
boolean pushAndroid(PushBean pushBean, String... registids);
String[] checkRegistids(String[] registids);
}
package com.soss.system.jiguang;
import cn.jpush.api.push.model.PushPayload;
import com.soss.system.domain.vo.PushBean;
/**
* 极光推送
* 封装第三方api相关
*/
public interface MyJiGuangPushService {
boolean pushAll(PushBean pushBean);
boolean pushIos(PushBean pushBean);
boolean pushIos(PushBean pushBean, String... registids);
boolean pushAndroid(PushBean pushBean);
boolean pushAndroid(PushBean pushBean, String... registids);
boolean sendPush(PushPayload pushPayload);
}
package com.soss.system.jiguang.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.MyJiGuangPushService;
import com.soss.system.mapper.MachineMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 推送服务
* 封装业务功能相关
*/
@Service
@Slf4j
public class JiGuangPushServiceImpl implements JiGuangPushService {
/** 一次推送最大数量 (极光限制1000) */
private static final int max_size = 800;
@Autowired
private MyJiGuangPushService jPushService;
@Autowired
private MachineMapper machineMapper;
/**
* 推送全部, 不支持附加信息
*
* @return
*/
@Override
public boolean pushAll(PushBean pushBean) {
return jPushService.pushAll(pushBean);
}
/**
* 推送全部ios
*
* @return
*/
@Override
public boolean pushIos(PushBean pushBean) {
return jPushService.pushIos(pushBean);
}
/**
* 推送ios 指定id
*
* @return
*/
@Override
public boolean pushIos(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registed
while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushIos(pushBean, Arrays.copyOfRange(registids, 0, max_size));
registids = Arrays.copyOfRange(registids, max_size, registids.length);
}
return jPushService.pushIos(pushBean, registids);
}
/**
* 推送全部android
*
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean) {
return jPushService.pushAndroid(pushBean);
}
/**
* 推送android 指定id
*
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean, String... registids) {
registids = checkRegistids(registids); // 剔除无效registedpush to
while (registids.length > max_size) { // 每次推送max_size个
jPushService.pushAndroid(pushBean, Arrays.copyOfRange(registids, 0, max_size));
registids = Arrays.copyOfRange(registids, max_size, registids.length);
}
return jPushService.pushAndroid(pushBean, registids);
}
/**
* 剔除无效registed
*
* @param registids
* @return
*/
@Override
public String[] checkRegistids(String[] registids) {
List<String> regList = new ArrayList<String>(registids.length);
for (String registid : registids) {
if (registid != null && !"".equals(registid.trim())) {
regList.add(registid);
}
}
return regList.toArray(new String[0]);
}
public void push(Integer machineId, Integer screenNo, JSONObject jsonObject) {
// String s = machineMapper.selectRegister(key);
String[] registerIds = machineMapper.selectRegister(machineId, screenNo);
if (registerIds != null && registerIds.length > 0) {
PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean, registerIds);
log.info("pushto " + JSON.toJSONString(registerIds) + ", " + JSON.toJSONString(jsonObject));
}
}
/*public void pushMachine(String machineId, Map<String, String> map) {
Machine machine = machineMapper.selectMachineById(machineId);
if (StringUtils.isNotEmpty(machine.getRegister())) {
PushBean pushBean = new PushBean();
pushBean.setExtras(map);
pushBean.setAlert("新消息");
pushAndroid(pushBean, machine.getRegister());
}
}
public void pushOrderState(Order order) {
Machine machine = machineMapper.selectMachineById(order.getMachineId());
if(StringUtils.isNotEmpty(machine.getRegister())){
JSONObject jsonObject = new JSONObject();
jsonObject.put("action","ORDER_STATE_CHANGED");
jsonObject.put("timestamp",System.currentTimeMillis());
JSONObject data = new JSONObject();
data.put("orderId",order.getId());
data.put("orderNo",order.getOrderNo());
data.put("orderNumber",order.getOrderNum());
data.put("state",order.getState());
jsonObject.put("data",data);
PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean,machine.getRegister());
}
}*/
}
package com.soss.system.jiguang.impl;
import cn.jpush.api.JPushClient;
import cn.jpush.api.common.resp.APIConnectionException;
import cn.jpush.api.common.resp.APIRequestException;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.Notification;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.MyJiGuangPushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 极光推送
* 封装第三方api相关
*/
@Service
@Slf4j
public class MyJiGuangPushServiceImpl implements MyJiGuangPushService {
@Autowired
private JPushClient jPushClient;
/**
* 广播 (所有平台,所有设备, 不支持附加信息)
* @param pushBean 推送内容
* @return
*/
@Override
public boolean pushAll(PushBean pushBean){
Message build = new Message.Builder().setMsgContent(pushBean.getMessageCount().toJSONString()).build();
return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setMessage(build)
.build());
}
/**
* ios广播
* @param pushBean 推送内容
* @return
*/
@Override
public boolean pushIos(PushBean pushBean){
return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.all())
.setNotification(Notification.ios(pushBean.getAlert(), pushBean.getExtras()))
.build());
}
/**
* ios通过registid推送 (一次推送最多 1000 个)
* @param pushBean 推送内容
* @param registids 推送id
* @return
*/
@Override
public boolean pushIos(PushBean pushBean, String... registids){
return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.registrationId(registids))
.setNotification(Notification.ios(pushBean.getAlert(), pushBean.getExtras()))
.build());
}
/**
* android广播
* @param pushBean 推送内容
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean){
return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.android())
.setAudience(Audience.all())
.setNotification(Notification.android(pushBean.getAlert(), pushBean.getTitle(), pushBean.getExtras()))
.build());
}
/**
* android通过registid推送 (一次推送最多 1000 个)
* @param pushBean 推送内容
* @param registids 推送id
* @return
*/
@Override
public boolean pushAndroid(PushBean pushBean, String ... registids){
Message build = new Message.Builder().setMsgContent(pushBean.getMessageCount().toJSONString()).build();
log.info("极光推送的内容为:【{}】::[{}]",registids[0], JSONObject.toJSONString(build));
return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.android())
.setAudience(Audience.registrationId(registids))
.setMessage(build)
//.setNotification(Notification.android(pushBean.getAlert(), pushBean.getTitle(), pushBean.getExtras()))
.build());
}
/**
* 调用api推送
* @param pushPayload 推送实体
* @return
*/
@Override
public boolean sendPush(PushPayload pushPayload){
log.info("发送极光推送请求: {}", pushPayload);
PushResult result = null;
try{
result = jPushClient.sendPush(pushPayload);
} catch (APIConnectionException e) {
log.error("极光推送连接异常: ", e);
} catch (APIRequestException e) {
log.error("极光推送请求异常: ", e);
}
if (result!=null && result.isResultOK()) {
log.info("极光推送请求成功: {}", result);
return true;
}else {
log.info("极光推送请求失败: {}", result);
return false;
}
}
}
\ No newline at end of file
package com.soss.system.push;
/**
* 推送服务
* 封装业务功能相关
*/
public interface PushService {
boolean pushAll(String message);
boolean push(String machineCode, Integer screenNo, String message);
boolean push(String machineCode, String message);
boolean sendPush(String machineCode, Integer screenNo, String message);
}
package com.soss.system.push.impl;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.push.PushService;
import com.soss.system.service.impl.MachineApiServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
/**
* 推送服务
* 封装业务功能相关
*/
@Service
@Slf4j
public class PushServiceImpl implements PushService {
@Autowired
@Lazy
private MachineApiServiceImpl machineApiService;
/**
* 推送全部, 不支持附加信息
*
* @return
*/
@Override
public boolean pushAll(String message) {
return sendPush(null, null, message);
}
/**
* 推送android 指定id
*
* @return
*/
@Override
public boolean push(String machineCode, Integer screenNo, String message) {
return sendPush(machineCode, screenNo, message);
}
@Override
public boolean push(String machineCode, String message) {
push(machineCode, 1, message);
push(machineCode, 2, message);
return true;
}
@Override
public boolean sendPush(String machineCode, Integer screenNo, String message) {
JSONObject requestBody = new JSONObject();
requestBody.put("machineCode", machineCode);
requestBody.put("screenNo", screenNo);
requestBody.put("message", message);
machineApiService.sendRequest(requestBody.toJSONString(), "/v1/push");
return true;
}
}
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.soss.common.enums.CouponCategoryType; import com.soss.common.enums.CouponCategoryType;
import com.soss.common.enums.CouponState; import com.soss.common.enums.CouponState;
import com.soss.common.enums.CouponUserType; import com.soss.common.enums.CouponUserType;
...@@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils; ...@@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -190,6 +192,9 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -190,6 +192,9 @@ public class CouponUserServiceImpl implements ICouponUserService {
BigDecimal orderTotalAmount = orderDetails.stream().map(OrderDetail::getAmountShould).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal orderTotalAmount = orderDetails.stream().map(OrderDetail::getAmountShould).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal orderTotalOrigDiscount = orderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal orderTotalOrigDiscount = orderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("orderTotalAmount:{}, orderTotalOrigDiscount:{}", orderTotalAmount, orderTotalOrigDiscount); log.info("orderTotalAmount:{}, orderTotalOrigDiscount:{}", orderTotalAmount, orderTotalOrigDiscount);
if (!CollectionUtils.isEmpty(couponVos)) {
orderDetails.forEach(x -> x.setAmountShould(x.getOrigDiscount()));
}
couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc())).forEach(couponVo -> { couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc())).forEach(couponVo -> {
/** 可用饮品范围的判断 */ /** 可用饮品范围的判断 */
List<Long> fitCouponGoodsIdList = goods.stream().filter(good -> List<Long> fitCouponGoodsIdList = goods.stream().filter(good ->
...@@ -206,15 +211,31 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -206,15 +211,31 @@ public class CouponUserServiceImpl implements ICouponUserService {
} }
/** 券价值的判断 */ /** 券价值的判断 */
if (couponVo.getType().equals(CouponCategoryType.DEDUCTION.getType())) { // 抵扣 if (couponVo.getType().equals(CouponCategoryType.DEDUCTION.getType())) { // 抵扣
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(orderTotalAmount) > 0) { if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(orderTotalOrigDiscount) > 0) {
couponVo.setNotFitableDesc("未达到满减要求"); couponVo.setNotFitableDesc("未达到满减要求");
return; return;
} }
couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalOrigDiscount)); couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalOrigDiscount));
AtomicReference<Integer> nums = new AtomicReference<>(0);
orderDetails.forEach(x -> nums.updateAndGet(v -> v + x.getNum()));
log.info("nums:{}", nums);
if (nums.get() <= 1) {
OrderDetail orderDetail = orderDetails.get(0);
orderDetail.setCouponAmount(couponVo.getCouponAmount().negate());
orderDetail.setRealAmount(orderDetail.getAmountShould().add(orderDetail.getCouponAmount()));
} else {
orderDetails.forEach(orderDetail -> {
BigDecimal rate = orderDetail.getAmountShould().divide(orderTotalOrigDiscount);
orderDetail.setCouponAmount(couponVo.getCouponAmount().negate().multiply(rate));
orderDetail.setRealAmount(orderDetail.getAmountShould().add(orderDetail.getCouponAmount()));
log.info("rate:{},detail:{}", rate, JSON.toJSON(orderDetail));
});
}
} else { } else {
List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList()); List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList());
BigDecimal fitGoodsAmount = fitOrderDetails.stream().map(OrderDetail::getAmountShould).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal fitGoodsAmount = fitOrderDetails.stream().map(x -> x.getAmountShould().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal fitGoodsOrigDiscount = fitOrderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal fitGoodsOrigDiscount = fitOrderDetails.stream().map(x -> x.getOrigDiscount().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("fitGoodsOrigDiscount:{}, fitGoodsAmount:{}", fitGoodsOrigDiscount, fitGoodsAmount); log.info("fitGoodsOrigDiscount:{}, fitGoodsAmount:{}", fitGoodsOrigDiscount, fitGoodsAmount);
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) { if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) {
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣 if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
...@@ -261,7 +282,7 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -261,7 +282,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
orderDetail.setOriAmount(skuNum.multiply(sku.getPrice())); orderDetail.setOriAmount(skuNum.multiply(sku.getPrice()));
orderDetail.setUnitPrice(sku.getDiscount()); orderDetail.setUnitPrice(sku.getDiscount());
orderDetail.setAmountShould(skuNum.multiply(sku.getDiscount())); orderDetail.setAmountShould(skuNum.multiply(sku.getDiscount()));
orderDetail.setOrigDiscount(sku.getOrigDiscount()); orderDetail.setOrigDiscount(skuNum.multiply(sku.getOrigDiscount()));
}); });
return goodsSkus; return goodsSkus;
} }
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.enums.SkuDeleteState; import com.soss.common.enums.SkuDeleteState;
...@@ -7,7 +8,7 @@ import com.soss.common.exception.ServiceException; ...@@ -7,7 +8,7 @@ import com.soss.common.exception.ServiceException;
import com.soss.common.utils.GenerateCode; import com.soss.common.utils.GenerateCode;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.push.impl.PushServiceImpl;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.service.IGoodsService; import com.soss.system.service.IGoodsService;
import jodd.util.StringPool; import jodd.util.StringPool;
...@@ -55,7 +56,7 @@ public class GoodsServiceImpl implements IGoodsService { ...@@ -55,7 +56,7 @@ public class GoodsServiceImpl implements IGoodsService {
@Autowired @Autowired
private MachineMapper machineMapper; private MachineMapper machineMapper;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private PushServiceImpl pushService;
/** /**
* 查询商品 * 查询商品
...@@ -398,8 +399,7 @@ public class GoodsServiceImpl implements IGoodsService { ...@@ -398,8 +399,7 @@ public class GoodsServiceImpl implements IGoodsService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "GOODS_CHANGED"); jsonObject.put("action", "GOODS_CHANGED");
jsonObject.put("timestamp", System.currentTimeMillis()); jsonObject.put("timestamp", System.currentTimeMillis());
int machineId = Integer.parseInt(machines.get(0).getId()); pushService.push(machines.get(0).getCode(), JSON.toJSONString(jsonObject));
jiGuangPushService.push(machineId, null, jsonObject);
} }
} }
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
...@@ -8,7 +9,7 @@ import com.soss.common.utils.StringUtils; ...@@ -8,7 +9,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.constants.OrderStatusConstant; import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.domain.vo.ResultVo; import com.soss.system.domain.vo.ResultVo;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.push.impl.PushServiceImpl;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -46,7 +47,7 @@ public class MachineApiServiceImpl { ...@@ -46,7 +47,7 @@ public class MachineApiServiceImpl {
@Autowired @Autowired
private GoodsMapper goodsMapper; private GoodsMapper goodsMapper;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private PushServiceImpl pushService;
@Autowired @Autowired
private OrderOperationLogServiceImpl operationLogService; private OrderOperationLogServiceImpl operationLogService;
...@@ -120,8 +121,7 @@ public class MachineApiServiceImpl { ...@@ -120,8 +121,7 @@ public class MachineApiServiceImpl {
data.put("goodsId", aLong); data.put("goodsId", aLong);
data.put("skuIds", map.get(aLong)); data.put("skuIds", map.get(aLong));
data.put("state", status); data.put("state", status);
int machineId = Integer.parseInt(machine.getId()); pushService.push(machine.getCode(), JSON.toJSONString(jsonObject));
jiGuangPushService.push(machineId, null, jsonObject);
} }
} }
...@@ -214,11 +214,10 @@ public class MachineApiServiceImpl { ...@@ -214,11 +214,10 @@ public class MachineApiServiceImpl {
} }
public ResultVo sendRequest(String param, String interfaceName) { public ResultVo sendRequest(String param, String interfaceName) {
try { try {
String postUrl = url + interfaceName; String postUrl = url + interfaceName;
log.info("请求订单接口[{}]:【{}】", postUrl, param); log.info("请求machine接口[{}]:【{}】", postUrl, param);
HttpHeaders requestHeaders = new HttpHeaders(); HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.APPLICATION_JSON); requestHeaders.setContentType(MediaType.APPLICATION_JSON);
HttpEntity requestEntity = new HttpEntity(param, requestHeaders); HttpEntity requestEntity = new HttpEntity(param, requestHeaders);
......
...@@ -7,7 +7,7 @@ import com.soss.common.utils.StringUtils; ...@@ -7,7 +7,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Goods; import com.soss.system.domain.Goods;
import com.soss.system.domain.Machine; import com.soss.system.domain.Machine;
import com.soss.system.domain.ShopRecommend; import com.soss.system.domain.ShopRecommend;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.push.impl.PushServiceImpl;
import com.soss.system.mapper.GoodsCategoryMapper; import com.soss.system.mapper.GoodsCategoryMapper;
import com.soss.system.mapper.MachineMapper; import com.soss.system.mapper.MachineMapper;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
...@@ -40,7 +40,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService { ...@@ -40,7 +40,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService {
@Autowired @Autowired
private GoodsCategoryMapper goodsCategoryMapper; private GoodsCategoryMapper goodsCategoryMapper;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private PushServiceImpl pushService;
/** /**
* 查询推荐和今日特惠 * 查询推荐和今日特惠
...@@ -113,8 +113,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService { ...@@ -113,8 +113,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "GOODS_CHANGED"); jsonObject.put("action", "GOODS_CHANGED");
jsonObject.put("timestamp", System.currentTimeMillis()); jsonObject.put("timestamp", System.currentTimeMillis());
int machineId = Integer.parseInt(machines.get(0).getId()); pushService.push(machines.get(0).getCode(), JSON.toJSONString(jsonObject));
jiGuangPushService.push(machineId, null, jsonObject);
} }
} }
......
...@@ -12,7 +12,7 @@ import com.soss.common.utils.StringUtils; ...@@ -12,7 +12,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.domain.vo.SkuCountVo; import com.soss.system.domain.vo.SkuCountVo;
import com.soss.system.domain.vo.orderTaking.*; import com.soss.system.domain.vo.orderTaking.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.push.impl.PushServiceImpl;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.service.IShopService; import com.soss.system.service.IShopService;
import com.soss.system.utils.ArrayUtil; import com.soss.system.utils.ArrayUtil;
...@@ -55,7 +55,7 @@ public class ShopServiceImpl implements IShopService { ...@@ -55,7 +55,7 @@ public class ShopServiceImpl implements IShopService {
@Autowired @Autowired
private ShopRecommendMapper shopRecommendMapper; private ShopRecommendMapper shopRecommendMapper;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private PushServiceImpl pushService;
@Autowired @Autowired
private GoodsTagMapper goodsTagMapper; private GoodsTagMapper goodsTagMapper;
@Autowired @Autowired
...@@ -276,10 +276,11 @@ public class ShopServiceImpl implements IShopService { ...@@ -276,10 +276,11 @@ public class ShopServiceImpl implements IShopService {
} }
public void updateApplication(Integer machineId) { public void updateApplication(Integer machineId) {
Machine machine = machineMapper.selectMachineById(String.valueOf(machineId));
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "GOODS_CHANGED"); jsonObject.put("action", "GOODS_CHANGED");
jsonObject.put("timestamp", System.currentTimeMillis()); jsonObject.put("timestamp", System.currentTimeMillis());
jiGuangPushService.push(machineId, null, jsonObject); pushService.push(machine.getCode(), JSON.toJSONString(jsonObject));
} }
@Override @Override
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
...@@ -8,8 +9,7 @@ import com.soss.system.domain.SysBanner; ...@@ -8,8 +9,7 @@ import com.soss.system.domain.SysBanner;
import com.soss.system.domain.po.BannerListPo; import com.soss.system.domain.po.BannerListPo;
import com.soss.system.domain.po.BannerPo; import com.soss.system.domain.po.BannerPo;
import com.soss.system.domain.vo.BannerVo; import com.soss.system.domain.vo.BannerVo;
import com.soss.system.domain.vo.PushBean; import com.soss.system.push.PushService;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.mapper.ShopMapper; import com.soss.system.mapper.ShopMapper;
import com.soss.system.mapper.SysBannerMapper; import com.soss.system.mapper.SysBannerMapper;
import com.soss.system.service.ISysBannerService; import com.soss.system.service.ISysBannerService;
...@@ -42,7 +42,7 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -42,7 +42,7 @@ public class SysBannerServiceImpl implements ISysBannerService {
@Autowired @Autowired
private AreaUtil areaUtil; private AreaUtil areaUtil;
@Autowired @Autowired
private JiGuangPushService jiGuangPushService; private PushService pushService;
@Override @Override
public List<SysBanner> selectBanner(BannerListPo banner) { public List<SysBanner> selectBanner(BannerListPo banner) {
...@@ -128,9 +128,7 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -128,9 +128,7 @@ public class SysBannerServiceImpl implements ISysBannerService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "BANNER_CHANGED"); jsonObject.put("action", "BANNER_CHANGED");
jsonObject.put("timestamp", System.currentTimeMillis()); jsonObject.put("timestamp", System.currentTimeMillis());
PushBean pushBean = new PushBean(); pushService.pushAll(JSON.toJSONString(jsonObject));
pushBean.setMessageCount(jsonObject);
jiGuangPushService.pushAll(pushBean);
} }
private SysBanner copyBanner(BannerPo bannerPo) { private SysBanner copyBanner(BannerPo bannerPo) {
......
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