Merge remote-tracking branch 'origin/dev' into hph

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java
This commit is contained in:
韩鹏辉 2024-07-10 15:11:00 +08:00
commit 8ce62ee06c
23 changed files with 1293 additions and 73 deletions

View File

@ -1,64 +0,0 @@
//package com.chaozhanggui.system.cashierservice.controller;
//
//import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
//import com.chaozhanggui.system.cashierservice.entity.dto.ProductCartDto;
//import com.chaozhanggui.system.cashierservice.service.CashierCartService;
//import com.chaozhanggui.system.cashierservice.sign.Result;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * @author lyf
// */
//@CrossOrigin(origins = "*")
//@RestController
//@Slf4j
//@RequestMapping("/cart")
//public class CashierCartController {
//
// @Resource
// private CashierCartService cashierCartService;
// /**
// * 添加购物车
// * @param productCartDto
// * @return
// */
// @PostMapping("/add")
// public Result batchAdd(@RequestBody ProductCartDto productCartDto) {
// return cashierCartService.batchAdd(productCartDto);
// }
//
// /**
// * 购物车
// * @param tableId
// * @return
// */
// @GetMapping("/cartList")
// public Result cartList(@RequestParam Integer tableId){
// return cashierCartService.cartList(tableId);
// }
//
// /**
// *更改数量
// * @param
// * @return
// */
// @GetMapping("/updateNumber")
// public Result updateNumber(@RequestParam Integer id ,@RequestParam String type){
// return cashierCartService.updateNumber(id,type);
// }
//
//
// /**
// *清空购物车
// * @param
// * @return
// */
// @GetMapping("/clear")
// public Result clearCart(@RequestParam Integer tableId){
// return cashierCartService.clearCart(tableId);
// }
//}

View File

@ -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;
@ -50,15 +50,19 @@ public class NotifyController {
Map<String, Object> map= getParameterMap(request);
log.info("fstmemberInCallBack回调返回信息:{}",JSONUtil.toJsonStr(map));
if(ObjectUtil.isNotEmpty(map)&&map.containsKey("code")&&"000000".equals(map.get("code")+"")){
// Map<String,Object> object=(Map)map.get("bizData");
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();
try {
if (ObjectUtil.isNotEmpty(extParam)&&ObjectUtil.isNotNull(extParam)&&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);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -80,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);
}

View File

@ -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));
}
}

View File

@ -1,7 +1,10 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
@Component
@ -20,4 +23,8 @@ public interface TbMerchantThirdApplyMapper {
int updateByPrimaryKeyWithBLOBs(TbMerchantThirdApply record);
int updateByPrimaryKey(TbMerchantThirdApply record);
}
@Select("select a.* from tb_merchant_third_apply as a left join tb_merchant_account as b on a.id=b.id where b.shop_id=#{shopId}")
TbMerchantThirdApply selectByShopId(@Param("shopId") Integer shopId);
}

View File

@ -0,0 +1,39 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopSong;
import com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* @author Administrator
* @description 针对表tb_shop_song的数据库操作Mapper
* @createDate 2024-07-09 11:52:30
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopSong
*/
public interface TbShopSongMapper {
int deleteByPrimaryKey(Long id);
int insert(TbShopSong record);
int insertSelective(TbShopSong record);
TbShopSong selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbShopSong record);
int updateByPrimaryKey(TbShopSong record);
List<TbShopSong> selectAllAndSearch(Integer shopId, String keyWord);
@Select("select * from fycashier.tb_shop_song where id=#{songId} and status=1")
TbShopSong selectById(@Param("songId") Integer songId);
@Update("update fycashier.tb_shop_song set sales_number=sales_number+#{num} where id=#{id}")
int incrNum(@Param("num") Integer num,@Param("id") Integer id);
}

View File

