Merge branch 'master' of codeup.aliyun.com:64d9c5feeceb191898f636d7/honor-dd-light-ds-java

20230922-ljl-fixBug
ljl 1 year ago
commit bd0116a550

@ -5,8 +5,8 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \
--data-raw '{
"appId":"7264840234423027259",
"authId":"4463798",
"method":"testSpi",
"data":"{\"moveCollectTaskDetailIds\":[26],\"deleteOnSaleProduct\":0,\"deleteProduct\":0}"
"method":"memberAuthCallBack",
"data":"{\"url\":\"/api/open/lightapp/callback/1688/7264840234423027259/memberAuthCallBack\",\"body\":\"{\\\"userId\\\":\\\"111087462\\\",\\\"cnaliMemberId\\\":\\\"b2b-6848123449731a\\\",\\\"authCode\\\":\\\"NGVkNWM1NjctNzYxMy01YWIwLWI5MDUtMmFhYjYwZGFiYzI5\\\",\\\"gmtMemberExpireTime\\\":\\\"2023-12-21 23:59:59\\\",\\\"type\\\":\\\"auth\\\"}\"}"
}'

@ -495,12 +495,14 @@ public class DoudianMsgServiceImpl implements DoudianMsgService {
return null;
}
row.setLocked(1L);
DoudianTradeMsgQueue updateData = new DoudianTradeMsgQueue();
updateData.setDoudianTradeMsgQueueId(row.getDoudianTradeMsgQueueId());
updateData.setLocked(1L);
// row.setHostname("");
row.setGmtLastHeartbeat(new Date());
row.setGmtLocked(new Date());
row.setGmtModified(new Date());
int affRow = doudianTradeMsgQueueMapper.updateByPrimaryKeySelective(row);
updateData.setGmtLastHeartbeat(new Date());
updateData.setGmtLocked(new Date());
updateData.setGmtModified(new Date());
int affRow = doudianTradeMsgQueueMapper.updateByPrimaryKeySelective(updateData);
if (affRow == 1) {
// todo: 心跳后面想想怎么搞
return row;
@ -531,12 +533,14 @@ public class DoudianMsgServiceImpl implements DoudianMsgService {
return null;
}
row.setLocked(1);
DoudianAftersaleMsgQueue updateData = new DoudianAftersaleMsgQueue();
updateData.setDoudianAftersaleMsgQueueId(row.getDoudianAftersaleMsgQueueId());
updateData.setLocked(1);
// row.setHostname("");
row.setGmtLastHeartbeat(new Date());
row.setGmtLocked(new Date());
row.setGmtModified(new Date());
int affRow = doudianAftersaleMsgQueueMapper.updateByPrimaryKeySelective(row);
updateData.setGmtLastHeartbeat(new Date());
updateData.setGmtLocked(new Date());
updateData.setGmtModified(new Date());
int affRow = doudianAftersaleMsgQueueMapper.updateByPrimaryKeySelective(updateData);
if (affRow == 1) {
// todo: 心跳后面想想怎么搞
return row;

@ -68,13 +68,16 @@ public class OpOrderRsyncPageQueueServiceImpl implements OpOrderRsyncPageQueueSe
if (ObjectUtil.isEmpty(row)) {
return null;
}
OpOrderRsyncPageQueue updateData = new OpOrderRsyncPageQueue();
updateData.setOpOrderRsyncPageQueueId(row.getOpOrderRsyncPageQueueId());
Date date = new Date();
row.setLocked(timerLockId);
row.setHostname("");
row.setGmtLastHeartbeat(date);
row.setGmtModified(date);
row.setGmtLocked(date);
int affectRows = opOrderRsyncPageQueueMapper.updateByPrimaryKey(row);
updateData.setLocked(timerLockId);
updateData.setHostname("");
updateData.setGmtLastHeartbeat(date);
updateData.setGmtModified(date);
updateData.setGmtLocked(date);
int affectRows = opOrderRsyncPageQueueMapper.updateByPrimaryKeySelective(updateData);
if (affectRows == 1) {
return row;
}

@ -65,13 +65,16 @@ public class OpOrderRsyncQueueServiceImpl implements OpOrderRsyncQueueService {
if (ObjectUtil.isEmpty(row)) {
return null;
}
OpOrderRsyncQueue updateData = new OpOrderRsyncQueue();
updateData.setOpOrderRsyncQueueId(row.getOpOrderRsyncQueueId());
Date date = new Date();
row.setLocked(timerLockId);
row.setHostname("");
row.setGmtLastHeartbeat(date);
row.setGmtModified(date);
row.setGmtLocked(date);
int affectRows = opOrderRsyncQueueMapper.updateByPrimaryKey(row);
updateData.setLocked(timerLockId);
updateData.setHostname("");
updateData.setGmtLastHeartbeat(date);
updateData.setGmtModified(date);
updateData.setGmtLocked(date);
int affectRows = opOrderRsyncQueueMapper.updateByPrimaryKeySelective(updateData);
if (affectRows == 1) {
return row;
}

@ -1,6 +1,7 @@
package com.ms.api.spi.callback;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.token_create.TokenCreateRequest;
import com.doudian.open.api.token_create.TokenCreateResponse;
import com.doudian.open.api.token_create.data.TokenCreateData;
@ -45,24 +46,24 @@ public class MemberAuthCallbackService extends SPIBaseService implements Extensi
MemberAuthCallBackRequestDTO fields = req.getData();
log.info("receive callback: " + JSON.toJSONString(fields));
String body = fields.getBody();
// String body = "userId=4463798&cnaliMemberId=b2b-221123084407697b20&authCode=NGNiYzEyODUtNzFhOS01ZmIwLWE5MDEtYzI3ZTAyYWFjOTA3&gmtMemberExpireTime=2023-11-13+23%3A59%3A59&type=auth";
Map<String, String> map = new HashMap<String, String>();
// String body = "{\"userId\":\"111087462\",\"cnaliMemberId\":\"b2b-6848123449731a\",\"authCode\":\"NGVkNWM1NjctNzYxMy01YWIwLWI5MDUtMmFhYjYwZGFiYzI5\",\"gmtMemberExpireTime\":\"2023-12-21 23:59:59\",\"type\":\"auth\"}";
// ----逻辑校验----
// ----业务处理----
try {
final String charset = "utf-8";
String contents = URLDecoder.decode(body, charset);
String[] keyValues = contents.split("&");
for (int i = 0; i < keyValues.length; i++) {
String key = keyValues[i].substring(0, keyValues[i].indexOf("="));
String value = keyValues[i].substring(keyValues[i].indexOf("=") + 1);
map.put(key, value);
}
String authCode = map.get("authCode");
String cnaliMemberId = map.get("cnaliMemberId");
String gmtMemberExpireTime = map.get("gmtMemberExpireTime");
String userId = map.get("userId");
// final String charset = "utf-8";
// String contents = URLDecoder.decode(body, charset);
// String[] keyValues = contents.split("&");
// for (int i = 0; i < keyValues.length; i++) {
// String key = keyValues[i].substring(0, keyValues[i].indexOf("="));
// String value = keyValues[i].substring(keyValues[i].indexOf("=") + 1);
// map.put(key, value);
// }
JSONObject map = JSONObject.parseObject(body);
String authCode = map.getString("authCode");
String cnaliMemberId = map.getString("cnaliMemberId");
String gmtMemberExpireTime = map.getString("gmtMemberExpireTime");
String userId = map.getString("userId");
this.authCode = fields.getAuthCode();
Shop1688DsAuth shop1688DsAuth = shop1688DsAuthService.getDetailByShopId(Long.valueOf(userId));

@ -21,6 +21,7 @@ import com.ms.api.tool.SecurityTool;
import com.ms.dal.entity.Shop;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -55,10 +56,14 @@ public class ShopAuthCallbackService extends SPIBaseService implements Extension
Integer msgType = bodyObj.getInteger("msg_type");
String msg = bodyObj.getString("msg");
JSONObject msgObj = JSONObject.parseObject(msg);
Long shopId = msgObj.getLong("shop_id");
Long shopId = null;
String shopName = "";
Long expireTime = null;
String appVersion = "";
if (msgType == 2) { // 授权消息
shopId = msgObj.getLong("shop_id");
String code = msgObj.getString("code");
String shopName = "";
try {
TokenCreateRequest request = new TokenCreateRequest();
@ -73,21 +78,35 @@ public class ShopAuthCallbackService extends SPIBaseService implements Extension
log.error("获取商户信息失败", e);
}
Shop shop = shopService.getDetailById(shopId);
if (Objects.isNull(shop)) {
shop = new Shop();
shop.setShopId(shopId);
shop.setGmtCreate(new Date());
shop.setGmtModified(new Date());
shop.setShopName(shopName);
shopService.insertSelective(shop);
}
} else if (msgType == 1) { // 支付消息
JSONObject orderInfoObj = msgObj.getJSONObject("order_info");
shopId = orderInfoObj.getLong("shop_id");
expireTime = orderInfoObj.getLong("service_end_time");
JSONObject pushSkuInfoObj = orderInfoObj.getJSONObject("push_sku_info");
appVersion = pushSkuInfoObj.getString("spec_value");
}
Shop shop = shopService.getDetailById(shopId);
boolean isNewShop = Objects.isNull(shop);
Shop shopData = new Shop();
shopData.setShopId(shopId);
shopData.setGmtModified(new Date());
if (StringUtils.isNotEmpty(shopName)) {
shopData.setShopName(shopName);
}
if (StringUtils.isNotEmpty(appVersion)) {
shopData.setAppVersion(appVersion);
}
if (expireTime != null) {
shopData.setGmtExpire(new Date(expireTime * 1000L));
}
if (isNewShop) {
shopData.setGmtCreate(new Date());
shopService.insertSelective(shopData);
} else {
shopService.updateByPrimaryKeySelective(shopData);
}
// 按照三方平台的规范返回成功或失败的body值
String respBody = "{\"success\":true,\"code\":0}";

@ -833,13 +833,13 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return productFormatNew;
}
private Map<Long, List<StrObjMap>> buildProductAttrs(List<DataItem> attributes, JSONObject sourceAttrs, String title, MoveProductPublishQueueBO queueMsg) {
Map<Long, List<StrObjMap>> matchAttrs = new HashMap<>();
private Map<String, List<StrObjMap>> buildProductAttrs(List<DataItem> attributes, JSONObject sourceAttrs, String title, MoveProductPublishQueueBO queueMsg) {
Map<String, List<StrObjMap>> matchAttrs = new HashMap<>();
for (DataItem attribute : attributes) {
long currAid = attribute.getPropertyId();
List<StrObjMap> matchList = matchSourceAttr(attribute, sourceAttrs, title);
if (ObjectUtil.isNotEmpty(matchList)) {
matchAttrs.put(currAid, matchList);
matchAttrs.put(String.valueOf(currAid), matchList);
}
}
log.info(JSON.toJSONString(matchAttrs));
@ -857,18 +857,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
} else {
matchAttr = matchProductAttributesByOption(attribute, sourceAttrs, title);
}
log.info("type:" + attribute.getType() + "--" + JSON.toJSONString(matchAttr));
List<StrObjMap> result = new ArrayList<>();
if (ObjectUtil.isNotEmpty(matchAttr)) {
for (StrObjMap v : matchAttr) {
StrObjMap item = new StrObjMap();
item.put("name", v.get("name"));
item.put("diy_type", v.get("diy_type"));
item.put("value", 100);
result.add(item);
}
}
return result;
return matchAttr;
}
public List<StrObjMap> matchProductAttributesByOption(DataItem attribute, JSONObject sourceAttrs, String title) {
@ -1170,7 +1159,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
sourceValue = getDefaultValueByAttrName(attribute.getPropertyName(), sourceValue);
if (sourceValue == null && !isReq) {
if (ObjectUtil.isEmpty(sourceValue) && !isReq) {
return null;
}
@ -1201,18 +1190,19 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
if (!matchSourceAttrs.isEmpty()) {
if (sourceAttrs.containsKey(attribute.getPropertyName())) {
sourceAttrs.remove(attribute.getPropertyName());
} else {
for (String key : sourceAttrs.keySet()) {
sourceAttrs.remove(key);
}
}
// else {
// for (String key : sourceAttrs.keySet()) {
// sourceAttrs.remove(key);
// }
// }
}
if (sourceValue != null) {
StrObjMap matchAttr = new StrObjMap();
matchAttr.put("name", attribute.getPropertyName());
matchAttr.put("name", sourceValue);
matchAttr.put("diy_type", 0);
matchAttr.put("value", sourceValue);
matchAttr.put("value", 0);
return Collections.singletonList(matchAttr);
}
return null;

Loading…
Cancel
Save