Commit c4665ea2 authored by shiyu's avatar shiyu

bug修复

parent 183c8cd4
...@@ -90,6 +90,9 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService { ...@@ -90,6 +90,9 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
supplierItem.setUpdateTime(now); supplierItem.setUpdateTime(now);
supplierItem.setIsOnSale(true); supplierItem.setIsOnSale(true);
supplierItem.setIsDeleted(false); supplierItem.setIsDeleted(false);
if (dto.getStock() == null) {
supplierItem.setStock(1);
}
//平台上传商品使用系统默认账号 //平台上传商品使用系统默认账号
supplierItem.setCreatorId(CommConsts.SYSTEM_ACCOUNT); supplierItem.setCreatorId(CommConsts.SYSTEM_ACCOUNT);
long itemId = supplierItemDao.insert(supplierItem); long itemId = supplierItemDao.insert(supplierItem);
......
...@@ -26,6 +26,8 @@ public class OfficialAccountApi { ...@@ -26,6 +26,8 @@ public class OfficialAccountApi {
private final static String SEND_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send"; private final static String SEND_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send";
/** /**
* 测试环境和正式环境的url不同,相互隔离不会冲突 * 测试环境和正式环境的url不同,相互隔离不会冲突
*/ */
...@@ -173,4 +175,6 @@ public class OfficialAccountApi { ...@@ -173,4 +175,6 @@ public class OfficialAccountApi {
} }
} }
...@@ -25,7 +25,11 @@ public interface CollectionBookDao { ...@@ -25,7 +25,11 @@ public interface CollectionBookDao {
List<CollectionBook> findByUserId(long userId); List<CollectionBook> findByUserId(long userId);
long countByUserId(long userId);
int delete(long id); int delete(long id);
boolean isExisted(long userId, String name);
} }
...@@ -46,6 +46,16 @@ public class CollectionBookDaoImpl implements CollectionBookDao { ...@@ -46,6 +46,16 @@ public class CollectionBookDaoImpl implements CollectionBookDao {
return collectionBookMapper.selectByExample(example); return collectionBookMapper.selectByExample(example);
} }
@Override
public long countByUserId(long userId) {
CollectionBookExample example = new CollectionBookExample();
CollectionBookExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andIsDeletedEqualTo(false);
return collectionBookMapper.countByExample(example);
}
@Override @Override
public int delete(long id) { public int delete(long id) {
CollectionBook collectionBook = new CollectionBook(); CollectionBook collectionBook = new CollectionBook();
...@@ -54,4 +64,15 @@ public class CollectionBookDaoImpl implements CollectionBookDao { ...@@ -54,4 +64,15 @@ public class CollectionBookDaoImpl implements CollectionBookDao {
collectionBook.setId(id); collectionBook.setId(id);
return collectionBookMapper.updateByPrimaryKeySelective(collectionBook); return collectionBookMapper.updateByPrimaryKeySelective(collectionBook);
} }
@Override
public boolean isExisted(long userId, String name) {
CollectionBookExample example = new CollectionBookExample();
CollectionBookExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andTitleEqualTo(name);
criteria.andIsDeletedEqualTo(false);
return collectionBookMapper.countByExample(example) > 0;
}
} }
...@@ -61,6 +61,16 @@ public class AuctionOfferNoticeMsg implements Entity { ...@@ -61,6 +61,16 @@ public class AuctionOfferNoticeMsg implements Entity {
*/ */
private String profit; private String profit;
/**
* 创建时间
*/
private Date createTime;
/**
* 消息内容
*/
private String content;
} }
......
...@@ -30,6 +30,14 @@ public class CollectionBookServiceImpl implements CollectionBookService { ...@@ -30,6 +30,14 @@ public class CollectionBookServiceImpl implements CollectionBookService {
@Override @Override
public Result create(CollectionBookRequestDto dto) { public Result create(CollectionBookRequestDto dto) {
try { try {
long countNum = collectionBookDao.countByUserId(dto.getUserId());
if (countNum >= 15) {
return Result.failed("标签数量已达上限");
}
if (collectionBookDao.isExisted(dto.getUserId(), dto.getTitle())) {
return Result.failed("标签名称已存在");
}
CollectionBook collectionBook = new CollectionBook(); CollectionBook collectionBook = new CollectionBook();
EntityMapper.copyAttribute(dto, collectionBook); EntityMapper.copyAttribute(dto, collectionBook);
collectionBook.setSort(1); collectionBook.setSort(1);
......
package com.wwdz.ch.wx.impl.distribution; package com.wwdz.ch.wx.impl.distribution;
import com.wwdz.ch.core.api.OfficialAccountApi; import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.OkHttpUtil; import com.wwdz.ch.core.util.OkHttpUtil;
import com.wwdz.ch.db.dao.OfficialAccountSubscribeRecordDao; import com.wwdz.ch.db.dao.OfficialAccountSubscribeRecordDao;
...@@ -37,6 +38,11 @@ public class SendMsgServiceImpl implements SendMsgService { ...@@ -37,6 +38,11 @@ public class SendMsgServiceImpl implements SendMsgService {
private final static String SEND_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send"; private final static String SEND_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send";
/**
* 发送订阅消息url
*/
private final static String SEND_SUBSCRIBE_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
@Value("${dts.wx.pay-templetId}") @Value("${dts.wx.pay-templetId}")
private String PAY_TEMPLETID; private String PAY_TEMPLETID;
...@@ -548,4 +554,109 @@ public class SendMsgServiceImpl implements SendMsgService { ...@@ -548,4 +554,109 @@ public class SendMsgServiceImpl implements SendMsgService {
String openId = officialAccountSubscribeRecord.getOpenid(); String openId = officialAccountSubscribeRecord.getOpenid();
return openId; return openId;
} }
/**
* 商品上新通知
* @param auctionOfferNoticeMsg
* @return
*/
public boolean sendNewItemMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_SUBSCRIBE_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", "qazuHdQTudkRd-UIYb58nEW0Zw4_ZCVIYmi_muR9cgc");
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("thing1", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName());
}});
paramMap.put("time4", new HashMap() {{
put("value", auctionOfferNoticeMsg.getCreateTime());
}});
paramMap.put("thing5", new HashMap() {{
put("value", auctionOfferNoticeMsg.getContent());
}});
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 false;
}
logger.info("============= 发送商品上新通知成功 ===========");
return true;
}
/**
* 竞拍开始通知
* @param auctionOfferNoticeMsg
* @return
*/
public boolean sendAuctionStartMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_SUBSCRIBE_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", "RjUUMuLyyW1g6ULUr9HWO8oEKoE-Vd_3s3p0XRI7tS0");
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("thing1", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName());
}});
paramMap.put("time2", new HashMap() {{
put("value", auctionOfferNoticeMsg.getCreateTime());
}});
paramMap.put("time3", new HashMap() {{
put("value", auctionOfferNoticeMsg.getContent());
}});
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 false;
}
logger.info("============= 发送竞拍开始通知成功 ===========");
return true;
}
} }
...@@ -118,15 +118,29 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -118,15 +118,29 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setRebate(supplierItem.getRebate().toPlainString() + "%"); supplierItemVo.setRebate(supplierItem.getRebate().toPlainString() + "%");
//竞拍商品需要展示当前价 //竞拍商品需要展示当前价
if (supplierItem.getType() == DistributionEnum.DistributionTypeEnum.AUCTION.getCode()) { if (supplierItem.getType() == DistributionEnum.DistributionTypeEnum.AUCTION.getCode()) {
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(supplierItem.getId()); Date now = new Date();
if (auctionRecord != null && auctionRecord.getPrice() != null) { AuctionRecord lastedRecord = auctionRecordDao.findLastedRecord(supplierItem.getId());
supplierItemVo.setCurrentPrice(PriceUtil.convertPriceFenToYuan(auctionRecord.getPrice())); if (lastedRecord != null && lastedRecord.getPrice() != null) {
supplierItemVo.setCurrentPrice(PriceUtil.convertPriceFenToYuan(lastedRecord.getPrice()));
} else { } else {
//没有出价记录最新价格为0
supplierItemVo.setCurrentPrice("0"); supplierItemVo.setCurrentPrice("0");
} }
AuctionConfig auctionConfig = auctionConfigDao.findByItemId(supplierItem.getId()); AuctionConfig auctionConfig = auctionConfigDao.findByItemId(supplierItem.getId());
supplierItemVo.setRealEndTime(auctionConfig.getRealEndTime()); supplierItemVo.setRealEndTime(auctionConfig.getRealEndTime());
if (now.before(auctionConfig.getStartTime())) {
supplierItemVo.setState(DistributionEnum.AuctionStateEnum.NOT_START.getCode());
supplierItemVo.setStateName(DistributionEnum.AuctionStateEnum.NOT_START.getDes());
} else if (now.after(auctionConfig.getRealEndTime())) {
supplierItemVo.setState(DistributionEnum.AuctionStateEnum.END.getCode());
supplierItemVo.setStateName(DistributionEnum.AuctionStateEnum.END.getDes());
//如果当前时间已经超过截拍时间,并且竞拍配置还未改成无效,则进行修改
if (auctionConfig.getIsValid()) {
auctionConfigDao.setEnd(supplierItem.getId());
}
} else {
supplierItemVo.setState(DistributionEnum.AuctionStateEnum.IN_AUCTION.getCode());
supplierItemVo.setStateName(DistributionEnum.AuctionStateEnum.IN_AUCTION.getDes());
}
} }
supplierItemVos.add(supplierItemVo); supplierItemVos.add(supplierItemVo);
}); });
...@@ -728,7 +742,7 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -728,7 +742,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
//查询用户的历史浏览记录 //查询用户的历史浏览记录
List<UserRecentBrowse> userRecentBrowseList = userRecentBrowseDao.findByUserId(userId); List<UserRecentBrowse> userRecentBrowseList = userRecentBrowseDao.findByUserId(userId);
//浏览记录是平台商品的 //浏览记录是平台商品的
List<Long> sharedUserIdList = userRecentBrowseList.stream().filter(a -> a.getType() == DistributionEnum.UserBrowseTypeEnum.PLATFORM_ITEM.getCode()).map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList()); List<Long> sharedUserIdList = userRecentBrowseList.stream().map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(sharedUserIdList)) { if (CollectionUtils.isEmpty(sharedUserIdList)) {
sharedUserIdList.add(sellerId); sharedUserIdList.add(sellerId);
} }
......
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