@ -0,0 +1,50 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_song_order的数据库操作Mapper
* @createDate 2024-07-09 15:23:30
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder
*/
public interface TbShopSongOrderMapper {
int deleteByPrimaryKey(Long id);
int insert(TbShopSongOrder record);
int insertSelective(TbShopSongOrder record);
TbShopSongOrder selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbShopSongOrder record);
int updateByPrimaryKey(TbShopSongOrder record);
@Select("<script>SELECT\n" +
" b.img, b.name, b.origin_singer originSinger, b.price, a.from_name fromName, a.to_name toName, a.note\n" +
" FROM\n" +
" tb_shop_song_order AS a\n" +
" LEFT JOIN tb_shop_song AS b ON a.song_id = b.id\n" +
" WHERE\n" +
" a.user_id = #{userId}\n" +
" <if test=\"state!=null\">AND a.state = #{state}</if></script>")
List<Map<String, Object>> selectByUserId(@Param("userId") Integer userId, @Param("state") Integer state);
Map<String, Object> selectByUserIdAndId(@Param("userId") Integer userId, @Param("id") Integer id);
@Select("select * from fycashier.tb_shop_song_order where order_no=#{orderNo};")
TbShopSongOrder selectByOrderNo(@Param("orderNo") String orderNo);
@Delete("DELETE FROM tb_shop_song_order\n" +
"WHERE create_time < NOW() - INTERVAL 10 MINUTE AND state=-1;\n")
int deleteExpireOrder();
}

View File

@ -0,0 +1,5 @@
package com.chaozhanggui.system.cashierservice.entity.Enum;
public interface PayTypeConstant {
String MINI_PAY="MiniAppSongPay";
}

View File

@ -0,0 +1,151 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName tb_shop_song
*/
@Data
public class TbShopSong implements Serializable {
/**
*
*/
private Integer id;
/**
* 店铺id
*/
private Integer shopId;
/**
* 歌曲图片
*/
private String img;
/**
* 歌曲名称
*/
private String name;
/**
* 原唱歌手
*/
private String originSinger;
/**
* 演出歌手id
*/
private Integer singerId;
/**
* 演出歌手名称
*/
private String singer;
/**
* 单价
*/
private BigDecimal price;
/**
* 点播次数
*/
private Integer salesNumber;
/**
* 歌曲状态1-开启0-关闭
*/
private Integer status;
/**
*
*/
private Integer sort;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbShopSong other = (TbShopSong) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getImg() == null ? other.getImg() == null : this.getImg().equals(other.getImg()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getOriginSinger() == null ? other.getOriginSinger() == null : this.getOriginSinger().equals(other.getOriginSinger()))
&& (this.getSingerId() == null ? other.getSingerId() == null : this.getSingerId().equals(other.getSingerId()))
&& (this.getSinger() == null ? other.getSinger() == null : this.getSinger().equals(other.getSinger()))
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
&& (this.getSalesNumber() == null ? other.getSalesNumber() == null : this.getSalesNumber().equals(other.getSalesNumber()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getImg() == null) ? 0 : getImg().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getOriginSinger() == null) ? 0 : getOriginSinger().hashCode());
result = prime * result + ((getSingerId() == null) ? 0 : getSingerId().hashCode());
result = prime * result + ((getSinger() == null) ? 0 : getSinger().hashCode());
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
result = prime * result + ((getSalesNumber() == null) ? 0 : getSalesNumber().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", shopId=").append(shopId);
sb.append(", img=").append(img);
sb.append(", name=").append(name);
sb.append(", originSinger=").append(originSinger);
sb.append(", singerId=").append(singerId);
sb.append(", singer=").append(singer);
sb.append(", price=").append(price);
sb.append(", salesNumber=").append(salesNumber);
sb.append(", status=").append(status);
sb.append(", sort=").append(sort);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,159 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName tb_shop_song_order
*/
@Data
public class TbShopSongOrder implements Serializable {
/**
*
*/
private Integer id;
/**
* 歌曲id
*/
private Integer songId;
/**
* 歌曲名称
*/
private String songName;
/**
* 用户id
*/
private Integer userId;
/**
* 支付金额
*/
private BigDecimal payMoney;
/**
* 状态 -1 未支付 0 已取消 1 已支付 2 演唱中 3 已演唱
*/
private Integer state;
/**
* 创建时间
*/
private Date createTime;
/**
* 下单来源
*/
private Integer clientType;
/**
* 订单编号
*/
private String orderNo;
/**
* 点歌人
*/
private String fromName;
/**
* 收歌人
*/
private String toName;
/**
* 祝福语
*/
private String note;
/**
* 店铺id
*/
private Integer shopId;
/**
* 歌曲实际价格
*/
private BigDecimal realMoney;
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbShopSongOrder other = (TbShopSongOrder) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getSongId() == null ? other.getSongId() == null : this.getSongId().equals(other.getSongId()))
&& (this.getSongName() == null ? other.getSongName() == null : this.getSongName().equals(other.getSongName()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getPayMoney() == null ? other.getPayMoney() == null : this.getPayMoney().equals(other.getPayMoney()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getClientType() == null ? other.getClientType() == null : this.getClientType().equals(other.getClientType()))
&& (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo()))
&& (this.getFromName() == null ? other.getFromName() == null : this.getFromName().equals(other.getFromName()))
&& (this.getToName() == null ? other.getToName() == null : this.getToName().equals(other.getToName()))
&& (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getRealMoney() == null ? other.getRealMoney() == null : this.getRealMoney().equals(other.getRealMoney()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getSongId() == null) ? 0 : getSongId().hashCode());
result = prime * result + ((getSongName() == null) ? 0 : getSongName().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getPayMoney() == null) ? 0 : getPayMoney().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getClientType() == null) ? 0 : getClientType().hashCode());
result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode());
result = prime * result + ((getFromName() == null) ? 0 : getFromName().hashCode());
result = prime * result + ((getToName() == null) ? 0 : getToName().hashCode());
result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getRealMoney() == null) ? 0 : getRealMoney().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", songId=").append(songId);
sb.append(", songName=").append(songName);
sb.append(", userId=").append(userId);
sb.append(", payMoney=").append(payMoney);
sb.append(", state=").append(state);
sb.append(", createTime=").append(createTime);
sb.append(", clientType=").append(clientType);
sb.append(", orderNo=").append(orderNo);
sb.append(", fromName=").append(fromName);
sb.append(", toName=").append(toName);
sb.append(", note=").append(note);
sb.append(", shopId=").append(shopId);
sb.append(", realMoney=").append(realMoney);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,12 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
@Data
public class SongOrderDTO {
private Integer songId;
private String fromName;
private String toName;
private String note;
private Integer shopId;
}

