feat(商城): 代码优化

master
wayn 10 months ago
parent f52c005cdb
commit 6daf514f45

@ -40,7 +40,7 @@ public class EmailController {
sendMailVO.setSubject(subject);
sendMailVO.setContent(content);
sendMailVO.setTos(Collections.singletonList(tos));
MailUtil.sendMail(emailConfig, sendMailVO, false, false);
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
return R.success();
}
}

@ -46,7 +46,7 @@ public class EmailConfigController {
if (!mailConfigService.checkMailConfig(emailConfig)) {
return R.error(ReturnCodeEnum.TOOL_EMAIL_ERROR);
}
MailUtil.sendMail(emailConfig, mailVO, false, false);
MailUtil.sendMail(emailConfig, mailVO, false, true);
return R.success();
}
}

@ -53,8 +53,8 @@ es:
config:
host: 127.0.0.1
port: 9200
username:
password:
username: elastic
password: 123456
scheme: http
shards: 3
replicas: 2

@ -78,6 +78,15 @@ public class CacheConfig implements CachingConfigurer {
return new MyRedisCacheManager(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory), defaultCacheConfig());
}
// @Bean
// public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
// return RedisCacheManager.builder(redisConnectionFactory)
// .cacheDefaults(defaultCacheConfig())
// .transactionAware()
// .build();
// }
private RedisCacheConfiguration defaultCacheConfig() {
return RedisCacheConfiguration.defaultCacheConfig()
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(keySerializer()))

@ -14,8 +14,8 @@ public enum RedisKeyEnum {
ES_SYNC_CACHE(CacheConstants.CACHE_PREFIX + "es_sync_cache", 3600),
CART_LOCK(CacheConstants.CACHE_PREFIX + "cart_lock:", 3600),
EMAIL_CONSUMER_MAP(CacheConstants.CACHE_PREFIX + "email_consumer_map", 60),
ORDER_CONSUMER_MAP(CacheConstants.CACHE_PREFIX + "order_consumer_map", 60),
UNPAID_ORDER_CONSUMER_MAP(CacheConstants.CACHE_PREFIX + "unpaid_order_consumer_map", 60),
ORDER_CONSUMER_MAP(CacheConstants.CACHE_PREFIX + "order_consumer_key", 60),
UNPAID_ORDER_CONSUMER_MAP(CacheConstants.CACHE_PREFIX + "unpaid_order_consumer_key", 60),
ORDER_RESULT_KEY(CacheConstants.CACHE_PREFIX + "order_result_key:", 60),
;

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.wayn.message.api.MobileApi;
import com.wayn.message.core.constant.MQConstants;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.retry.annotation.Backoff;
@ -17,6 +18,7 @@ import org.springframework.web.client.RestTemplate;
* @author: waynaqua
* @date: 2023/8/20 18:30
*/
@Slf4j
@Service
public class MobileApiImpl implements MobileApi {
@Resource
@ -36,6 +38,7 @@ public class MobileApiImpl implements MobileApi {
multiValueMap.add("order", msgObject.get("order"));
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(multiValueMap, headers);
ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class);
log.info("submitOrder response:{}", response.getBody());
if (response.getStatusCode().value() != HttpStatus.OK.value()) {
throw new Exception("调用mobile下单api失败 body" + body);
}
@ -60,6 +63,7 @@ public class MobileApiImpl implements MobileApi {
multiValueMap.add("orderSn", orderSn);
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(multiValueMap, headers);
ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class);
log.info("unpaidOrder response:{}", response.getBody());
if (response.getStatusCode().value() != HttpStatus.OK.value()) {
throw new Exception("调用mobile未支付订单超时取消api失败 body" + body);
}
@ -85,6 +89,7 @@ public class MobileApiImpl implements MobileApi {
multiValueMap.add("tos", msgObject.get("tos"));
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(multiValueMap, headers);
ResponseEntity<String> response = restTemplate.postForEntity(notifyUrl, request, String.class);
log.info("sendEmail response:{}", response.getBody());
if (response.getStatusCode().value() != HttpStatus.OK.value()) {
throw new Exception("调用mobile发送邮件api失败 body" + body);
}

@ -147,7 +147,7 @@ public class LoginController {
sendMailVO.setSubject("mall商城注册通知");
sendMailVO.setContent("邮箱验证码:" + verCode);
sendMailVO.setTos(Collections.singletonList(registryObj.getEmail()));
MailUtil.sendMail(emailConfig, sendMailVO, false, false);
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
});
return R.success().add("emailKey", key);
}

@ -88,7 +88,7 @@ public class UserController {
sendMailVO.setSubject("mall商城重置密码通知");
sendMailVO.setContent("邮箱验证码:" + verCode);
sendMailVO.setTos(Collections.singletonList(registryObj.getEmail()));
MailUtil.sendMail(emailConfig, sendMailVO, false, false);
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
return R.success().add("key", key);
}

@ -26,7 +26,7 @@ public class EmailController {
sendMailVO.setSubject(subject);
sendMailVO.setContent(content);
sendMailVO.setTos(List.of(tos));
MailUtil.sendMail(emailConfig, sendMailVO, false, false);
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
return R.success();
}
}

@ -37,7 +37,7 @@ public class IHomeServiceImpl implements IHomeService {
private ThreadPoolTaskExecutor commonThreadPoolTaskExecutor;
@Cacheable(value = "home_index_cache#600", unless = "#result == null")
@Cacheable(value = "home_index_cache#300", unless = "#result == null")
@Override
public HomeIndexResponseVO index() {
HomeIndexResponseVO responseVO = new HomeIndexResponseVO();

Loading…
Cancel
Save