20240115-ljl-multiPay
ljl 1 year ago
parent 4b0dc1181c
commit 2bde53c616

@ -0,0 +1,18 @@
package com.ms.api.dto.common;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
@Data
public class DoudianMessage implements Serializable {
@JSONField(name = "tag")
private String tag;
@JSONField(name = "msg_id")
private String msg_id;
@JSONField(name = "data")
private String data;
}

@ -0,0 +1,27 @@
package com.ms.biz.listener;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
//@Component
public class JobListener implements ApplicationListener<ContextRefreshedEvent>, Runnable {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
JobListener listener = event.getApplicationContext().getBean(JobListener.class);
new Thread(this).start();
}
@Override
public void run() {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println("run run run...");
}
}
}

@ -56,9 +56,11 @@ public class MqDemoService implements ApplicationListener<ContextRefreshedEvent>
public void testConsumer() {
DefaultMQPushConsumer consumer = MqFactory.newMqConsumer(GROUP, TOPIC, new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
log.info("testConsumer Receive New Messages: {}", JSON.toJSONString(msgs));
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> messages, ConsumeConcurrentlyContext context) {
log.info("testConsumer Receive New Messages: {}", JSON.toJSONString(messages));
for (MessageExt message: messages) {
message.getBody();
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});

@ -8,6 +8,7 @@ import com.ms.biz.common.R;
import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.BatchCreateParam;
import com.ms.biz.dto.openspi.response.BatchCreateData;
import com.ms.biz.dto.openspi.response.BatchPayData;
import com.ms.biz.service.DistributionOrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -20,9 +21,13 @@ public class BatchCreateService extends SPIBaseService implements ExtensionServi
@Override
public BaseResponse<BatchCreateData> handle(BaseRequest<BatchCreateParam> req) {
try {
BatchCreateParam param = req.getData();
BatchCreateData data = new BatchCreateData();
distributionOrderService.batchCreate(param, data);
return R.ok(data);
return BaseResponse.<BatchCreateData>builder().success(true).message("success").code("0").data(data).build();
} catch (Exception e) {
return BaseResponse.<BatchCreateData>builder().success(true).message(e.getMessage()).code("100003").build();
}
}
}

@ -29,24 +29,7 @@ public class DoudianMsgReceiveService extends SPIBaseService implements Extensio
}
for (String msgStr: msgList) {
DoudianMessage msg = JSON.parseObject(msgStr, DoudianMessage.class);
}
// ----逻辑校验----
// ----业务处理----
boolean addRet = false;
try {
addRet = doudianMsgService.addDoudianMsg(msgBody);
} catch (Exception e) {
log.error(String.format("addDoudianMsg fail, exception: %s", e.getMessage()));
}
if (!addRet) {
log.info(String.format("fail msgBody: %s", JSON.toJSONString(msgList)));
return BaseResponse.<Void>builder().success(false).code("1").build();
}
// 处理成功则返回 true code 0
return BaseResponse.<Void>builder().success(true).code("0").build();
}

@ -1,13 +1,12 @@
package com.ms.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.annotation.JSONField;
import com.doudian.open.api.supplyCenter_cargo_detail.data.SupplyCenterCargoDetailData;
import com.doudian.open.api.supplyCenter_cargo_detail.param.SupplyCenterCargoDetailParam;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.core.util.AuthThreadLocalUtil;
import com.ms.api.dto.common.DoudianMessage;
import com.ms.api.dto.dsapi.response.CheckDsAppAuthExpireResponseDTO;
import com.ms.api.dto.dsapi.response.GetAuthInfoResponseDTO;
import com.ms.api.dto.dsapi.response.GetAuthShopMemberInfosResponseDTO;
@ -18,7 +17,7 @@ import com.ms.api.dto.dsorder.DsMessageCallbackDTO;
import com.ms.biz.service.*;
import com.ms.biz.tool.CommonTool;
import com.ms.biz.util.DDApi;
import com.ms.dal.entity.Shop;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import java.io.Serializable;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -99,6 +99,10 @@ public class Test {
}
public static void main(String[] args) throws ParseException {
String str = "{\"data\":\"{\\\"activity_id\\\":\\\"0\\\",\\\"after\\\":\\\"false\\\",\\\"before\\\":\\\"true\\\",\\\"channel_id\\\":\\\"0\\\",\\\"channel_type\\\":0,\\\"process_time\\\":1699455945,\\\"product_id\\\":\\\"3649553844716833566\\\",\\\"shop_id\\\":\\\"121233657\\\",\\\"sku_id\\\":\\\"3384401776121602\\\"}\",\"tag\":\"420\",\"msg_id\":\"66533861744835594630:0:420:1699455945:2560971988:7264840234423027259\"}";
DoudianMessage msg = JSON.parseObject(str, DoudianMessage.class);
System.out.println(msg);
System.out.println(Double.valueOf(CommonTool.doubleTrans(CommonTool.noZeros(2.00d))));
System.out.println("ni号顺11".length());
System.out.println("ni号顺11".substring(0, 6));

Loading…
Cancel
Save