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

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java
This commit is contained in:
牛叉闪闪 2024-07-22 13:55:53 +08:00
commit fd293f2df0
33 changed files with 784 additions and 418 deletions

View File

@ -60,7 +60,9 @@ public class LoginFilter implements Filter {
// 点歌部分不需要登录
"/cashierService/song/detail",
"/cashierService/song/record",
"/cashierService/song"
"/cashierService/song",
"/cashierService/song/singing",
"/cashierService/login/test"
);
@Autowired

View File

@ -96,19 +96,15 @@ public class LoginContoller {
* @return
*/
@RequestMapping("/wx/custom/login")
public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> map
// ,
// @RequestParam(value = "rawData", required = false) String rawData,
// @RequestParam(value = "signature", required = false) String signature
) {
public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> map) {
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
Result.fail("code不能为空");
}
String code = map.get("code").toString();
String rawData = map.get("rawData");
String signature = map.get("signature");
String encryptedData = map.get("encryptedData");
String ivStr = map.get("iv");
// String signature = map.get("signature");
// String encryptedData = map.get("encryptedData");
// String ivStr = map.get("iv");
// String phone = map.get("phone");
// 用户非敏感信息rawData
// 签名signature
@ -118,26 +114,26 @@ public class LoginContoller {
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
// 3.接收微信接口服务 获取返回的参数
String openid = SessionKeyOpenId.getString("openid");
String sessionKey = SessionKeyOpenId.getString("session_key");
// String sessionKey = SessionKeyOpenId.getString("session_key");
// 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey)
String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
if (!signature.equals(signature2)) {
return Result.fail("签名校验失败");
}
String phone = "";
try{
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
phone =JSONObject.parseObject(data).get("phoneNumber").toString();
}
}catch (Exception e){
log.info("登录传参:获取手机号失败{}",e.getMessage());
}
// String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
// if (!signature.equals(signature2)) {
// return Result.fail("签名校验失败");
// }
// String phone = "";
// try{
// String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
// if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
// phone =JSONObject.parseObject(data).get("phoneNumber").toString();
// }
// }catch (Exception e){
// log.info("登录传参:获取手机号失败{}",e.getMessage());
// }
String nickName = rawDataJson.getString("nickName");
String avatarUrl = rawDataJson.getString("avatarUrl");
try {
return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, IpUtil.getIpAddr(request));
return loginService.wxCustomLogin(openid, avatarUrl, nickName, "", IpUtil.getIpAddr(request));
} catch (Exception e) {
e.printStackTrace();
}
@ -154,7 +150,37 @@ public class LoginContoller {
* @return
*/
// @RequestMapping("getPhoneNumber")
public Result getPhoneNumber(@RequestBody Map<String, String> map) {
// public Result getPhoneNumber(@RequestBody Map<String, String> map) {
//
// if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
// Result.fail("code不能为空");
// }
// String code = map.get("code").toString();
//
// String encryptedData = map.get("encryptedData");
//
// String ivStr = map.get("iv");
// if (StringUtils.isBlank(encryptedData) || StringUtils.isBlank(ivStr)) {
// return Result.fail("请授权后使用");
// }
//
// JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
// // 3.接收微信接口服务 获取返回的参数
// String openid = SessionKeyOpenId.getString("openid");
// String sessionKey = SessionKeyOpenId.getString("session_key");
// String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
// try {
// if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
// return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
// }
// } catch (Exception e){
// log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data);
// }
// return Result.fail("获取手机号失败,请重试!");
// }
@RequestMapping("getPhoneNumber")
public Result getPhoneNumber(@RequestHeader String openId,@RequestBody Map<String, String> map) {
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
Result.fail("code不能为空");
@ -175,10 +201,14 @@ public class LoginContoller {
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
try {
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) {
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
}
log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString());
}
} catch (Exception e){
// e.printStackTrace();
log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data);
}
return Result.fail("获取手机号失败,请重试!");

View File

@ -55,18 +55,12 @@ 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();
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);
}
}
}
}
return null;
@ -159,8 +153,9 @@ public class NotifyController {
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "000000".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("bizData"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("state") && "TRADE_SUCCESS".equals(object.getStr("state"))) {
String tradeNo=object.get("payOrderId").toString();
String orderNo = object.getStr("mchOrderNo");
return payService.songOrderSuccess(orderNo, DateUtils.getTime(new Date()));
return payService.songOrderSuccess(orderNo, tradeNo);
}
}
return null;

View File

@ -50,10 +50,7 @@ public class OrderController {
@RequestParam Integer size, @RequestParam String status){
return orderService.orderList(userId,page,size,status);
}
@GetMapping("/testMessage")
private void testMessage(@RequestParam("tableId") String tableId, @RequestParam("message") String message) throws IOException {
orderService.testMessage(tableId,message);
}
@GetMapping("/tradeIntegral")
private Result tradeIntegral(@RequestParam("userId") String userId, @RequestParam("id") String id) throws IOException, ParseException {
return orderService.tradeIntegral(userId,id);

View File

@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
import com.chaozhanggui.system.cashierservice.sign.Result;
@ -52,15 +53,35 @@ public class ShopSongController {
@GetMapping("/record")
public Result getRecord(
@RequestHeader("openId") String openId,
@RequestParam("shopId") Integer shopId,
@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(openId, page, size, state, isDesc));
return Result.successWithData(shopSongService.getRecord(openId, page, size, state, isDesc,shopId));
}
/**
* 获取正在播放的歌曲
* @param openId 用户id
* @return 歌曲信息
*/
@GetMapping("/singing")
public Result getSinging(
@RequestHeader("openId") String openId
) {
return Result.successWithData(shopSongService.getSinging(openId));
}
/**
* 创建订单
* @param openId 用户信息
* @param songOrderDTO 订单信息
* @return result
*/
@LimitSubmit(key = "song_order_pay:#openId")
@PostMapping
public Result createOrder(
@RequestHeader("openId") String openId,

View File

@ -89,8 +89,8 @@ public class UserContoller {
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
if(ObjectUtil.isEmpty(shopUser)){
// shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
// if(ObjectUtil.isEmpty(shopUser)){
shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
@ -112,16 +112,20 @@ public class UserContoller {
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
}else {
shopUser.setUserId(userId);
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.updateByPrimaryKey(shopUser);
}
// }else {
// shopUser.setUserId(userId);
// shopUser.setUpdatedAt(System.currentTimeMillis());
// shopUserMapper.updateByPrimaryKey(shopUser);
// }
}
} else {
shopUser.setAmount(BigDecimal.ZERO);
}
if (tbShopInfo != null) {
shopUser.setShopName(tbShopInfo.getShopName());
}else {
shopUser.setShopName("");
}
return Result.success(CodeEnum.SUCCESS, shopUser);
}
@ -130,24 +134,28 @@ public class UserContoller {
int num = userService.userCoupon(userId, orderNum);
return Result.success(CodeEnum.SUCCESS, num);
}
@PostMapping("/modityIntegral")
public JSONObject modityIntegral(@RequestHeader String token, @RequestBody IntegralVo integralVo) throws Exception {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userSign = jsonObject.getString("userSign");
return userService.modityIntegral(integralVo, userSign);
}
@PostMapping("/userIntegral")
public JSONObject userIntegral(@RequestHeader String token, @RequestBody IntegralFlowVo integralFlowVo) throws Exception {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userSign = jsonObject.getString("userSign");
return userService.userIntegral(integralFlowVo, userSign);
}
@PostMapping("/userAllIntegral")
public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
// String userSign = jsonObject.getString("userSign");
return userService.userAllIntegral(integralFlowVo, "userSign");
}
@PostMapping("/userAll")
public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
@ -156,8 +164,4 @@ public class UserContoller {
}
}