View File

@ -29,6 +29,7 @@ import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -141,6 +142,12 @@ public class PayService {
@Autowired
TbActivateMapper tbActivateMapper;
private final TbShopSongOrderService shopSongOrderService;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
this.shopSongOrderService = shopSongOrderService;
}
@Transactional(rollbackFor = Exception.class)
public Result payOrder(String openId,String orderId,String ip) throws Exception {
@ -257,7 +264,8 @@ public class PayService {
reqbody=body.toString();
}
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),reqbody,reqbody,payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),openId,ip,DateUtils.getsdfTimesSS(),thirdApply.getStoreId(),callFSTBack,null,thirdApply.getAppToken());
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),
reqbody,reqbody,payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),openId,ip,DateUtils.getsdfTimesSS(),thirdApply.getStoreId(),callFSTBack,null,thirdApply.getAppToken());
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
if("000000".equals(publicResp.getCode())){
WxScanPayResp wxScanPayResp= publicResp.getObjData();
@ -822,7 +830,9 @@ public class PayService {
}
}else {
String orderNo=DateUtils.getsdfTimesSS();
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),"会员充值","会员充值",new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),openId,ip, orderNo,thirdApply.getStoreId(),callInBack,null,thirdApply.getAppToken());
PublicResp<WxScanPayResp> publicResp= thirdPayService
.scanpay(thirdUrl,thirdApply.getAppId(),
"会员充值","会员充值",new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),openId,ip, orderNo,thirdApply.getStoreId(),callInBack,null,thirdApply.getAppToken());
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
if("000000".equals(publicResp.getCode())){
WxScanPayResp wxScanPayResp= publicResp.getObjData();
@ -1211,6 +1221,30 @@ public class PayService {
PushToClientChannelHandlerAdapter.getInstance().AppSendInfoV1(orderInfo.getShopId(),orderInfo.getOrderNo(), client);
}
/**
* 点歌支付成功
* @param mchOrderNo 商户订单编号
* @param orderNo
* @return
*/
public String songPaySuccess(String mchOrderNo, String orderNo) {
TbMemberIn memberIn= tbMemberInMapper.selectByOrderNo(mchOrderNo);
if(ObjectUtil.isEmpty(memberIn)){
return "充值记录不存在";
}
if(!"7".equals(memberIn.getStatus())){
return "订单已处理";
}
memberIn.setTradeNo(orderNo);
memberIn.setStatus("0");
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
shopSongOrderService.successPay(orderNo);
return "success";
}
// public Result returnOrder(){
//

View File

@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.service;
/**
* @author Administrator
* @description 针对表tb_shop_song_order的数据库操作Service
* @createDate 2024-07-06 17:54:20
*/
public interface TbShopSongOrderService {
void successPay(String orderNo);
void clearExpireOrder();
}

View File

@ -0,0 +1,48 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.pagehelper.PageInfo;
import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_song的数据库操作Service
* @createDate 2024-07-06 14:43:39
*/
public interface TbShopSongService {
/**
* 分页获取数据
*
* @param shopId 用户id
* @param page 页数
* @param size 数量
* @param keyWord 搜索关键字
* @param isDesc 是否降序
*/
PageInfo<?> all(Integer shopId, Integer page, Integer size, String keyWord, boolean isDesc);
Object getRecord(Integer userId, Integer page, Integer size, Integer state, boolean isDesc);
/**
* 创建订单
*
* @param userId 用户id
* @param songOrderDTO 订单信息
* @param openId
* @return 支付信息
*/
JsonNode createOrder(Integer userId, SongOrderDTO songOrderDTO, String openId);
/**
* 订单详情
*
* @param userId 用户id
* @param id 订单id
* @return 订单信息
*/
Map<String, Object> getDetail(Integer userId, Integer id);
}

View File

@ -0,0 +1,50 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.chaozhanggui.system.cashierservice.dao.TbShopSongMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder;
import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService;
import com.chaozhanggui.system.cashierservice.dao.TbShopSongOrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表tb_shop_song_order的数据库操作Service实现
* @createDate 2024-07-06 17:54:20
*/
@Service
@Slf4j
public class TbShopSongOrderServiceImpl
implements TbShopSongOrderService{
private final TbShopSongMapper shopSongMapper;
private final TbShopSongOrderMapper shopSongOrderMapper;
public TbShopSongOrderServiceImpl(TbShopSongMapper shopSongMapper, TbShopSongOrderMapper shopSongOrderMapper) {
this.shopSongMapper = shopSongMapper;
this.shopSongOrderMapper = shopSongOrderMapper;
}
@Override
public void successPay(String orderNo) {
TbShopSongOrder shopSongOrder = shopSongOrderMapper.selectByOrderNo(orderNo);
if (shopSongOrder.getState().equals(1)) {
log.warn("点歌支付成功,重复支付,订单编号:{}", orderNo);
return;
}
shopSongOrder.setState(1);
shopSongOrder.setRealMoney(shopSongOrder.getPayMoney());
shopSongOrderMapper.updateByPrimaryKeySelective(shopSongOrder);
shopSongMapper.incrNum(1, shopSongOrder.getSongId());
}
@Override
public void clearExpireOrder() {
int i = shopSongOrderMapper.deleteExpireOrder();
log.info("历史歌曲订单删除了{}条", i);
}
}

View File

@ -0,0 +1,124 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.chaozhanggui.system.cashierservice.dao.TbMerchantThirdApplyMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopSongOrderMapper;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply;
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.TbShopSongOrderService;
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
import com.chaozhanggui.system.cashierservice.dao.TbShopSongMapper;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.PayUtils;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_song的数据库操作Service实现
* @createDate 2024-07-06 14:43:39
*/
@Service
public class TbShopSongServiceImpl implements TbShopSongService{
private final RedisTemplate<String, Object> redisTemplate;
private final TbShopSongOrderService shopSongOrderService;
private final TbShopSongOrderMapper shopSongOrderMapper;
private final TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper;
private final PayUtils payUtils;
private final TbShopSongMapper shopSongMapper;
public TbShopSongServiceImpl(RedisTemplate<String, Object> redisTemplate, @Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, TbShopSongOrderMapper shopSongOrderMapper, TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper, PayUtils payUtils, TbShopSongMapper shopSongMapper) {
this.redisTemplate = redisTemplate;
this.shopSongOrderService = shopSongOrderService;
this.shopSongOrderMapper = shopSongOrderMapper;
this.tbMerchantThirdApplyMapper = tbMerchantThirdApplyMapper;
this.payUtils = payUtils;
this.shopSongMapper = shopSongMapper;
}
@Override
public PageInfo<TbShopSong> all(Integer shopId, Integer page, Integer size, String keyWord, boolean isDesc) {
PageHelper.startPage(page, size);
List<TbShopSong> shopSongs = shopSongMapper.selectAllAndSearch(shopId, keyWord);
return new PageInfo<>(shopSongs);
}
@Override
public Object getRecord(Integer userId, Integer page, Integer size, Integer state, boolean isDesc) {
PageHelper.startPage(page, size);
List<Map<String, Object>> songOrders = shopSongOrderMapper.selectByUserId(userId, state);
ArrayList<Map<String, Object>> infos = new ArrayList<>();
for (int i = 0; i < songOrders.size(); i++) {
Map<String, Object> toMap = songOrders.get(i);
toMap.put("preCount", i);
infos.add(toMap);
}
return new PageInfo<>(infos);
}
@Override
@Transactional
public JsonNode createOrder(Integer userId, 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);
TbShopSongOrder shopSongOrder = new TbShopSongOrder();
shopSongOrder.setUserId(userId);
shopSongOrder.setOrderNo(orderNo);
shopSongOrder.setCreateTime(DateUtil.date());
shopSongOrder.setSongId(song.getId());
shopSongOrder.setClientType(0);
shopSongOrder.setSongName(song.getName());
shopSongOrder.setState(-1);
shopSongOrder.setFromName(shopSongOrder.getFromName());
shopSongOrder.setToName(shopSongOrder.getToName());
shopSongOrder.setNote(songOrderDTO.getNote());
shopSongOrder.setShopId(shopSongOrder.getShopId());
shopSongOrderMapper.insert(shopSongOrder);
TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyMapper.selectByShopId(songOrderDTO.getShopId());
if (tbMerchantThirdApply == null) {
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);
}
@Override
public Map<String, Object> getDetail(Integer userId, Integer id) {
Map<String, Object> map = shopSongOrderMapper.selectByUserIdAndId(userId, id);
if (map == null) {
throw new MsgException("订单不存在");
}
return map;
}
}

