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
33 changed files with 784 additions and 418 deletions

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")) {
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 Result.success(CodeEnum.SUCCESS, 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,15 +55,9 @@ 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);
}
String tradeNo=object.get("payOrderId").toString();
return payService.fstMemberInSuccess(orderNo,tradeNo);
}
}
}
@@ -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

@@ -82,82 +82,86 @@ public class UserContoller {
// return jsonObject;
// }
@GetMapping("/shopUserInfo")
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
TbShopUser shopUser=new TbShopUser();
public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception {
TbShopUser shopUser = new TbShopUser();
TbShopInfo tbShopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
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=new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.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(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
}else {
shopUser.setUserId(userId);
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.updateByPrimaryKey(shopUser);
}
// shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
// if(ObjectUtil.isEmpty(shopUser)){
shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.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(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
// }else {
// shopUser.setUserId(userId);
// shopUser.setUpdatedAt(System.currentTimeMillis());
// shopUserMapper.updateByPrimaryKey(shopUser);
// }
}
}else {
} else {
shopUser.setAmount(BigDecimal.ZERO);
}
shopUser.setShopName(tbShopInfo.getShopName());
return Result.success(CodeEnum.SUCCESS,shopUser);
if (tbShopInfo != null) {
shopUser.setShopName(tbShopInfo.getShopName());
}else {
shopUser.setShopName("");
}
return Result.success(CodeEnum.SUCCESS, shopUser);
}
@GetMapping("/userCoupon")
public Result userCoupon(@RequestParam("userId") String userId ,@RequestParam("orderNum") BigDecimal orderNum ) throws Exception {
int num = userService.userCoupon(userId,orderNum);
return Result.success(CodeEnum.SUCCESS,num);
public Result userCoupon(@RequestParam("userId") String userId, @RequestParam("orderNum") BigDecimal orderNum) throws Exception {
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 {
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);
return userService.modityIntegral(integralVo, userSign);
}
@PostMapping("/userIntegral")
public JSONObject userIntegral(@RequestHeader String token,@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
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);
return userService.userIntegral(integralFlowVo, userSign);
}
@PostMapping("/userAllIntegral")
public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
// String userSign = jsonObject.getString("userSign");
return userService.userAllIntegral(integralFlowVo,"userSign");
return userService.userAllIntegral(integralFlowVo, "userSign");
}
@PostMapping("/userAll")
public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
// String userSign = jsonObject.getString("userSign");
return userService.userAll(integralFlowVo,"userSign");
return userService.userAll(integralFlowVo, "userSign");
}
}