微信小程序点歌接口
This commit is contained in:
@@ -4,6 +4,7 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant;
|
||||
import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
@@ -24,7 +25,6 @@ public class NotifyController {
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
PayService payService;
|
||||
|
||||
@@ -55,9 +55,15 @@ public class NotifyController {
|
||||
JSONObject object=JSONUtil.parseObj(map.get("bizData").toString());
|
||||
if(ObjectUtil.isNotEmpty(object)&&object.containsKey("state")){
|
||||
if("TRADE_SUCCESS".equals(object.get("state").toString())){
|
||||
JSONObject extParam = object.getJSONObject("extParam");
|
||||
String orderNo=object.get("mchOrderNo").toString();
|
||||
String tradeNo=object.get("payOrderId").toString();
|
||||
return payService.fstMemberInSuccess(orderNo,tradeNo);
|
||||
if (PayTypeConstant.MINI_PAY.equals(extParam.getStr("payType"))) {
|
||||
log.info("接收到微信点歌支付成功回调,订单编号:{}", orderNo);
|
||||
return payService.songPaySuccess(orderNo, extParam.getStr("orderNo"));
|
||||
}else {
|
||||
String tradeNo=object.get("payOrderId").toString();
|
||||
return payService.fstMemberInSuccess(orderNo,tradeNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +84,11 @@ public class NotifyController {
|
||||
log.info("回调返回信息:{}",JSONUtil.toJsonStr(map));
|
||||
if(ObjectUtil.isNotEmpty(map)&&map.containsKey("code")&&"200".equals(map.get("code")+"")){
|
||||
JSONObject object=JSONUtil.parseObj(map.get("data"));
|
||||
if(ObjectUtil.isNotEmpty(object)&&object.containsKey("status")&&"1".equals(object.getStr("status"))){
|
||||
if(ObjectUtil.isNotEmpty(object)
|
||||
&& object.containsKey("status")
|
||||
&& "1".equals(object.getStr("status"))
|
||||
&& !"0100".equals(object.getStr("payType"))
|
||||
){
|
||||
String orderNo=object.getStr("orderNumber");
|
||||
return payService.callBackPay(orderNo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@Slf4j
|
||||
@RequestMapping("/song")
|
||||
@RestController
|
||||
public class ShopSongController {
|
||||
|
||||
|
||||
private final TbShopSongService shopSongService;
|
||||
|
||||
public ShopSongController(@Qualifier("tbShopSongServiceImpl") TbShopSongService shopSongService) {
|
||||
this.shopSongService = shopSongService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有歌曲,支持搜索及分页
|
||||
* @param page 页数
|
||||
* @param size 数量
|
||||
* @param keyWord 搜索关键字
|
||||
* @return data
|
||||
*/
|
||||
@GetMapping
|
||||
public Result all(
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String keyWord,
|
||||
@RequestParam Integer shopId,
|
||||
@RequestParam(defaultValue = "true") boolean isDesc
|
||||
) {
|
||||
return Result.successWithData(shopSongService.all(shopId, page, size, keyWord, isDesc));
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
public Result getRecord(
|
||||
@RequestParam Integer id
|
||||
) {
|
||||
return Result.successWithData(shopSongService.getDetail(TokenUtil.getUserId(), id));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/record")
|
||||
public Result getRecord(
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) Integer state,
|
||||
@RequestParam(defaultValue = "true") boolean isDesc
|
||||
) {
|
||||
return Result.successWithData(shopSongService.getRecord(TokenUtil.getUserId(), page, size, state, isDesc));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public Result createOrder(
|
||||
@RequestHeader("openId") String openId,
|
||||
@RequestBody SongOrderDTO songOrderDTO
|
||||
) {
|
||||
return Result.successWithData(shopSongService.createOrder(TokenUtil.getUserId(), songOrderDTO, openId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user