View File

@ -19,6 +19,7 @@ public interface TbProductMapper {
TbProduct selectById(Integer id);
List<TbProduct> selectByIdIn(@Param("ids") String ids);
List<TbProduct> selectByIdInAndCheck(@Param("ids") String ids);
List<TbProduct> selectByIds(@Param("list") List<String> ids);
Integer selectByQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId);

View File

@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
@ -15,19 +16,11 @@ import java.util.List;
public interface TbProductSkuMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbProductSkuWithBLOBs record);
int insertSelective(TbProductSkuWithBLOBs record);
TbProductSkuWithBLOBs selectByPrimaryKey(Integer id);
Integer selectBySpecSnap(@Param("shopId")String shopId,@Param("tableId") Integer tableId,@Param("specSnap") String specSnap);
int updateByPrimaryKeySelective(TbProductSkuWithBLOBs record);
List<HomeVO> selectSale();
List<HomeVO> selectDay();
int updateByPrimaryKeyWithBLOBs(TbProductSkuWithBLOBs record);
int updateByPrimaryKey(TbProductSku record);
TbProductSkuWithBLOBs selectByShopIdAndProductIdAndSpec(@Param("shopId") String shopId, @Param("productId") String productId, @Param("spec") String spec);
@ -46,4 +39,7 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id}")
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
}

View File

@ -26,8 +26,8 @@ public interface TbShopOpenIdMapper {
int updateByPrimaryKey(TbShopOpenId record);
@Select("select * from tb_shop_open_id where open_id=#{openId}")
TbShopOpenId countByOpenId(@Param("openId") String openId);
@Select("select * from tb_shop_open_id where open_id=#{openId} and shop_id=#{shopId} limit 1")
TbShopOpenId countByOpenId(@Param("openId") String openId, @Param("shopId") Integer shopId);
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1")
List<TbShopOpenId> selectByShopId(@Param("shopId") Integer shopId);

View File

@ -11,7 +11,7 @@ import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_song_order的数据库操作Mapper
* @createDate 2024-07-09 15:23:30
* @createDate 2024-07-11 09:24:20
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder
*/
public interface TbShopSongOrderMapper {
@ -29,15 +29,23 @@ public interface TbShopSongOrderMapper {
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" +
" a.id orderId, b.img, b.name, b.origin_singer originSinger, b.price, a.from_name fromName, a.to_name toName, a.note,a.create_time,a.state\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.open_id = #{openId} and a.shop_id=#{shopId} " +
" <if test=\"state!=null\">AND a.state = #{state}</if> order by a.state asc, a.create_time desc</script>")
List<Map<String, Object>> selectByUserId(@Param("openId") String openId, @Param("state") Integer state, Integer shopId);
@Select(" SELECT\n" +
" *\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.open_id = #{openId}\n" +
" <if test=\"state!=null\">AND a.state = #{state}</if></script>")
List<Map<String, Object>> selectByUserId(@Param("openId") String openId, @Param("state") Integer state);
" AND a.id=#{id}")
Map<String, Object> selectByUserIdAndId(@Param("openId") String openId, @Param("id") Integer id);
@Select("select * from fycashier.tb_shop_song_order where order_no=#{orderNo};")
@ -47,4 +55,18 @@ public interface TbShopSongOrderMapper {
"WHERE create_time < NOW() - INTERVAL 10 MINUTE AND state=-1;\n")
int deleteExpireOrder();
@Select("SELECT\n" +
" a.id orderId,b.img, b.name, b.origin_singer originSinger, b.price, a.from_name fromName, a.to_name toName, a.note, a.create_time,a.state\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.open_id = #{openId} and a.state in (1, 2, 3) and a.shop_id=#{shopId} order by a.state asc, a.create_time desc")
List<Map<String, Object>> selectActiveOrderByUserId(@Param("openId") String openId, Integer shopId);
@Select("SELECT a.song_name songName, a.id, b.img FROM `tb_shop_song_order` as a left join tb_shop_song as b on a.song_id=b.id where state=2 limit 1")
Map<String, Object> selectSinging();
@Select("select id from tb_shop_song_order where (state=1 or state=2) and shop_id=#{id} order by create_time asc")
List<TbShopSongOrder> selectWaitAll(@Param("id") Integer shopId);
}

View File

