Commit 8ddbd0a4 authored by shiyu's avatar shiyu

恢复用户交换商品库存

parent 5bb3faca
......@@ -4,8 +4,10 @@ import com.github.pagehelper.PageInfo;
import com.wwdz.ch.admin.service.SysSupplierItemService;
import com.wwdz.ch.core.api.WxAppletApi;
import com.wwdz.ch.core.consts.*;
import com.wwdz.ch.core.entity.ExchangeNoticeMsg;
import com.wwdz.ch.core.entity.SupplierItemVo;
import com.wwdz.ch.core.notify.AliSmsSender;
import com.wwdz.ch.core.service.SendMsgService;
import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.PageSearchResult;
import com.wwdz.ch.core.type.Result;
......@@ -89,6 +91,8 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
@Autowired
GroupPurchaseConfigDao groupPurchaseConfigDao;
@Autowired
SendMsgService sendMsgService;
@Override
@Transactional
......@@ -475,6 +479,17 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
supplierItem.setId(dto.getId());
supplierItem.setOfficialEstimatedPrice(PriceUtil.convertPriceFromStr(dto.getOfficialEstimatedPrice()));
supplierItemDao.update(supplierItem);
//发送模板消息,通知用户估价完成
String buyerOpenId = sendMsgService.getOpenIdByUserId(supplierItem.getCreatorId());
if (com.xxdxxs.utils.StringUtils.hasLength(buyerOpenId)) {
ExchangeNoticeMsg exchangeNoticeMsg = new ExchangeNoticeMsg();
exchangeNoticeMsg.setItemId(supplierItem.getId());
exchangeNoticeMsg.setItemName(supplierItem.getName());
exchangeNoticeMsg.setOfficialEstimatedPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getOfficialEstimatedPrice()));
sendMsgService.sendOfficialEstimatedPriceMsg(exchangeNoticeMsg);
} else {
logger.info(">>>>> 买家openid为空, 发送消息失败 <<<<<");
}
return Result.success();
} catch (Exception e) {
logger.error("编辑官方预估价失败 error : {}", e);
......
package com.wwdz.ch.core.entity;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class ExchangeNoticeMsg implements Entity {
private String openId;
private String templetId;
private Long itemId;
private String itemName;
private Long userId;
private String officialEstimatedPrice;
}
......@@ -973,4 +973,49 @@ public class SendMsgServiceImpl implements SendMsgService {
}
return Result.failed();
}
@Override
public Result sendOfficialEstimatedPriceMsg(ExchangeNoticeMsg exchangeNoticeMsg) {
try {
String openId = exchangeNoticeMsg.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", "P07Jrru56-e2JmWplinEcAFoWTUecmN3RDQp4A_VUDk");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer("/pages/detail/index");
stringBuffer.append("?itemId=" + exchangeNoticeMsg.getItemId());
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing1", new HashMap() {{
put("value", exchangeNoticeMsg.getItemName() + "-官方预估价");
}});
paramMap.put("amount2", new HashMap() {{
put("value", exchangeNoticeMsg.getOfficialEstimatedPrice()+ "元");
}});
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) {
logger.error("发送官方估计完成通知模板消息 error :{}", e);
}
return Result.failed();
}
}
......@@ -119,4 +119,12 @@ public interface SendMsgService {
* @return
*/
Result sendGroupPurchaseRateMsg(GroupPurchaseNoticeMsg groupPurchaseNoticeMsg);
/**
* 平台估价之后通知用户
* @param exchangeNoticeMsg
* @return
*/
Result sendOfficialEstimatedPriceMsg(ExchangeNoticeMsg exchangeNoticeMsg);
}
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