View File

@ -33,6 +33,10 @@ public class Result {
*/
private String icon;
public static<T> Result successWithData(T data) {
return new Result(CodeEnum.SUCCESS, data);
}
public boolean isEncrypt() {
return encrypt;
}

View File

@ -2,11 +2,15 @@ package com.chaozhanggui.system.cashierservice.task;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.NicknameGenerator;
import com.chaozhanggui.system.cashierservice.util.RandomUtil;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -19,6 +23,7 @@ import java.util.concurrent.*;
@Component
public class TaskScheduler {
private static final Logger log = LoggerFactory.getLogger(TaskScheduler.class);
@Autowired
private TbWiningUserMapper tbWiningUserMapper;
@Autowired
@ -31,6 +36,13 @@ public class TaskScheduler {
private TbReleaseFlowMapper releaseFlowMapper;
@Autowired
private TbUserCouponsMapper userCouponsMapper;
private final TbShopSongOrderService shopSongOrderService;
public TaskScheduler(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
this.shopSongOrderService = shopSongOrderService;
}
//更新订单状态
// @Scheduled(fixedRate = 1000000)
public void orderStatus() throws InterruptedException {
@ -160,4 +172,10 @@ public class TaskScheduler {
long randomMilliseconds = ThreadLocalRandom.current().nextLong(startTimestamp, endTimestamp);
return randomMilliseconds;
}
@Scheduled(fixedRate = 60000)
public void clearSongOrder() {
log.info("定时任务执行,清楚过期歌曲订单");
shopSongOrderService.clearExpireOrder();
}
}

View File

@ -32,6 +32,8 @@ public class WxScanPayReq implements Serializable {
private String returnUrl;
private String extParam;
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
@ -46,4 +48,20 @@ public class WxScanPayReq implements Serializable {
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl, String extParam) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.subAppid = subAppid;
this.userId = userId;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
this.extParam = extParam;
}
}

View File

@ -100,6 +100,33 @@ public class ThirdPayService {
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
try {
String str = JSONUtil.toJSONString(sortFields(scanPayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(ltpay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<WxScanPayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),WxScanPayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public PublicResp<WxScanPayResp> scanpay(String url,String appId, String subject, String body, Long amount,String payType, String subAppId, String userId,
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
String key, String extParam){
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl, extParam);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
try {
String str = JSONUtil.toJSONString(sortFields(scanPayReq));
param.setBizData(str);

View File

@ -0,0 +1,117 @@
package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbMemberInMapper;
import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant;
import com.chaozhanggui.system.cashierservice.entity.TbMemberIn;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.WxScanPayResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.util.Date;
@Component
public class PayUtils {
private static final Logger log = LoggerFactory.getLogger(PayUtils.class);
@Value("${thirdPay.payType}")
private String thirdPayType;
@Value("${thirdPay.url}")
private String thirdUrl;
@Value("${thirdPay.callInBack}")
private String callInBack;
@Value("${thirdPay.callFSTBack}")
private String callFSTBack;
@Value("${ysk.url}")
private String url;
@Value("${ysk.callBackurl}")
private String callBackurl;
@Value("${ysk.callBackGroupurl}")
private String callBackGroupurl;
@Value("${ysk.callBackIn}")
private String callBackIn;
private final RestTemplate restTemplate;
private final ThirdPayService thirdPayService;
private final TbMemberInMapper tbMemberInMapper;
public PayUtils(RestTemplate restTemplate, ThirdPayService thirdPayService, TbMemberInMapper tbMemberInMapper) {
this.restTemplate = restTemplate;
this.thirdPayService = thirdPayService;
this.tbMemberInMapper = tbMemberInMapper;
}
public JsonNode getWxPay(String ip, String songOrderNo,
Integer userId,
String code,
Integer shopId,
BigDecimal money,
Integer merchantId,
String openId, TbMerchantThirdApply thirdApply) {
TbMemberIn memberIn=new TbMemberIn();
memberIn.setAmount(money);
memberIn.setUserId(userId);
memberIn.setCode(code);
memberIn.setShopId(shopId);
memberIn.setStatus("100");
memberIn.setMerchantId(merchantId);
memberIn.setCreateTime(new Date());
String orderNo=DateUtils.getsdfTimesSS();
log.info("开始发送支付请求,携带参数:{}", memberIn);
JSONObject ext = new JSONObject();
ext.put("payType", PayTypeConstant.MINI_PAY);
ext.put("orderNo", songOrderNo);
PublicResp<WxScanPayResp> publicResp= thirdPayService
.scanpay(thirdUrl,thirdApply.getAppId(),
"会员充值","会员充值",money.setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
"WECHAT",
thirdApply.getSmallAppid(),
openId,ip, orderNo,
thirdApply.getStoreId(),callInBack,null,thirdApply.getAppToken(), ext.toJSONString());
log.info("支付请求发送完毕,响应内容:{}", publicResp);
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
if("000000".equals(publicResp.getCode())){
WxScanPayResp wxScanPayResp= publicResp.getObjData();
if("TRADE_AWAIT".equals(wxScanPayResp.getState())){
memberIn.setOrderNo(orderNo);
memberIn.setTradeNo(wxScanPayResp.getPayOrderId());
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.readTree(wxScanPayResp.getPayInfo());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}else{
throw new MsgException(publicResp.getMsg());
}
}
}
return null;
}
}

View File

@ -6,7 +6,10 @@ import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -118,6 +121,13 @@ public class TokenUtil {
}
return jsonObject;
}
public static Integer getUserId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
JSONObject jsonObject = parseParamFromToken(request.getHeader("token"));
return jsonObject.getInteger("userId");
}
// public static void main(String[] args) throws Exception {
// System.out.println(refreshToken("eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1OTY4Nzc5MjEsInN1YiI6ImRkZGRkIiwiaWF0IjoxNTk2Njk3OTIxfQ.lrg3KF9h9izbmyD2q5onqnZIKBqanWy9xCcroFpjxPKmJz6kz27G9lVlFpVanrL1I4SFf3Dz3q3Xu01DX2T_dw"));
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopSongMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopSong">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="img" column="img" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="originSinger" column="origin_singer" jdbcType="VARCHAR"/>
<result property="singerId" column="singer_id" jdbcType="INTEGER"/>
<result property="singer" column="singer" jdbcType="VARCHAR"/>
<result property="price" column="price" jdbcType="DECIMAL"/>
<result property="salesNumber" column="sales_number" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,shop_id,img,
name,origin_singer,singer_id,
singer,price,sales_number,
status,sort,create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_song
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllAndSearch" resultType="com.chaozhanggui.system.cashierservice.entity.TbShopSong">
select *
from fycashier.tb_shop_song where shop_id=#{shopId}
and status=1
<if test="keyWord != null and keyWord != ''">
and name like CONCAT('%',#{keyWord},'%')
</if>
order by create_time desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from tb_shop_song
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSong" useGeneratedKeys="true">
insert into tb_shop_song
( id,shop_id,img
,name,origin_singer,singer_id
,singer,price,sales_number
,status,sort,create_time
,update_time)
values (#{id,jdbcType=INTEGER},#{shopId,jdbcType=INTEGER},#{img,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR},#{originSinger,jdbcType=VARCHAR},#{singerId,jdbcType=INTEGER}
,#{singer,jdbcType=VARCHAR},#{price,jdbcType=DECIMAL},#{salesNumber,jdbcType=INTEGER}
,#{status,jdbcType=TINYINT},#{sort,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP}
,#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSong" useGeneratedKeys="true">
insert into tb_shop_song
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="shopId != null">shop_id,</if>
<if test="img != null">img,</if>
<if test="name != null">name,</if>
<if test="originSinger != null">origin_singer,</if>
<if test="singerId != null">singer_id,</if>
<if test="singer != null">singer,</if>
<if test="price != null">price,</if>
<if test="salesNumber != null">sales_number,</if>
<if test="status != null">status,</if>
<if test="sort != null">sort,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="img != null">#{img,jdbcType=VARCHAR},</if>
<if test="name != null">#{name,jdbcType=VARCHAR},</if>
<if test="originSinger != null">#{originSinger,jdbcType=VARCHAR},</if>
<if test="singerId != null">#{singerId,jdbcType=INTEGER},</if>
<if test="singer != null">#{singer,jdbcType=VARCHAR},</if>
<if test="price != null">#{price,jdbcType=DECIMAL},</if>
<if test="salesNumber != null">#{salesNumber,jdbcType=INTEGER},</if>
<if test="status != null">#{status,jdbcType=TINYINT},</if>
<if test="sort != null">#{sort,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSong">
update tb_shop_song
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="img != null">
img = #{img,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="originSinger != null">
origin_singer = #{originSinger,jdbcType=VARCHAR},
</if>
<if test="singerId != null">
singer_id = #{singerId,jdbcType=INTEGER},
</if>
<if test="singer != null">
singer = #{singer,jdbcType=VARCHAR},
</if>
<if test="price != null">
price = #{price,jdbcType=DECIMAL},
</if>
<if test="salesNumber != null">
sales_number = #{salesNumber,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSong">
update tb_shop_song
set
shop_id = #{shopId,jdbcType=INTEGER},
img = #{img,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
origin_singer = #{originSinger,jdbcType=VARCHAR},
singer_id = #{singerId,jdbcType=INTEGER},
singer = #{singer,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
sales_number = #{salesNumber,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
sort = #{sort,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopSongOrderMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="songId" column="song_id" jdbcType="INTEGER"/>
<result property="songName" column="song_name" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="payMoney" column="pay_money" jdbcType="DECIMAL"/>
<result property="state" column="state" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="clientType" column="client_type" jdbcType="TINYINT"/>
<result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
<result property="fromName" column="from_name" jdbcType="VARCHAR"/>
<result property="toName" column="to_name" jdbcType="VARCHAR"/>
<result property="note" column="note" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="realMoney" column="real_money" jdbcType="DECIMAL"/>
</resultMap>
<sql id="Base_Column_List">
id,song_id,song_name,
user_id,pay_money,state,
create_time,client_type,order_no,
from_name,to_name,note,
shop_id,real_money
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_song_order
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from tb_shop_song_order
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder" useGeneratedKeys="true">
insert into tb_shop_song_order
( id,song_id,song_name
,user_id,pay_money,state
,create_time,client_type,order_no
,from_name,to_name,note
,shop_id,real_money)
values (#{id,jdbcType=INTEGER},#{songId,jdbcType=INTEGER},#{songName,jdbcType=VARCHAR}
,#{userId,jdbcType=INTEGER},#{payMoney,jdbcType=DECIMAL},#{state,jdbcType=TINYINT}
,#{createTime,jdbcType=TIMESTAMP},#{clientType,jdbcType=TINYINT},#{orderNo,jdbcType=VARCHAR}
,#{fromName,jdbcType=VARCHAR},#{toName,jdbcType=VARCHAR},#{note,jdbcType=VARCHAR}
,#{shopId,jdbcType=INTEGER},#{realMoney,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder" useGeneratedKeys="true">
insert into tb_shop_song_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="songId != null">song_id,</if>
<if test="songName != null">song_name,</if>
<if test="userId != null">user_id,</if>
<if test="payMoney != null">pay_money,</if>
<if test="state != null">state,</if>
<if test="createTime != null">create_time,</if>
<if test="clientType != null">client_type,</if>
<if test="orderNo != null">order_no,</if>
<if test="fromName != null">from_name,</if>
<if test="toName != null">to_name,</if>
<if test="note != null">note,</if>
<if test="shopId != null">shop_id,</if>
<if test="realMoney != null">real_money,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="songId != null">#{songId,jdbcType=INTEGER},</if>
<if test="songName != null">#{songName,jdbcType=VARCHAR},</if>
<if test="userId != null">#{userId,jdbcType=INTEGER},</if>
<if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
<if test="state != null">#{state,jdbcType=TINYINT},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="clientType != null">#{clientType,jdbcType=TINYINT},</if>
<if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
<if test="fromName != null">#{fromName,jdbcType=VARCHAR},</if>
<if test="toName != null">#{toName,jdbcType=VARCHAR},</if>
<if test="note != null">#{note,jdbcType=VARCHAR},</if>
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="realMoney != null">#{realMoney,jdbcType=DECIMAL},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
update tb_shop_song_order
<set>
<if test="songId != null">
song_id = #{songId,jdbcType=INTEGER},
</if>
<if test="songName != null">
song_name = #{songName,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="payMoney != null">
pay_money = #{payMoney,jdbcType=DECIMAL},
</if>
<if test="state != null">
state = #{state,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="clientType != null">
client_type = #{clientType,jdbcType=TINYINT},
</if>
<if test="orderNo != null">
order_no = #{orderNo,jdbcType=VARCHAR},
</if>
<if test="fromName != null">
from_name = #{fromName,jdbcType=VARCHAR},
</if>
<if test="toName != null">
to_name = #{toName,jdbcType=VARCHAR},
</if>
<if test="note != null">
note = #{note,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="realMoney != null">
real_money = #{realMoney,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
update tb_shop_song_order
set
song_id = #{songId,jdbcType=INTEGER},
song_name = #{songName,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=INTEGER},
pay_money = #{payMoney,jdbcType=DECIMAL},
state = #{state,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
client_type = #{clientType,jdbcType=TINYINT},
order_no = #{orderNo,jdbcType=VARCHAR},
from_name = #{fromName,jdbcType=VARCHAR},
to_name = #{toName,jdbcType=VARCHAR},
note = #{note,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=INTEGER},
real_money = #{realMoney,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByUserIdAndId" resultType="java.util.Map">
SELECT
*
FROM
tb_shop_song_order AS a
LEFT JOIN tb_shop_song AS b ON a.song_id = b.id
WHERE
a.user_id = #{userId}
AND a.id=#{id}
</select>
</mapper>