@ -30,6 +30,7 @@ public interface TbShopUserMapper {
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
TbShopUser selectByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
TbShopUser selectPCByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
List<TbShopUser> selectAllByUserId(@Param("userId") String userId);

View File

@ -135,6 +135,7 @@ public class TbProduct implements Serializable {
private String groupCategoryId;
private Integer stockNumber;
private Integer suit;
public String getImages() {
@ -663,4 +664,12 @@ public class TbProduct implements Serializable {
public Integer getStockNumber() {
return this.stockNumber;
}
public Integer getSuit() {
return suit;
}
public void setSuit(Integer suit) {
this.suit = suit;
}
}

View File

@ -24,6 +24,8 @@ public class TbProductSku implements Serializable {
private BigDecimal guidePrice;
private Integer suit;
private BigDecimal strategyPrice;
private Double stockNumber;
@ -47,9 +49,28 @@ public class TbProductSku implements Serializable {
private Long updatedAt;
private Integer isPauseSale = 0;
private Integer isDel;
private Integer isGrounding;
private String specSnap;
public String getSpecSnap() {
return specSnap;
}
public void setSpecSnap(String specSnap) {
this.specSnap = specSnap;
}
private static final long serialVersionUID = 1L;
public Integer getIsGrounding() {
return isGrounding;
}
public void setIsGrounding(Integer isGrounding) {
this.isGrounding = isGrounding;
}
public Integer getId() {
return id;
}
@ -186,6 +207,14 @@ public class TbProductSku implements Serializable {
this.realSalesNumber = realSalesNumber;
}
public Integer getSuit() {
return suit;
}
public void setSuit(Integer suit) {
this.suit = suit;
}
public BigDecimal getFirstShared() {
return firstShared;
}
@ -225,4 +254,12 @@ public class TbProductSku implements Serializable {
public void setIsPauseSale(Integer isPauseSale) {
this.isPauseSale = isPauseSale;
}
public Integer getIsDel() {
return isDel;
}
public void setIsDel(Integer isDel) {
this.isDel = isDel;
}
}

View File

@ -27,7 +27,7 @@ public class TbShopSongOrder implements Serializable {
private String songName;
/**
* 用户id
* 用户openId
*/
private String openId;
@ -81,6 +81,11 @@ public class TbShopSongOrder implements Serializable {
*/
private BigDecimal realMoney;
/**
* 平台订单号
*/
private String payOrderId;
private static final long serialVersionUID = 1L;
@Override
@ -108,7 +113,8 @@ public class TbShopSongOrder implements Serializable {
&& (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()));
&& (this.getRealMoney() == null ? other.getRealMoney() == null : this.getRealMoney().equals(other.getRealMoney()))
&& (this.getPayOrderId() == null ? other.getPayOrderId() == null : this.getPayOrderId().equals(other.getPayOrderId()));
}
@Override
@ -129,6 +135,7 @@ public class TbShopSongOrder implements Serializable {
result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getRealMoney() == null) ? 0 : getRealMoney().hashCode());
result = prime * result + ((getPayOrderId() == null) ? 0 : getPayOrderId().hashCode());
return result;
}
@ -152,6 +159,7 @@ public class TbShopSongOrder implements Serializable {
sb.append(", note=").append(note);
sb.append(", shopId=").append(shopId);
sb.append(", realMoney=").append(realMoney);
sb.append(", payOrderId=").append(payOrderId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();

View File

@ -160,54 +160,6 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
});
}
/**
* @param message 发送的消息内容
* @param shopId 店铺Id
// * @param clientId 客户端Id
// * @param userFlag 为true 单发给clientId
* 为false 群发 shopId为空 发给所有人
*/
// @Async
// public void AppSendInfo(String message, String shopId,String clientId, boolean userFlag) {
// log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}",shopId,clientId,userFlag, JSONUtil.toJSONString(message));
// if (userFlag) {
// if (webSocketMap.containsKey(shopId)) {
// ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
// if(!webSockets.isEmpty()){
// if (StringUtils.isNotBlank(clientId)) {
// ChannelHandlerContext ctx = webSockets.get(clientId);
// if (ctx != null) {
// sendMesToApp(message,ctx);
// }
// }
// }
// }
// } else {
// if (StringUtils.isEmpty(shopId)) {
// // 向所有用户发送信息
// for (ConcurrentHashMap<String, ChannelHandlerContext> value : webSocketMap.values()) {
// for (ChannelHandlerContext ctx : value.values()) {
// sendMesToApp(message,ctx);
// }
// }
// } else if (webSocketMap.containsKey(shopId)) {
// ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(shopId);
// if((!webSockets.isEmpty() && !webSockets.keySet().isEmpty())) {
// for (String user : webSockets.keySet()) {
// ChannelHandlerContext ctx = webSockets.get(user);
// if (ctx != null) {
// log.info("netty连接client 发送消息 桌码群发 clientId:{}",user);
// sendMesToApp(message,ctx);
// }else {
// log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",user);
// }
// }
// }else {
// log.info("netty连接client 发送消息 桌码群发 clientId:{} 失败",clientId);
// }
// }
// }
// }
public void AppSendInfoV1(String shopId, String orderNo, JSONObject message) {
log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}", shopId, message.get("orderInfo"));
retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(message);

View File

@ -59,4 +59,7 @@ public interface RabbitConstants {
public static final String CONS_MSG_COLLECT_ROUTINGKEY_PUT = "cons_msg_collect_routingkey_put";
// 库存记录交换机
String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";
}

View File

@ -24,4 +24,6 @@ public class RedisCst {
public static final String OUT_NUMBER="ORDER:NUMBER:";
// 创建订单锁
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:";
public static final String SONG_PAY_LOCK = "song_pay_lock:";
}

View File

@ -288,7 +288,6 @@ public class CartService {
// log.error("长链接错误 createCart{}", e.getMessage());
// }
// }
public void createCart(JSONObject jsonObject) {
try {
String tableId = jsonObject.getString("tableId");
@ -311,10 +310,24 @@ public class CartService {
Integer buyNum = jsonObject.getInteger("num");
String skuId = jsonObject.getString("skuId");
// 判断商品是否已下架
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
if (tbProductSkuWithBLOBs ==null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "此商品已下架");
jsonObject1.put("data", new ArrayList<>());
jsonObject1.put("reqData", jsonObject);
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.error("商品已下架 skuId:{}", skuId);
return;
}
if (tbProduct.getIsStock() == 1) {
// 1:共享库存 0:独立库存
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() - buyNum < 0) {//是否售罄
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() < buyNum ) {//是否售罄
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "该商品已售罄");
@ -326,8 +339,7 @@ public class CartService {
throw new MsgException("该商品已售罄");
}
} else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
if(tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() - buyNum < 0){//是否售罄
if (tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() < buyNum ) {//是否售罄
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "该商品已售罄");
@ -360,6 +372,10 @@ public class CartService {
if (cashierCart.getSkuId().equals(skuId)) {
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + buyNum);
cashierCart.setNumber(cashierCart.getNumber() + buyNum);
if (buyNum < 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) {
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
continue;
}
if (cashierCart.getNumber() > 0) {
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
@ -460,9 +476,16 @@ public class CartService {
) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
shopOpenIds.forEach(item -> {
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
if (message == null) {
wechatUtil.sendStockWarnMsg(shopInfo.getShopName(), product.getName(),
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber() - num) : String.valueOf(productSku.getStockNumber() - num),
"耗材库存不足,请及时补充。", item.getOpenId());
"商品库存不足,请及时补充。", item.getOpenId());
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
}else {
log.info("{}已在30分钟内推送过消息跳过发送", item.getOpenId());
}
});
}
}
@ -491,9 +514,33 @@ public class CartService {
throw new MsgException("该商品规格不存在");
}
TbCashierCart cashierCart = new TbCashierCart();
if (productSku.getSuit() != null && productSku.getSuit() > 1) {
if (product.getIsStock() == 1) {
boolean isSale = false;
// 1:共享库存 0:独立库存
if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
} else {
if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
}
if (isSale) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "该商品库存不足");
jsonObject1.put("data", new ArrayList<>());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
log.error("购物车添加商品异常,该商品起售库存不足:{}", productId);
throw new MsgException("该商品起售库存不足");
}
}
cashierCart.setNumber(productSku.getSuit());
cashierCart.setTotalNumber(productSku.getSuit());
} else {
cashierCart.setNumber(num);
cashierCart.setTotalNumber(num);
}
cashierCart.setProductId(productId);
cashierCart.setSkuId(skuId);
cashierCart.setNumber(num);
cashierCart.setCoverImg(product.getCoverImg());
cashierCart.setName(product.getName());
cashierCart.setCategoryId(product.getCategoryId());
@ -508,7 +555,6 @@ public class CartService {
cashierCart.setSalePrice(productSku.getSalePrice());
cashierCart.setCreatedAt(Instant.now().toEpochMilli());
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
cashierCart.setTotalNumber(num);
cashierCart.setPackFee(BigDecimal.ZERO);
cashierCart.setRefundNumber(0);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
@ -534,6 +580,7 @@ public class CartService {
try {
String shopId = jsonObject.getString("shopId");
String tableId = jsonObject.getString("tableId");
String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark");
String key = tableId + "-" + shopId;
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
List<Integer> ids = new ArrayList<>();
@ -561,6 +608,16 @@ public class CartService {
TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
// 判断商品是否已下架
if (tbProduct.getIsGrounding().equals(0)) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName());
jsonObject1.put("data", new ArrayList<>());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
return;
}
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cashierCart.getNumber()));
@ -728,7 +785,7 @@ public class CartService {
orderInfo.setProductAmount(saleAmount);
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setIsUseCoupon(isuseYhq);
// orderInfo.setRemark(StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark"));
orderInfo.setRemark(remark);
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else {
@ -739,6 +796,7 @@ public class CartService {
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setIsUseCoupon(isuseYhq);
orderInfo.setUserCouponAmount(couponAmount);
orderInfo.setRemark(remark);
JSONObject object = new JSONObject();
String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
@ -777,7 +835,16 @@ public class CartService {
object.put("updatedAt", System.currentTimeMillis());
object.put("orderId", orderId + "");
}
// 发送mq消息
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("orderId", orderInfo.getId());
jsonObject2.put("type", "create");
log.info("开始发送mq消息消耗耗材消息内容{}", jsonObject2);
producer.cons(jsonObject2.toString());
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
orderInfo.setDetailList(orderDetails);
JSONObject jsonObject1 = new JSONObject();
@ -799,13 +866,6 @@ public class CartService {
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
// 发送mq消息
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("orderId", orderId);
jsonObject2.put("type", "create");
log.info("开始发送mq消息消耗耗材消息内容{}", jsonObject2);
producer.cons(jsonObject2.toString());
} catch (Exception e) {
log.info("长链接错误 addCart{}", e.getMessage());
e.printStackTrace();

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
@ -76,7 +77,7 @@ public class LoginService {
}
// 为商家绑定openid
if (shopOpenIdMapper.countByOpenId(openId) == null) {
if (shopOpenIdMapper.countByOpenId(openId, Integer.valueOf(shopId)) == null) {
TbShopOpenId shopOpenId = new TbShopOpenId();
shopOpenId.setOpenId(openId);
shopOpenId.setCreateTime(DateUtil.date());
@ -88,14 +89,8 @@ public class LoginService {
}
@Transactional(rollbackFor = Exception.class)
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception {
TbUserInfo userInfo = new TbUserInfo();
if(StringUtils.isNotBlank(telephone)){
userInfo = tbUserInfoMapper.selectByPhone(telephone);
if (ObjectUtil.isNull(userInfo)) {
userInfo = tbUserInfoMapper.selectByOpenId(openId);
public Result wxCustomLogin(String openId,String headImage,String nickName,String telephone,String ip) {
TbUserInfo userInfo= tbUserInfoMapper.selectByOpenId(openId);
if(ObjectUtil.isNull(userInfo)){
userInfo=new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
@ -105,9 +100,9 @@ public class LoginService {
userInfo.setConsumeAmount(BigDecimal.ZERO);
userInfo.setTotalScore(0);
userInfo.setLockScore(0);
userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");
userInfo.setHeadImg(ObjectUtil.isNotNull(headImage)?headImage:"");
userInfo.setNickName(ObjectUtil.isNotNull(nickName)?nickName:"微信用户");
userInfo.setTelephone(telephone);
userInfo.setTelephone(ObjectUtil.isNotNull(telephone)?telephone:"");
userInfo.setMiniAppOpenId(openId);
userInfo.setStatus(Byte.parseByte("1"));
userInfo.setParentType("PERSON");
@ -119,92 +114,142 @@ public class LoginService {
userInfo.setSearchWord("||微信用户");
userInfo.setIsPwd("0");
userInfo.setPwd(MD5Utils.md5("123456"));
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.insert(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
if (!CollectionUtils.isEmpty(tbShopUsers)) {
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setUserId(userInfo.getId() + "");
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}
}else {
userInfo.setTelephone(telephone);
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
if (!CollectionUtils.isEmpty(tbShopUsers)) {
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setUserId(null);
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}
}
}else {
if(!userInfo.getMiniAppOpenId().equals(openId)){
userInfo.setMiniAppOpenId(openId);
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
}
}
}else {
userInfo = tbUserInfoMapper.selectByOpenId(openId);
if(ObjectUtil.isNull(userInfo)){
userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
userInfo.setChargeAmount(BigDecimal.ZERO);
userInfo.setLineOfCredit(BigDecimal.ZERO);
userInfo.setConsumeNumber(0);
userInfo.setConsumeAmount(BigDecimal.ZERO);
userInfo.setTotalScore(0);
userInfo.setLockScore(0);
userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");
userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
userInfo.setTelephone(telephone);
userInfo.setMiniAppOpenId(openId);
userInfo.setStatus(Byte.parseByte("1"));
userInfo.setParentType("PERSON");
userInfo.setIsResource(Byte.parseByte("0"));
userInfo.setIsOnline(Byte.parseByte("0"));
userInfo.setIsVip(Byte.parseByte("0"));
userInfo.setSourcePath("WECHAT-APP");
userInfo.setIsAttentionMp(Byte.parseByte("0"));
userInfo.setSearchWord("||微信用户");
userInfo.setIsPwd("0");
userInfo.setPwd(MD5Utils.md5("123456"));
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.insert(userInfo);
}
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
}
//生成token 信息
String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());
Map<String, Object> map = new HashMap<>();
try {
map.put("token", token);
map.put("userInfo", userInfo);
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map), 60 * 60 * 24 * 30L);
//redis里 获取要关注的公众号信息
//userInfo 某字段存储关注公众号的标识
// userInfo.get
//公众号 appid
//展示描述
//图标
// map.put("", );
log.info("登录传参 结果:" + JSONUtil.toJSONString(map));
return Result.success(CodeEnum.SUCCESS, map);
} catch (Exception e) {
e.printStackTrace();
}
}
return Result.fail("登录失败");
}
// @Transactional(rollbackFor = Exception.class)
// public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception {
// TbUserInfo userInfo = new TbUserInfo();
// if(StringUtils.isNotBlank(telephone)){
// userInfo = tbUserInfoMapper.selectByPhone(telephone);
// if (ObjectUtil.isNull(userInfo)) {
// userInfo = tbUserInfoMapper.selectByOpenId(openId);
// if (ObjectUtil.isNull(userInfo)) {
// userInfo = new TbUserInfo();
// userInfo.setAmount(BigDecimal.ZERO);
// userInfo.setChargeAmount(BigDecimal.ZERO);
// userInfo.setLineOfCredit(BigDecimal.ZERO);
// userInfo.setConsumeNumber(0);
// userInfo.setConsumeAmount(BigDecimal.ZERO);
// userInfo.setTotalScore(0);
// userInfo.setLockScore(0);
// userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");
// userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
// userInfo.setTelephone(telephone);
// userInfo.setMiniAppOpenId(openId);
// userInfo.setStatus(Byte.parseByte("1"));
// userInfo.setParentType("PERSON");
// userInfo.setIsResource(Byte.parseByte("0"));
// userInfo.setIsOnline(Byte.parseByte("0"));
// userInfo.setIsVip(Byte.parseByte("0"));
// userInfo.setSourcePath("WECHAT-APP");
// userInfo.setIsAttentionMp(Byte.parseByte("0"));
// userInfo.setSearchWord("||微信用户");
// userInfo.setIsPwd("0");
// userInfo.setPwd(MD5Utils.md5("123456"));
// userInfo.setLastLogInAt(System.currentTimeMillis());
// userInfo.setCreatedAt(System.currentTimeMillis());
// userInfo.setUpdatedAt(System.currentTimeMillis());
// tbUserInfoMapper.insert(userInfo);
// List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
// if (!CollectionUtils.isEmpty(tbShopUsers)) {
// for (TbShopUser tbShopUser : tbShopUsers) {
// tbShopUser.setUserId(userInfo.getId() + "");
// tbShopUser.setUpdatedAt(System.currentTimeMillis());
// tbShopUserMapper.updateByPrimaryKey(tbShopUser);
// }
// }
// }else {
// userInfo.setTelephone(telephone);
// userInfo.setUpdatedAt(System.currentTimeMillis());
// tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
// List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
// if (!CollectionUtils.isEmpty(tbShopUsers)) {
// for (TbShopUser tbShopUser : tbShopUsers) {
// tbShopUser.setUserId(null);
// tbShopUser.setUpdatedAt(System.currentTimeMillis());
// tbShopUserMapper.updateByPrimaryKey(tbShopUser);
// }
// }
// }
// }else {
// if(!userInfo.getMiniAppOpenId().equals(openId)){
// userInfo.setMiniAppOpenId(openId);
// userInfo.setUpdatedAt(System.currentTimeMillis());
// tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
// }
// }
// }else {
// userInfo = tbUserInfoMapper.selectByOpenId(openId);
// if(ObjectUtil.isNull(userInfo)){
// userInfo = new TbUserInfo();
// userInfo.setAmount(BigDecimal.ZERO);
// userInfo.setChargeAmount(BigDecimal.ZERO);
// userInfo.setLineOfCredit(BigDecimal.ZERO);
// userInfo.setConsumeNumber(0);
// userInfo.setConsumeAmount(BigDecimal.ZERO);
// userInfo.setTotalScore(0);
// userInfo.setLockScore(0);
// userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");
// userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
// userInfo.setTelephone(telephone);
// userInfo.setMiniAppOpenId(openId);
// userInfo.setStatus(Byte.parseByte("1"));
// userInfo.setParentType("PERSON");
// userInfo.setIsResource(Byte.parseByte("0"));
// userInfo.setIsOnline(Byte.parseByte("0"));
// userInfo.setIsVip(Byte.parseByte("0"));
// userInfo.setSourcePath("WECHAT-APP");
// userInfo.setIsAttentionMp(Byte.parseByte("0"));
// userInfo.setSearchWord("||微信用户");
// userInfo.setIsPwd("0");
// userInfo.setPwd(MD5Utils.md5("123456"));
// userInfo.setLastLogInAt(System.currentTimeMillis());
// userInfo.setCreatedAt(System.currentTimeMillis());
// userInfo.setUpdatedAt(System.currentTimeMillis());
// tbUserInfoMapper.insert(userInfo);
// }
// }
// //生成token 信息
// String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());
//
// Map<String, Object> map = new HashMap<>();
// try {
// map.put("token", token);
// map.put("userInfo", userInfo);
// redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map),60*60*24*30L);
// //redis里 获取要关注的公众号信息
// //userInfo 某字段存储关注公众号的标识
//// userInfo.get
// //公众号 appid
// //展示描述
// //图标
//// map.put("", );
// log.info("登录传参 结果:" + JSONUtil.toJSONString(map));
// return Result.success(CodeEnum.SUCCESS, map);
// } catch (Exception e) {
// e.printStackTrace();
//
// }
// return Result.fail("登录失败");
// }
/**
* APP注册
@ -366,6 +411,63 @@ public class LoginService {
return Result.success(CodeEnum.ENCRYPT, tbUserInfo);
}
@Transactional
public Result upPhone(String openId, String phone, String shopId) {
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
boolean isup = false;
if(StringUtils.isNotBlank(userInfo.getTelephone())){
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(userInfo.getTelephone());
for (TbShopUser tbShopUser : tbShopUsers) {
if (tbShopUser.getShopId().equals(shopId)) {
isup = true;
}
tbShopUser.setTelephone(phone);
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
if(!isup){
registerShopUser(userInfo,shopId);
}
}else {
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(), shopId);
if (shopUser != null) {
shopUser.setTelephone(phone);
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(shopUser);
}else {
registerShopUser(userInfo,shopId);
}
}
userInfo.setTelephone(phone);
userInfo.setUpdatedAt(System.currentTimeMillis());
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
return Result.success(CodeEnum.SUCCESS);
}
public void registerShopUser(TbUserInfo userInfo,String shopId) {
TbShopUser shopUser = new TbShopUser();
shopUser.setName(userInfo.getNickName());
shopUser.setSex(userInfo.getSex());
shopUser.setBirthDay(userInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(userInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(shopId);
shopUser.setUserId(userInfo.getId().toString());
shopUser.setMiniOpenId(userInfo.getMiniAppOpenId());
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.insert(shopUser);
}
public Result upPass(String userId, String oldPass, String newPass) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
if (!tbUserInfo.getPassword().equals(oldPass)) {

View File

@ -248,18 +248,6 @@ public class OrderService {
}
public void testMessage(String tableId, String message) throws IOException {
// AppWebSocketServer.AppSendInfo(message,tableId);
// redisUtil.seckill(tableId,message);
// AppWebSocketServer.onClosed(tableId);
List<TbProductSku> list = productSkuMapper.selectAll();
for (TbProductSku productSku : list) {
// productSku.setStockNumber(200.00);
redisUtil.saveMessage("PRODUCT:" + productSku.getShopId() + ":" + productSku.getId(), "10000");
}
}
@Transactional(rollbackFor = Exception.class)
public Result tradeIntegral(String userId, String id) throws ParseException {
updateIntegral(userId, id);

View File

@ -147,6 +147,8 @@ public class PayService {
TbActivateMapper tbActivateMapper;
private final TbShopSongOrderService shopSongOrderService;
@Autowired
private MQUtils mQUtils;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
this.shopSongOrderService = shopSongOrderService;
@ -268,7 +270,9 @@ public class PayService {
}
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());
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();
@ -878,6 +882,12 @@ public class PayService {
producer.printMechine(orderInfo.getId() + "");
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
// 发送mq消息并保存库存记录
JSONObject data = new JSONObject();
data.put("orderId", orderInfo.getId());
data.put("plat", "miniApp");
mQUtils.sendStockSaleMsg(data);
return "SUCCESS";
}
@ -923,6 +933,12 @@ public class PayService {
producer.printCoupons(coupons.toJSONString());
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
// 发送mq消息并保存库存记录
JSONObject data = new JSONObject();
data.put("orderId", orderInfo.getId());
data.put("plat", "miniApp");
mQUtils.sendStockSaleMsg(data);
return "SUCCESS";
}
@ -1205,30 +1221,7 @@ 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 paySongOrder(String openId, String shopId, Integer orderId, String ip, TbMerchantThirdApply thirdApply) throws JsonProcessingException {
if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) {
@ -1237,7 +1230,7 @@ public class PayService {
TbShopSongOrder songOrder = tbShopSongOrderMapper.selectByPrimaryKey(Long.valueOf(orderId));
if (songOrder.getState() != 0 && songOrder.getState() != -1) {
if (songOrder == null || songOrder.getState() != 0 && songOrder.getState() != -1) {
return Result.fail("订单状态异常,不允许支付");
}
@ -1287,14 +1280,14 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public String songOrderSuccess(String mchOrderNo, String orderNo) {
public String songOrderSuccess(String mchOrderNo, String tradeNo) {
TbShopSongOrder songOrder = tbShopSongOrderMapper.selectByOrderNo(mchOrderNo);
if (ObjectUtil.isEmpty(songOrder)) {
return "订单信息不存在";
}
log.info("更新点歌订单:{}", songOrder);
shopSongOrderService.successPay(mchOrderNo);
shopSongOrderService.successPay(mchOrderNo, tradeNo);
return "SUCCESS";
}

View File

@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
@ -76,8 +78,8 @@ public class ProductService {
try{
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
shopUser = tbShopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
if(ObjectUtil.isEmpty(shopUser)){
// shopUser = tbShopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
// if(ObjectUtil.isEmpty(shopUser)){
shopUser=new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
@ -99,11 +101,11 @@ public class ProductService {
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.insert(shopUser);
}else {
shopUser.setUserId(userId);
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(shopUser);
}
// }else {
// shopUser.setUserId(userId);
// shopUser.setUpdatedAt(System.currentTimeMillis());
// tbShopUserMapper.updateByPrimaryKey(shopUser);
// }
}else {
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(shopUser);
@ -138,12 +140,53 @@ public class ProductService {
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
List<TbProduct> products = tbProductMapper.selectByIdIn(in);
// List<TbProduct> products = tbProductMapper.selectByIdIn(in);
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
if (ObjectUtil.isNotEmpty(products) && products.size() > 0) {
products.parallelStream().forEach(it -> {
Integer sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId());
it.setCartNumber(sum == null ? "0" : String.valueOf(sum));
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
HashSet<String> specSet = new HashSet<>();
tbProductSkus.forEach(item -> {
String specSnap = item.getSpecSnap();
if (specSnap != null) {
specSet.addAll(Arrays.asList(specSnap.split(",")));
}
});
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
JSONObject snapJSON;
JSONArray finalSnap = new JSONArray();
String finalValues = "";
for (Object snap : tagSnaps) {
snapJSON = (JSONObject) snap;
String values = snapJSON.getString("value");
if (StrUtil.isNotBlank(values)) {
String[] valueList = values.split(",");
for (String value : valueList) {
if (specSet.contains(value)) {
finalValues = finalValues + (value) + ",";
}
}
if (StrUtil.isNotBlank(finalValues)) {
finalValues = StrUtil.removeSuffix(finalValues, ",");
snapJSON.put("value", finalValues);
finalSnap.add(snapJSON);
}
}
}
skuResult.setTagSnap(finalSnap.toJSONString());
}
it.setProductSkuResult(skuResult);
});
g.setProducts(products);

View File

@ -7,7 +7,7 @@ package com.chaozhanggui.system.cashierservice.service;
*/
public interface TbShopSongOrderService {
void successPay(String orderNo);
void successPay(String orderNo, String tradeNo);
void clearExpireOrder();
}

View File

@ -25,7 +25,7 @@ public interface TbShopSongService {
*/
PageInfo<?> all(Integer shopId, Integer page, Integer size, String keyWord, boolean isDesc);
Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc);
Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc, Integer shopId);
/**
* 创建订单
@ -44,4 +44,11 @@ public interface TbShopSongService {
* @return 订单信息
*/
Map<String, Object> getDetail(String openId, Integer id);
/**
* 正在演唱的歌曲
* @param openId 用户id
* @return 歌曲信息
*/
Object getSinging(String openId);
}

View File

@ -26,13 +26,14 @@ public class TbShopSongOrderServiceImpl
}
@Override
public void successPay(String orderNo) {
public void successPay(String orderNo, String tradeNo) {
TbShopSongOrder shopSongOrder = shopSongOrderMapper.selectByOrderNo(orderNo);
if (shopSongOrder.getState().equals(1)) {
log.warn("点歌支付成功,重复支付,订单编号:{}", orderNo);
return;
}
shopSongOrder.setState(1);
shopSongOrder.setPayOrderId(tradeNo);
shopSongOrder.setRealMoney(shopSongOrder.getPayMoney());
shopSongOrderMapper.updateByPrimaryKeySelective(shopSongOrder);
shopSongMapper.incrNum(1, shopSongOrder.getSongId());

View File

@ -9,6 +9,7 @@ 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.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.service.PayService;
import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService;
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
@ -20,6 +21,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -27,9 +30,7 @@ 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;
import java.util.*;
/**
* @author Administrator
@ -39,6 +40,7 @@ import java.util.Map;
@Service
public class TbShopSongServiceImpl implements TbShopSongService{
private static final Logger log = LoggerFactory.getLogger(TbShopSongServiceImpl.class);
private final RedisTemplate<String, Object> redisTemplate;
private final TbShopSongOrderService shopSongOrderService;
@ -65,19 +67,36 @@ public class TbShopSongServiceImpl implements TbShopSongService{
@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);
List<TbShopSong> shopSongs;
try {
shopSongs = shopSongMapper.selectAllAndSearch(shopId, keyWord);
}catch (Exception e) {
log.warn("查询歌曲列表出现异常", e);
shopSongs = new ArrayList<>();
}
return new PageInfo<>(shopSongs);
}
@Override
public Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc) {
public Object getRecord(String openId, Integer page, Integer size, Integer state, boolean isDesc, Integer shopId) {
PageHelper.startPage(page, size);
List<Map<String, Object>> songOrders = shopSongOrderMapper.selectByUserId(openId, state);
List<Map<String, Object>> songOrders;
if (state == null) {
songOrders = shopSongOrderMapper.selectActiveOrderByUserId(openId, shopId);
}else {
songOrders = shopSongOrderMapper.selectByUserId(openId, state, shopId);
}
LinkedHashMap<String, Integer> rank = new LinkedHashMap<>();
List<TbShopSongOrder> tbShopSongOrders = shopSongOrderMapper.selectWaitAll(shopId);
for (int i = 0; i < tbShopSongOrders.size(); i++) {
rank.put(tbShopSongOrders.get(i).getId().toString(), i);
}
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);
toMap.put("preCount", rank.get(String.valueOf(songOrders.get(i).get("orderId"))));
infos.add(toMap);
}
return new PageInfo<>(infos);
@ -99,8 +118,8 @@ public class TbShopSongServiceImpl implements TbShopSongService{
shopSongOrder.setClientType(0);
shopSongOrder.setSongName(song.getName());
shopSongOrder.setState(-1);
shopSongOrder.setFromName(shopSongOrder.getFromName());
shopSongOrder.setToName(shopSongOrder.getToName());
shopSongOrder.setFromName(songOrderDTO.getFromName());
shopSongOrder.setToName(songOrderDTO.getToName());
shopSongOrder.setNote(songOrderDTO.getNote());
shopSongOrder.setShopId(songOrderDTO.getShopId());
shopSongOrder.setPayMoney(song.getPrice());
@ -128,6 +147,20 @@ public class TbShopSongServiceImpl implements TbShopSongService{
}
return map;
}
@Override
public Object getSinging(String openId) {
Map<String, Object> map = shopSongOrderMapper.selectSinging();
if (map == null) {
return new HashMap<String, Object>(){{
put("songName", "");
put("id", "");
put("img", "");
}};
}else {
return map;
}
}
}

View File

@ -173,7 +173,7 @@ public class TaskScheduler {
return randomMilliseconds;
}
@Scheduled(fixedRate = 60000)
@Scheduled(fixedRate = 60000 * 60)
public void clearSongOrder() {
log.info("定时任务执行,清楚过期歌曲订单");
shopSongOrderService.clearExpireOrder();

View File

@ -0,0 +1,26 @@
package com.chaozhanggui.system.cashierservice.util;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class MQUtils {
private final RabbitTemplate rabbitTemplate;
public MQUtils(RabbitTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
}
private <T> void sendMsg(String exchange, String routingKey, T data, String note) {
log.info("开始发送{}mq消息, exchange: {}, routingKey: {}, data: {}", note, exchange, routingKey, data);
rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data));
}
public <T> void sendStockSaleMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
}
}

View File

@ -920,10 +920,28 @@
</update>
<select id="selectByIdIn" resultMap="BaseResultMap">
select *
from tb_product
where id in (${ids}) and is_show_mall =1 order by sort asc
select min( sku.suit ) as suit,tb.*
from tb_product tb
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
where tb.id in (${ids}) and is_show_mall =1 and sku.is_del = 0
group by tb.id
order by tb.sort asc
</select>
<select id="selectByIdInAndCheck" resultMap="BaseResultMap">
select min( sku.suit ) as suit,tb.*
from tb_product tb
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
where tb.id in (${ids}) and is_show_mall =1 and sku.is_del = 0 and sku.is_grounding=1
group by tb.id
order by tb.sort asc
</select>
<!-- <select id="selectByIdIn" resultMap="BaseResultMap">-->
<!-- select *-->
<!-- from tb_product-->
<!-- where id in (${ids}) and is_show_mall =1 order by sort asc-->
<!-- </select>-->
<select id="selectById" resultType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
select
<include refid="Base_Column_List" />

View File

@ -12,6 +12,7 @@
<result column="meal_price" jdbcType="DECIMAL" property="mealPrice" />
<result column="sale_price" jdbcType="DECIMAL" property="salePrice" />
<result column="guide_price" jdbcType="DECIMAL" property="guidePrice" />
<result column="suit" jdbcType="INTEGER" property="suit" />
<result column="strategy_price" jdbcType="DECIMAL" property="strategyPrice" />
<result column="stock_number" jdbcType="DOUBLE" property="stockNumber" />
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
@ -24,6 +25,8 @@
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="is_pause_sale" jdbcType="INTEGER" property="isPauseSale" />
<result column="is_del" jdbcType="INTEGER" property="isDel" />
<result column="is_grounding" jdbcType="INTEGER" property="isGrounding" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
<result column="spec_info" jdbcType="LONGVARCHAR" property="specInfo" />
@ -31,8 +34,8 @@
</resultMap>
<sql id="Base_Column_List">
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
sale_price, guide_price, strategy_price, stock_number, cover_img, warn_line, weight,
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale
sale_price, guide_price,suit, strategy_price, stock_number, cover_img, warn_line, weight,
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del,is_grounding
</sql>
<sql id="Blob_Column_List">
spec_info, spec_snap
@ -359,7 +362,7 @@
</update>
<select id="selectByShopIdAndProductIdAndSpec" resultMap="ResultMapWithBLOBs">
select * from tb_product_sku where shop_id=#{shopId} and product_id=#{productId}
select * from tb_product_sku where shop_id=#{shopId} and product_id=#{productId} and is_del = 0
<if test="spec != null and spec !=''">
and spec_snap = #{spec}

View File

@ -8,7 +8,7 @@
<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="openId" column="open_id" jdbcType="INTEGER"/>
<result property="openId" column="open_id" jdbcType="VARCHAR"/>
<result property="payMoney" column="pay_money" jdbcType="DECIMAL"/>
<result property="state" column="state" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@ -19,6 +19,7 @@
<result property="note" column="note" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="realMoney" column="real_money" jdbcType="DECIMAL"/>
<result property="payOrderId" column="pay_order_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
@ -26,7 +27,7 @@
open_id,pay_money,state,
create_time,client_type,order_no,
from_name,to_name,note,
shop_id,real_money
shop_id,real_money,pay_order_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@ -46,12 +47,14 @@
,open_id,pay_money,state
,create_time,client_type,order_no
,from_name,to_name,note
,shop_id,real_money)
,shop_id,real_money,pay_order_id
)
values (#{id,jdbcType=INTEGER},#{songId,jdbcType=INTEGER},#{songName,jdbcType=VARCHAR}
,#{openId,jdbcType=INTEGER},#{payMoney,jdbcType=DECIMAL},#{state,jdbcType=TINYINT}
,#{openId,jdbcType=VARCHAR},#{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})
,#{shopId,jdbcType=INTEGER},#{realMoney,jdbcType=DECIMAL},#{payOrderId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder" useGeneratedKeys="true">
insert into tb_shop_song_order
@ -70,12 +73,13 @@
<if test="note != null">note,</if>
<if test="shopId != null">shop_id,</if>
<if test="realMoney != null">real_money,</if>
<if test="payOrderId != null">pay_order_id,</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="openId != null">#{openId,jdbcType=INTEGER},</if>
<if test="openId != null">#{openId,jdbcType=VARCHAR},</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>
@ -86,6 +90,7 @@
<if test="note != null">#{note,jdbcType=VARCHAR},</if>
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="realMoney != null">#{realMoney,jdbcType=DECIMAL},</if>
<if test="payOrderId != null">#{payOrderId,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder">
@ -98,7 +103,7 @@
song_name = #{songName,jdbcType=VARCHAR},
</if>
<if test="openId != null">
open_id = #{openId,jdbcType=INTEGER},
open_id = #{openId,jdbcType=VARCHAR},
</if>
<if test="payMoney != null">
pay_money = #{payMoney,jdbcType=DECIMAL},
@ -130,6 +135,9 @@
<if test="realMoney != null">
real_money = #{realMoney,jdbcType=DECIMAL},
</if>
<if test="payOrderId != null">
pay_order_id = #{payOrderId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@ -138,7 +146,7 @@
set
song_id = #{songId,jdbcType=INTEGER},
song_name = #{songName,jdbcType=VARCHAR},
open_id = #{openId,jdbcType=INTEGER},
open_id = #{openId,jdbcType=VARCHAR},
pay_money = #{payMoney,jdbcType=DECIMAL},
state = #{state,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
@ -148,18 +156,8 @@
to_name = #{toName,jdbcType=VARCHAR},
note = #{note,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=INTEGER},
real_money = #{realMoney,jdbcType=DECIMAL}
real_money = #{realMoney,jdbcType=DECIMAL},
pay_order_id = #{payOrderId,jdbcType=VARCHAR}
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.open_id = #{openId}
AND a.id=#{id}
</select>
</mapper>

View File

@ -51,6 +51,15 @@
where telephone = #{phone,jdbcType=VARCHAR}
</select>
<select id="selectByShopIdAndPhone" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_user
where
shop_id=#{shopId}
and telephone = #{phone,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from tb_shop_user
where id = #{id,jdbcType=VARCHAR}
@ -397,6 +406,10 @@
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId}
</select>
<select id="selectPCByPhoneAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId} and user_id is null
</select>
<select id="selectAllByUserId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId}
</select>
@ -425,6 +438,7 @@
left join tb_shop_info i on u.shop_id=i.id
WHERE
u.user_id = #{userId}
and is_vip = 1
<if test="shopId != null and shopId !=''">
and shop_id = #{shopId}
</if>

View File

@ -585,7 +585,7 @@
<select id="selectByOpenId" resultMap="BaseResultMap">
select * from tb_user_info where mini_app_open_id=#{openId}
select * from tb_user_info where mini_app_open_id=#{openId} limit 1
</select>