Commit dbe5c08e authored by 王亮's avatar 王亮

format code.

parent f6d61138
package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.UserRegisterParam;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.time.LocalDate;
......@@ -14,43 +13,47 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* 用户注册发送给合同中心事件监听
*/
@Slf4j
@Component
public class BlackHoleRegisteredEventListener implements ApplicationListener<RegisterEvent> {
@Value("${registered.notify.black.hole.rabbitmq.connection.exchange}")
private String exchange;
@Value("${registered.notify.black.hole.rabbitmq.connection.routingKey}")
private String routingKey;
@Resource
private RabbitTemplate registeredNotifyBlackHoleRabbitTemplate;
@Value("${registered.notify.black.hole.rabbitmq.connection.exchange}")
private String exchange;
@Value("${registered.notify.black.hole.rabbitmq.connection.routingKey}")
private String routingKey;
@Resource
private RabbitTemplate registeredNotifyBlackHoleRabbitTemplate;
// 用户注册合同中心模版id
@Value("#{'${register.templateids}'.split(',')}")
private List<Long> templateIds;
// 用户注册合同中心模版id
@Value("#{'${register.templateids}'.split(',')}")
private List<Long> templateIds;
@Override
public void onApplicationEvent(RegisterEvent event) {
User user = event.getUserRegisterParam().getUser();
log.info("onApplicationEvent cn.quantgroup.xyqb.event.BlackHoleRegisteredEventListener start userId = 【{}】, registerFrom = 【{}】", user.getId(), event);
LocalDate signDate = LocalDate.now();
String dateStr = signDate.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
int day = signDate.getDayOfMonth();
// 信用钱包服务与隐私协议
templateIds.forEach(id->{
JSONObject fields = new JSONObject();
fields.put("phoneNo", user.getPhoneNo());
fields.put("genarateDateStr", dateStr);
fields.put("day", day);
JSONObject json = new JSONObject();
json.put("userId", user.getId());
json.put("mustReal", false);
json.put("templateId", id);
json.put("fields", fields);
JSONArray array = new JSONArray();
array.add(json);
registeredNotifyBlackHoleRabbitTemplate.convertAndSend(exchange, routingKey, array.toString());
});
}
@Override
public void onApplicationEvent(RegisterEvent event) {
User user = event.getUserRegisterParam().getUser();
log.info("onApplicationEvent start userId = 【{}】, registerFrom = 【{}】", user.getId(), event);
LocalDate signDate = LocalDate.now();
String dateStr = signDate.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
int day = signDate.getDayOfMonth();
// 信用钱包服务与隐私协议
templateIds.forEach(id -> {
JSONObject fields = new JSONObject();
fields.put("phoneNo", user.getPhoneNo());
fields.put("genarateDateStr", dateStr);
fields.put("day", day);
JSONObject json = new JSONObject();
json.put("userId", user.getId());
json.put("mustReal", false);
json.put("templateId", id);
json.put("fields", fields);
JSONArray array = new JSONArray();
array.add(json);
registeredNotifyBlackHoleRabbitTemplate.convertAndSend(exchange, routingKey,
array.toString());
});
}
}
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