修改点歌逻辑
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,24 +25,23 @@ public interface TbShopSongService {
|
||||
*/
|
||||
PageInfo<?> all(Integer shopId, Integer page, Integer size, String keyWord, boolean isDesc);
|
||||
|
||||
Object getRecord(Integer userId, Integer page, Integer size, Integer state, boolean isDesc);
|
||||
Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc);
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param songOrderDTO 订单信息
|
||||
* @param openId
|
||||
* @return 支付信息
|
||||
*/
|
||||
JsonNode createOrder(Integer userId, SongOrderDTO songOrderDTO, String openId);
|
||||
JsonNode createOrder(SongOrderDTO songOrderDTO, String openId);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param openId 用户id
|
||||
* @param id 订单id
|
||||
* @return 订单信息
|
||||
*/
|
||||
Map<String, Object> getDetail(Integer userId, Integer id);
|
||||
Map<String, Object> getDetail(String openId, Integer id);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,14 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopSong;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopSongMapper;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.PayUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -47,14 +50,16 @@ public class TbShopSongServiceImpl implements TbShopSongService{
|
||||
private final PayUtils payUtils;
|
||||
|
||||
private final TbShopSongMapper shopSongMapper;
|
||||
private final PayService payService;
|
||||
|
||||
public TbShopSongServiceImpl(RedisTemplate<String, Object> redisTemplate, @Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, TbShopSongOrderMapper shopSongOrderMapper, TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper, PayUtils payUtils, TbShopSongMapper shopSongMapper) {
|
||||
public TbShopSongServiceImpl(RedisTemplate<String, Object> redisTemplate, @Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, TbShopSongOrderMapper shopSongOrderMapper, TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper, PayUtils payUtils, TbShopSongMapper shopSongMapper, PayService payService) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.shopSongOrderService = shopSongOrderService;
|
||||
this.shopSongOrderMapper = shopSongOrderMapper;
|
||||
this.tbMerchantThirdApplyMapper = tbMerchantThirdApplyMapper;
|
||||
this.payUtils = payUtils;
|
||||
this.shopSongMapper = shopSongMapper;
|
||||
this.payService = payService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,9 +70,9 @@ public class TbShopSongServiceImpl implements TbShopSongService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRecord(Integer userId, Integer page, Integer size, Integer state, boolean isDesc) {
|
||||
public Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc) {
|
||||
PageHelper.startPage(page, size);
|
||||
List<Map<String, Object>> songOrders = shopSongOrderMapper.selectByUserId(userId, state);
|
||||
List<Map<String, Object>> songOrders = shopSongOrderMapper.selectByUserId(openId, state);
|
||||
|
||||
ArrayList<Map<String, Object>> infos = new ArrayList<>();
|
||||
for (int i = 0; i < songOrders.size(); i++) {
|
||||
@@ -80,14 +85,14 @@ public class TbShopSongServiceImpl implements TbShopSongService{
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public JsonNode createOrder(Integer userId, SongOrderDTO songOrderDTO, String openId) {
|
||||
public JsonNode createOrder(SongOrderDTO songOrderDTO, String openId) {
|
||||
TbShopSong song = shopSongMapper.selectById(songOrderDTO.getSongId());
|
||||
if (song == null) {
|
||||
throw new MsgException("歌曲不存在, 歌曲id: {}", songOrderDTO.getSongId());
|
||||
}
|
||||
String orderNo = "WX" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmssSSS")+ RandomUtil.randomInt(1000, 9999);
|
||||
String orderNo = "SONG" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmssSSS")+ RandomUtil.randomInt(1000, 9999);
|
||||
TbShopSongOrder shopSongOrder = new TbShopSongOrder();
|
||||
shopSongOrder.setUserId(userId);
|
||||
shopSongOrder.setOpenId(openId);
|
||||
shopSongOrder.setOrderNo(orderNo);
|
||||
shopSongOrder.setCreateTime(DateUtil.date());
|
||||
shopSongOrder.setSongId(song.getId());
|
||||
@@ -97,7 +102,8 @@ public class TbShopSongServiceImpl implements TbShopSongService{
|
||||
shopSongOrder.setFromName(shopSongOrder.getFromName());
|
||||
shopSongOrder.setToName(shopSongOrder.getToName());
|
||||
shopSongOrder.setNote(songOrderDTO.getNote());
|
||||
shopSongOrder.setShopId(shopSongOrder.getShopId());
|
||||
shopSongOrder.setShopId(songOrderDTO.getShopId());
|
||||
shopSongOrder.setPayMoney(song.getPrice());
|
||||
shopSongOrderMapper.insert(shopSongOrder);
|
||||
|
||||
TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyMapper.selectByShopId(songOrderDTO.getShopId());
|
||||
@@ -105,13 +111,18 @@ public class TbShopSongServiceImpl implements TbShopSongService{
|
||||
throw new MsgException("三方支付参数不存在");
|
||||
}
|
||||
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
|
||||
return payUtils.getWxPay(IpUtil.getIpAddr(attr.getRequest()), orderNo, userId, "", songOrderDTO.getShopId(), song.getPrice(),tbMerchantThirdApply.getId(),
|
||||
openId, tbMerchantThirdApply);
|
||||
|
||||
try {
|
||||
Result result = payService.paySongOrder(openId, String.valueOf(shopSongOrder.getShopId()), shopSongOrder.getId(), IpUtil.getIpAddr(attr.getRequest()), tbMerchantThirdApply);
|
||||
return (JsonNode) result.getData();
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDetail(Integer userId, Integer id) {
|
||||
Map<String, Object> map = shopSongOrderMapper.selectByUserIdAndId(userId, id);
|
||||
public Map<String, Object> getDetail(String openId, Integer id) {
|
||||
Map<String, Object> map = shopSongOrderMapper.selectByUserIdAndId(openId, id);
|
||||
if (map == null) {
|
||||
throw new MsgException("订单不存在");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user