Commit 2be4b365 authored by shiyu's avatar shiyu

问题修复3

parent f3da4b6c
......@@ -341,6 +341,10 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
auctionRecordVo.setState(DistributionEnum.AuctionStateEnum.END.getCode());
auctionRecordVo.setStateName(DistributionEnum.AuctionStateEnum.END.getDes());
} else {
if (lastedRecord.getUserId().longValue() == dto.getUserId().longValue()) {
auctionRecordVo.setUserState(DistributionEnum.AuctionUserStateEnum.LEAD.getCode());
auctionRecordVo.setUserStateName(DistributionEnum.AuctionUserStateEnum.LEAD.getDes());
}
auctionRecordVo.setState(DistributionEnum.AuctionStateEnum.IN_AUCTION.getCode());
auctionRecordVo.setStateName(DistributionEnum.AuctionStateEnum.IN_AUCTION.getDes());
}
......
......@@ -189,6 +189,11 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
RLock lock = redissonClient.getLock(itemIdKey);
try {
if (lock.tryLock(5, 5, TimeUnit.SECONDS)) {
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(dto.getItemId());
if (auctionRecord.getUserId().longValue() != dto.getBuyerId().longValue()) {
return Result.failed("下单信息错误");
}
String distributionOrderId = IdUtils.getOrderNumber(DISTRIBUTION_ORDER_PREFIX);
Map<String, String> map = new HashMap<>();
//判断是否该商品已创建了订单
DistributionOrder searchOrder = distributionOrderDao.findByItemId(dto.getItemId());
......@@ -196,11 +201,6 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
map.put("distributionOrderId", searchOrder.getDistributionOrderId());
return Result.success(map);
}
String distributionOrderId = IdUtils.getOrderNumber(DISTRIBUTION_ORDER_PREFIX);
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(dto.getItemId());
if (auctionRecord.getUserId().longValue() != dto.getBuyerId().longValue()) {
return Result.failed("下单信息错误");
}
Date now = new Date();
AuctionConfig auctionConfig = auctionConfigDao.findByItemId(dto.getItemId());
//查询用户第一次出价对应的分销商
......
......@@ -157,90 +157,204 @@ public class SendMsgServiceImpl implements SendMsgService {
@Override
public Result sendAuctionOfferOutMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId =auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "lO-SF3tbPEbC7bDZxRk-x6lcwp1FrNP7T3SGd160uYM");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
try {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "lO-SF3tbPEbC7bDZxRk-x6lcwp1FrNP7T3SGd160uYM");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing4", new HashMap(){{put("value", auctionOfferNoticeMsg.getItemName().substring(0,20));}});
paramMap.put("amount5", new HashMap(){{put("value", auctionOfferNoticeMsg.getCurrentPrice());}});
map.put("data", paramMap);
logger.info("============ 拍卖出价被超越通知模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送拍卖出价被超越通知模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送拍卖出价被超越通知模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing4", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName().substring(0, 20));
}});
paramMap.put("amount5", new HashMap() {{
put("value", auctionOfferNoticeMsg.getCurrentPrice());
}});
map.put("data", paramMap);
logger.info("============ 拍卖出价被超越通知模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送拍卖出价被超越通知模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送拍卖出价被超越通知模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送拍卖出价被超越通知模板消息成功 ===========");
return Result.success();
} catch (Exception e) {
e.printStackTrace();
}
logger.info("=============发送拍卖出价被超越通知模板消息成功 ===========");
return Result.success();
return Result.failed();
}
@Override
public Result auctionSuccessMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "Yy_58dviNzK1sDOilw6FnolJysIceRjm6qkhCN0RgcQ");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
try {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "Yy_58dviNzK1sDOilw6FnolJysIceRjm6qkhCN0RgcQ");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing4", new HashMap(){{put("value", auctionOfferNoticeMsg.getItemName().substring(0,20));}});
paramMap.put("amount6", new HashMap(){{put("value", auctionOfferNoticeMsg.getCurrentPrice());}});
paramMap.put("character_string5", new HashMap(){{put("value", auctionOfferNoticeMsg.getDistributionOrderId());}});
paramMap.put("time3", new HashMap(){{put("value", DateUtils.toString(auctionOfferNoticeMsg.getPayEndTime()));}});
map.put("data", paramMap);
logger.info("============ 竞拍成功通知模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送竞拍成功模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送竞拍成功模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送竞拍成功模板消息 成功 ===========");
return Result.success();
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing4", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName().substring(0, 20));
}});
paramMap.put("amount6", new HashMap() {{
put("value", auctionOfferNoticeMsg.getCurrentPrice());
}});
paramMap.put("character_string5", new HashMap() {{
put("value", auctionOfferNoticeMsg.getDistributionOrderId());
}});
paramMap.put("time3", new HashMap() {{
put("value", DateUtils.toString(auctionOfferNoticeMsg.getPayEndTime()));
}});
map.put("data", paramMap);
logger.info("============ 竞拍成功通知模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送竞拍成功模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送竞拍成功模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送竞拍成功模板消息 成功 ===========");
return Result.success();
} catch (Exception e) {
e.printStackTrace();
}
return Result.failed();
}
@Override
public Result prePayMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
return null;
try {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "WJkhzyY0_7AYqh19_ujK93ISwKU1oniEgKKakYOdhfs");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing2", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName().substring(0, 20));
}});
paramMap.put("thing3", new HashMap() {{
put("value", "请及时付款");
}});
String content = "付款截止时间" + DateUtils.toString(auctionOfferNoticeMsg.getPayEndTime());
paramMap.put("time4", new HashMap() {{
put("value", content);
}});
map.put("data", paramMap);
logger.info("============ 中拍通知付款模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送中拍通知付款模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送中拍通知付款模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送中拍通知付款模板消息 成功 ===========");
return Result.success();
} catch (Exception e) {
e.printStackTrace();
}
return Result.failed();
}
@Override
public Result auctionSuccessForDistributorMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
return null;
try {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "WJkhzyY0_7AYqh19_ujK93ISwKU1oniEgKKakYOdhfs");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing2", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName().substring(0, 20));
}});
paramMap.put("thing3", new HashMap() {{
put("value", "请及时付款");
}});
String content = "付款截止时间" + DateUtils.toString(auctionOfferNoticeMsg.getPayEndTime());
paramMap.put("time4", new HashMap() {{
put("value", content);
}});
map.put("data", paramMap);
logger.info("============ 通知分销商竞拍成功模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送通知分销商竞拍成功模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送通知分销商竞拍成功模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送通知分销商竞拍成功模板消息 成功 ===========");
return Result.success();
} catch (Exception e) {
e.printStackTrace();
}
return Result.failed();
}
@Override
......
......@@ -429,6 +429,12 @@ public class SupplierItemServiceImpl implements SupplierItemService {
}
}
} else {
if (lastedRecord != null) {
if (lastedRecord.getUserId().longValue() == dto.getUserId().longValue()) {
auctionDetailVo.setUserState(DistributionEnum.AuctionUserStateEnum.LEAD.getCode());
auctionDetailVo.setUserStateName(DistributionEnum.AuctionUserStateEnum.LEAD.getDes());
}
}
auctionDetailVo.setState(DistributionEnum.AuctionStateEnum.IN_AUCTION.getCode());
auctionDetailVo.setStateName(DistributionEnum.AuctionStateEnum.IN_AUCTION.getDes());
}
......
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