Here are the examples of the java api org.springframework.context.ApplicationContext.publishEvent() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
113 Examples
19
View Source File : BasketServiceImpl.java
License : GNU Affero General Public License v3.0
Project Creator : zycSummer
License : GNU Affero General Public License v3.0
Project Creator : zycSummer
@Override
public List<ShopCartDto> getShopCarts(List<ShopCarreplacedemDto> shopCarreplacedems) {
// 根据店铺ID划分item
Map<Long, List<ShopCarreplacedemDto>> shopCartMap = shopCarreplacedems.stream().collect(Collectors.groupingBy(ShopCarreplacedemDto::getShopId));
// 返回一个店铺的所有信息
List<ShopCartDto> shopCartDtos = Lists.newArrayList();
for (Long shopId : shopCartMap.keySet()) {
// 获取店铺的所有商品项
List<ShopCarreplacedemDto> shopCarreplacedemDtoList = shopCartMap.get(shopId);
// 构建每个店铺的购物车信息
ShopCartDto shopCart = new ShopCartDto();
// 店铺信息
shopCart.setShopId(shopId);
shopCart.setShopName(shopCarreplacedemDtoList.get(0).getShopName());
applicationContext.publishEvent(new ShopCartEvent(shopCart, shopCarreplacedemDtoList));
shopCartDtos.add(shopCart);
}
return shopCartDtos;
}
19
View Source File : SpringUtils.java
License : Apache License 2.0
Project Creator : zuihou
License : Apache License 2.0
Project Creator : zuihou
public static ApplicationContext publishEvent(Object event) {
applicationContext.publishEvent(event);
return applicationContext;
}
19
View Source File : ConfigContext.java
License : Apache License 2.0
Project Creator : zouzhirong
License : Apache License 2.0
Project Creator : zouzhirong
/**
* 完成刷新
*
* @param versionPropertySource
*/
protected void finishRefresh(VersionPropertySource<ConfigItemList> versionPropertySource) {
// 发布事件
applicationContext.publishEvent(new ConfigItemChangeEvent(this, versionPropertySource));
}
19
View Source File : LogEventPublisher.java
License : GNU General Public License v3.0
Project Creator : zhonghuasheng
License : GNU General Public License v3.0
Project Creator : zhonghuasheng
public void publishLogEvent(String msg) {
applicationContext.publishEvent(new LogEvent(this, msg));
}
19
View Source File : EventBootstrap.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
public static void main(String[] args) {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("factory.bean/bean-post-processor.xml");
// 第一个参数是来源,第二个参数是自定义
CarEvent carEvent = new CarEvent("hello", "world");
context.publishEvent(carEvent);
// 消息发送之后,打印以下内容
// source : hello, custom message : world
}
19
View Source File : RateCheckTaskRunner.java
License : Apache License 2.0
Project Creator : tangaiyun
License : Apache License 2.0
Project Creator : tangaiyun
public boolean checkRun(String rateLimiterKey, TimeUnit timeUnit, int permits) {
CheckTask task = new CheckTask(rateLimiterKey, timeUnit, permits);
Future<Boolean> checkResult = executorService.submit(task);
boolean retVal = true;
try {
retVal = checkResult.get(redisLimiterProperties.getCheckActionTimeout(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
applicationContext.publishEvent(new RateCheckFailureEvent(e, "Access rate check task executed failed."));
}
return retVal;
}
19
View Source File : AbstractPuller.java
License : Apache License 2.0
Project Creator : sunshinelyz
License : Apache License 2.0
Project Creator : sunshinelyz
protected void publishClosedEvent(String metaId) {
applicationContext.publishEvent(new ClosedEvent(applicationContext, metaId));
}
19
View Source File : DemoPublisher.java
License : Apache License 2.0
Project Creator : longjiazuo
License : Apache License 2.0
Project Creator : longjiazuo
public void publish(String msg) {
// ②
applicationContext.publishEvent(new DemoEvent(this, msg));
}
19
View Source File : ObserverConfiguration.java
License : Apache License 2.0
Project Creator : javastacks
License : Apache License 2.0
Project Creator : javastacks
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext context) {
return (args) -> {
log.info("发布事件:什么是观察者模式?");
context.publishEvent(new JavaStackEvent("什么是观察者模式?"));
};
}
19
View Source File : SpringBootPlugin.java
License : Apache License 2.0
Project Creator : hank-cp
License : Apache License 2.0
Project Creator : hank-cp
@Override
public void stop() {
if (getWrapper().getPluginState() != PluginState.STARTED)
return;
log.debug("Stopping plugin {} ......", getWrapper().getPluginId());
releaseAdditionalResources();
// unregister Extension beans
for (String extensionName : injectedExtensionNames) {
log.debug("Unregister extension <{}> to main ApplicationContext", extensionName);
unregisterBeanFromMainContext(extensionName);
}
getMainRequestMapping().unregisterControllers(this);
applicationContext.publishEvent(new SbpPluginStoppedEvent(applicationContext));
ApplicationContextProvider.unregisterApplicationContext(applicationContext);
injectedExtensionNames.clear();
((ConfigurableApplicationContext) applicationContext).close();
log.debug("Plugin {} is stopped", getWrapper().getPluginId());
}
19
View Source File : UserService.java
License : MIT License
Project Creator : GoldSubmarine
License : MIT License
Project Creator : GoldSubmarine
@Transactional
public void deleteUser(Long id) {
// 删除用户角色关联表
User user = super.getById(id);
userRoleService.remove(new LambdaQueryWrapper<>(new UserRole()).eq(UserRole::getUserId, id));
super.removeById(id);
applicationContext.publishEvent(user.deleteEvent());
}
19
View Source File : UserService.java
License : MIT License
Project Creator : GoldSubmarine
License : MIT License
Project Creator : GoldSubmarine
@Transactional
public String saveUser(User user) {
// 编辑
checkUserNameDuplicate(user);
Dept dept = deptService.getDeptById(user.getDeptId());
user.setDeptIds(Optional.ofNullable(dept.getPids()).orElse("") + dept.getId() + ",");
user.setDeptName(dept.getName());
String randomPreplaced = computePreplacedword(user);
super.saveOrUpdate(user);
applicationContext.publishEvent(user.saveEvent());
return randomPreplaced;
}
19
View Source File : DemoPublisher.java
License : Apache License 2.0
Project Creator : drinkagain
License : Apache License 2.0
Project Creator : drinkagain
public void publish(long id, String message) {
applicationContext.publishEvent(new DemoEvent(this, id, message));
}
19
View Source File : ApplicationUtils.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
public static void publishEvent(Object event) {
applicationContext.publishEvent(event);
}
19
View Source File : FileContentStore.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Publishes an event to the application context that will notify any interested parties of the existence of this
* content store.
*
* @param context
* the application context
* @param extendedEventParams
*/
private void publishEvent(ApplicationContext context, Map<String, Serializable> extendedEventParams) {
context.publishEvent(new ContentStoreCreatedEvent(this, extendedEventParams));
}
19
View Source File : DemoPublisher.java
License : Apache License 2.0
Project Creator : ab-book
License : Apache License 2.0
Project Creator : ab-book
public void publish(String msg) {
applicationContext.publishEvent(new DemoEvent(this, msg));
}
18
View Source File : ApplicationContextProvider.java
License : Apache License 2.0
Project Creator : yangjian102621
License : Apache License 2.0
Project Creator : yangjian102621
public static void publishEvent(ApplicationEvent event) {
context.publishEvent(event);
}
18
View Source File : SpringUtil.java
License : MIT License
Project Creator : xkcoding
License : MIT License
Project Creator : xkcoding
/**
* 发布事件
*
* @param event 事件
*/
public static void publishEvent(ApplicationEvent event) {
if (applicationContext == null) {
return;
}
applicationContext.publishEvent(event);
}
18
View Source File : SpringUtil.java
License : GNU Lesser General Public License v3.0
Project Creator : xkcoding
License : GNU Lesser General Public License v3.0
Project Creator : xkcoding
/**
* 发布事件
*
* @param event 事件
*/
public static void publishEvent(ApplicationEvent event) {
if (context == null) {
return;
}
try {
context.publishEvent(event);
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
18
View Source File : SpringContextHolder.java
License : MIT License
Project Creator : wligang
License : MIT License
Project Creator : wligang
/**
* 发布事件
*
* @param event
*/
public static void publishEvent(ApplicationEvent event) {
if (applicationContext == null) {
return;
}
applicationContext.publishEvent(event);
}
18
View Source File : PayloadApplicationEventTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void testEventClreplacedWithInterface() {
ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.clreplaced);
AuditablePayloadEvent event = new AuditablePayloadEvent<>(this, "xyz");
ac.publishEvent(event);
replacedertTrue(ac.getBean(AuditableListener.clreplaced).events.contains(event));
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : tiankong0310
License : Apache License 2.0
Project Creator : tiankong0310
@Transactional(rollbackFor = {})
@Override
public void add(E enreplacedy) {
if (repository.existsById(enreplacedy.getFdId())) {
throw new RecordExistException();
}
doInit(enreplacedy);
beforeSaveOrUpdate(enreplacedy, true);
doValidate(enreplacedy, AddGroup.clreplaced, Default.clreplaced);
repository.save(enreplacedy);
afterSaveOrUpdate(enreplacedy, true);
// TODO 日志 add-处理
applicationContext.publishEvent(new EnreplacedyAddEvent(enreplacedy));
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : tiankong0310
License : Apache License 2.0
Project Creator : tiankong0310
@Transactional(rollbackFor = {})
@Override
public void delete(E enreplacedy) {
beforeDelete(enreplacedy);
applicationContext.publishEvent(new EnreplacedyDeleteEvent(enreplacedy));
repository.delete(enreplacedy);
// TODO 日志 delete-处理
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : tiankong0310
License : Apache License 2.0
Project Creator : tiankong0310
// ==================== 新建/初始化 ====================
@Override
public V init(Optional<V> oVO) {
// 创建一个Enreplacedy,并接收vo的参数
E enreplacedy = ReflectUtil.newInstance(getEnreplacedyClreplaced());
V vo = null;
if (oVO.isPresent()) {
vo = oVO.get();
vo.setFdId(null);
voToEnreplacedy(vo, enreplacedy, true);
} else {
vo = ReflectUtil.newInstance(getViewObjectClreplaced());
}
// 初始化
doInit(enreplacedy);
if (enreplacedy.getMechanisms() != null && enreplacedy.getMechanisms().get("load") != null) {
applicationContext.publishEvent(new EnreplacedyInitEvent(enreplacedy));
}
// 转换回VO
enreplacedyToVo(enreplacedy, vo, true);
return vo;
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : tiankong0310
License : Apache License 2.0
Project Creator : tiankong0310
@Transactional(rollbackFor = {})
@Override
public void update(E enreplacedy) {
beforeSaveOrUpdate(enreplacedy, false);
doValidate(enreplacedy, UpdateGroup.clreplaced, Default.clreplaced);
repository.save(enreplacedy);
afterSaveOrUpdate(enreplacedy, false);
applicationContext.publishEvent(new EnreplacedyUpdateEvent(enreplacedy));
}
18
View Source File : SimpleSampleApplicationTests.java
License : Apache License 2.0
Project Creator : tedburner
License : Apache License 2.0
Project Creator : tedburner
@Test
public void contextLoads() {
TestEvent testEvent = new TestEvent("hello", "msg");
applicationContext.publishEvent(testEvent);
}
18
View Source File : CanalScheduling.java
License : Apache License 2.0
Project Creator : starcwang
License : Apache License 2.0
Project Creator : starcwang
private void publishCreplacedEvent(Entry entry) {
EventType eventType = entry.getHeader().getEventType();
switch(eventType) {
case INSERT:
applicationContext.publishEvent(new InsertAbstractCreplacedEvent(entry));
break;
case UPDATE:
applicationContext.publishEvent(new UpdateAbstractCreplacedEvent(entry));
break;
case DELETE:
applicationContext.publishEvent(new DeleteAbstractCreplacedEvent(entry));
break;
default:
break;
}
}
18
View Source File : EnvironmentRefresher.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
private void refreshProperties(ConfigChangeEvent changeEvent) {
applicationContext.publishEvent(new EnvironmentChangeEvent(applicationContext, changeEvent.changedKeys()));
}
18
View Source File : SpringContextHolder.java
License : MIT License
Project Creator : rexlin600
License : MIT License
Project Creator : rexlin600
/**
* Publish event *
*
* @param event event
*/
public static void publishEvent(ApplicationEvent event) {
if (applicationContext == null) {
return;
}
applicationContext.publishEvent(event);
}
18
View Source File : PostServiceImpl.java
License : GNU General Public License v3.0
Project Creator : qiushi123
License : GNU General Public License v3.0
Project Creator : qiushi123
private void onPushEvent(Post post, int action) {
PostUpdateEvent event = new PostUpdateEvent(System.currentTimeMillis());
event.setPostId(post.getId());
event.setUserId(post.getAuthorId());
event.setAction(action);
applicationContext.publishEvent(event);
}
18
View Source File : SpringContextHolder.java
License : Apache License 2.0
Project Creator : pig-mesh
License : Apache License 2.0
Project Creator : pig-mesh
/**
* 发布事件
* @param event
*/
public static void publishEvent(ApplicationEvent event) {
if (applicationContext == null) {
return;
}
applicationContext.publishEvent(event);
}
18
View Source File : SpringContextHolder.java
License : GNU General Public License v3.0
Project Creator : nancheung97
License : GNU General Public License v3.0
Project Creator : nancheung97
/**
* 发布事件
*/
public static void publishEvent(ApplicationEvent event) {
if (applicationContext == null) {
return;
}
applicationContext.publishEvent(event);
}
18
View Source File : SystemLogAspect.java
License : Apache License 2.0
Project Creator : myxzjie
License : Apache License 2.0
Project Creator : myxzjie
/**
* 返回通知
*
* @param ret
* @throws Throwable
*/
@AfterReturning(returning = "ret", pointcut = "logPointcut()")
public void doAfterReturning(Map<String, Object> ret) {
SystemLog systemLog = currentSystemLogThreadLocal.get();
// 处理完请求,返回内容
// R r = Convert.convert(R.clreplaced, ret);
if (ret.get("code").equals(0)) {
// // 正常返回
systemLog.setType(1);
systemLog.setLevel("INFO");
} else {
systemLog.setType(2);
systemLog.setLevel("ERROR");
}
this.consumingTime(systemLog);
// 发布事件
context.publishEvent(new SystemLogEvent(systemLog));
this.remove();
}
18
View Source File : ApplicationContextTools.java
License : Apache License 2.0
Project Creator : minbox-projects
License : Apache License 2.0
Project Creator : minbox-projects
/**
* Publish a {@link ApplicationEvent}
*
* @param event The {@link ApplicationEvent} instance
*/
public static void publishEvent(ApplicationEvent event) {
context.publishEvent(event);
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : lihangqi
License : Apache License 2.0
Project Creator : lihangqi
@Transactional(rollbackFor = {})
@Override
public void add(E enreplacedy) {
if (repository.existsById(enreplacedy.getFdId())) {
throw new RecordExistException();
}
doInit(enreplacedy);
beforeSaveOrUpdate(enreplacedy, true);
doValidate(enreplacedy, AddGroup.clreplaced, Default.clreplaced);
repository.save(enreplacedy);
afterSaveOrUpdate(enreplacedy, true);
applicationContext.publishEvent(new EnreplacedyAddEvent(enreplacedy));
}
18
View Source File : AbstractServiceImpl.java
License : Apache License 2.0
Project Creator : lihangqi
License : Apache License 2.0
Project Creator : lihangqi
@Transactional(rollbackFor = {})
@Override
public void delete(E enreplacedy) {
beforeDelete(enreplacedy);
applicationContext.publishEvent(new EnreplacedyDeleteEvent(enreplacedy));
repository.delete(enreplacedy);
}
18
View Source File : SpringContextUtil.java
License : GNU Lesser General Public License v3.0
Project Creator : lets-mica
License : GNU Lesser General Public License v3.0
Project Creator : lets-mica
public static void publishEvent(ApplicationEvent event) {
if (context == null) {
return;
}
context.publishEvent(event);
}
18
View Source File : DisruptorApplicationContext.java
License : Apache License 2.0
Project Creator : hiwepy
License : Apache License 2.0
Project Creator : hiwepy
@Override
public void publishEvent(DisruptorEvent event) {
applicationContext.publishEvent(new DisruptorApplicationEvent(event));
}
18
View Source File : SpringBootPlugin.java
License : Apache License 2.0
Project Creator : hank-cp
License : Apache License 2.0
Project Creator : hank-cp
@Override
public void start() {
if (getWrapper().getPluginState() == PluginState.STARTED)
return;
long startTs = System.currentTimeMillis();
log.debug("Starting plugin {} ......", getWrapper().getPluginId());
applicationContext = springBootstrap.run();
getMainRequestMapping().registerControllers(this);
// register Extensions
Set<String> extensionClreplacedNames = getWrapper().getPluginManager().getExtensionClreplacedNames(getWrapper().getPluginId());
for (String extensionClreplacedName : extensionClreplacedNames) {
try {
log.debug("Register extension <{}> to main ApplicationContext", extensionClreplacedName);
Clreplaced<?> extensionClreplaced = getWrapper().getPluginClreplacedLoader().loadClreplaced(extensionClreplacedName);
SpringExtensionFactory extensionFactory = (SpringExtensionFactory) getWrapper().getPluginManager().getExtensionFactory();
Object bean = extensionFactory.create(extensionClreplaced);
String beanName = extensionFactory.getExtensionBeanName(extensionClreplaced);
registerBeanToMainContext(beanName, bean);
injectedExtensionNames.add(beanName);
} catch (ClreplacedNotFoundException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
ApplicationContextProvider.registerApplicationContext(applicationContext);
applicationContext.publishEvent(new SbpPluginStartedEvent(applicationContext));
if (getPluginManager().isMainApplicationStarted()) {
// if main application context is not ready, don't send restart event
applicationContext.publishEvent(new SbpPluginRestartedEvent(applicationContext));
}
log.debug("Plugin {} is started in {}ms", getWrapper().getPluginId(), System.currentTimeMillis() - startTs);
}
18
View Source File : OperationLogAspect.java
License : MIT License
Project Creator : godcheese
License : MIT License
Project Creator : godcheese
@AfterReturning(pointcut = "operationLogAspect()", returning = "returning")
public void afterReturning(Object returning) {
LOGGER.info("returning={}", returning);
applicationContext.publishEvent(new OperationLogEvent(operationLogEnreplacedy));
}
18
View Source File : SpringUtils.java
License : Apache License 2.0
Project Creator : freezek
License : Apache License 2.0
Project Creator : freezek
public static void publishEvent(ApplicationEvent event) {
if (context == null)
return;
context.publishEvent(event);
}
18
View Source File : PluginServiceImpl.java
License : Apache License 2.0
Project Creator : FlowCI
License : Apache License 2.0
Project Creator : FlowCI
@Override
public void clone(List<PluginRepoInfo> repos) {
log.info("Loading plugins");
for (PluginRepoInfo repo : repos) {
appTaskExecutor.execute(() -> {
try {
Plugin plugin = clone(repo);
saveOrUpdate(plugin);
context.publishEvent(new RepoCloneEvent(this, plugin));
log.info("Plugin {} been clone", plugin);
} catch (Exception e) {
log.warn("Unable to clone plugin repo {} {}", repo.getSource(), e.getMessage());
}
});
}
}
18
View Source File : EventApplication.java
License : Apache License 2.0
Project Creator : evasnowind
License : Apache License 2.0
Project Creator : evasnowind
public static void main(String[] args) {
log.info("EventApplication 服务开始启动...");
ApplicationContext context = SpringApplication.run(EventApplication.clreplaced, args);
NotifyEvent event = new NotifyEvent(context, "[email protected]", "This is the content");
context.publishEvent(event);
log.info("EventApplication 服务启动完成.");
}
18
View Source File : UserBehaviorPublistener.java
License : GNU General Public License v2.0
Project Creator : CipherChina
License : GNU General Public License v2.0
Project Creator : CipherChina
public void publish(UserBehaviorInfo userBehaviorInfo) {
applicationContext.publishEvent(new UserBehaviorEvent(this, userBehaviorInfo));
}
18
View Source File : EquipBehaviorPublistener.java
License : GNU General Public License v2.0
Project Creator : CipherChina
License : GNU General Public License v2.0
Project Creator : CipherChina
public void publish(EquipBehaviorInfo equipBehaviorInfo) {
applicationContext.publishEvent(new EquipBehaviorEvent(this, equipBehaviorInfo));
}
18
View Source File : AppBehaviorPublistener.java
License : GNU General Public License v2.0
Project Creator : CipherChina
License : GNU General Public License v2.0
Project Creator : CipherChina
public void publish(AppAuditInfo appAuditInfo) {
applicationContext.publishEvent(new AppBehaviorEvent(this, appAuditInfo));
}
18
View Source File : SpringUtil.java
License : GNU Lesser General Public License v3.0
Project Creator : chillzhuang
License : GNU Lesser General Public License v3.0
Project Creator : chillzhuang
public static void publishEvent(ApplicationEvent event) {
if (context == null) {
return;
}
try {
context.publishEvent(event);
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
18
View Source File : StudentAddBean.java
License : Apache License 2.0
Project Creator : bootsrc
License : Apache License 2.0
Project Creator : bootsrc
public void addStudent(String studentName) {
StudentAddEvent event = new StudentAddEvent(appContext, studentName);
System.out.println(">>>publishEvent");
appContext.publishEvent(event);
}
18
View Source File : ContextRefreshBean.java
License : Apache License 2.0
Project Creator : baidu
License : Apache License 2.0
Project Creator : baidu
@Override
public Ecreplacedquest getObject() {
applicationContext.publishEvent(new ContextRefreshedEvent(applicationContext));
return new Ecreplacedquest();
}
17
View Source File : ShopCartController.java
License : GNU Affero General Public License v3.0
Project Creator : zycSummer
License : GNU Affero General Public License v3.0
Project Creator : zycSummer
@PostMapping("/totalPay")
@ApiOperation(value = "获取选中购物项总计、选中的商品数量", notes = "获取选中购物项总计、选中的商品数量,参数为购物车id数组")
public ResponseEnreplacedy<ShopCartAmountDto> getTotalPay(@RequestBody List<Long> basketIds) {
// 拿到购物车的所有item
List<ShopCarreplacedemDto> dbShopCarreplacedems = basketService.getShopCarreplacedems(SecurityUtils.getUser().getUserId());
List<ShopCarreplacedemDto> chooseShopCarreplacedems = dbShopCarreplacedems.stream().filter(shopCarreplacedemDto -> {
for (Long basketId : basketIds) {
if (Objects.equals(basketId, shopCarreplacedemDto.getBasketId())) {
return true;
}
}
return false;
}).collect(Collectors.toList());
// 根据店铺ID划分item
Map<Long, List<ShopCarreplacedemDto>> shopCartMap = chooseShopCarreplacedems.stream().collect(Collectors.groupingBy(ShopCarreplacedemDto::getShopId));
double total = 0.0;
int count = 0;
double reduce = 0.0;
for (Long shopId : shopCartMap.keySet()) {
// 获取店铺的所有商品项
List<ShopCarreplacedemDto> shopCarreplacedemDtoList = shopCartMap.get(shopId);
// 构建每个店铺的购物车信息
ShopCartDto shopCart = new ShopCartDto();
shopCart.setShopId(shopId);
applicationContext.publishEvent(new ShopCartEvent(shopCart, shopCarreplacedemDtoList));
List<ShopCarreplacedemDiscountDto> shopCarreplacedemDiscounts = shopCart.getShopCarreplacedemDiscounts();
for (ShopCarreplacedemDiscountDto shopCarreplacedemDiscount : shopCarreplacedemDiscounts) {
List<ShopCarreplacedemDto> shopCarreplacedems = shopCarreplacedemDiscount.getShopCarreplacedems();
ChooseDiscounreplacedemDto chooseDiscounreplacedemDto = shopCarreplacedemDiscount.getChooseDiscounreplacedemDto();
// 如果满足优惠活动
if (chooseDiscounreplacedemDto != null && chooseDiscounreplacedemDto.getNeedAmount() <= chooseDiscounreplacedemDto.getProdsPrice()) {
reduce = Arith.add(reduce, chooseDiscounreplacedemDto.getReduceAmount());
}
for (ShopCarreplacedemDto shopCarreplacedem : shopCarreplacedems) {
count = shopCarreplacedem.getProdCount() + count;
total = Arith.add(shopCarreplacedem.getProductTotalAmount(), total);
}
}
}
ShopCartAmountDto shopCartAmountDto = new ShopCartAmountDto();
shopCartAmountDto.setCount(count);
shopCartAmountDto.setTotalMoney(total);
shopCartAmountDto.setSubtractMoney(reduce);
shopCartAmountDto.setFinalMoney(Arith.sub(shopCartAmountDto.getTotalMoney(), shopCartAmountDto.getSubtractMoney()));
return ResponseEnreplacedy.ok(shopCartAmountDto);
}
See More Examples