web socket
支付 会员
This commit is contained in:
@@ -21,7 +21,7 @@ public class OtherHandler extends Handler{
|
||||
|
||||
//传送给对应tableId用户的websocket
|
||||
if (StringUtils.isNotBlank(webSocke.getTableId()) && webSocketMap.containsKey(webSocke.getTableId())) {
|
||||
AppSendInfo("1", webSocke.getTableId(),false);
|
||||
AppSendInfo("1", webSocke.getTableId(),"",false);
|
||||
|
||||
} else {
|
||||
System.out.println("请求的tableId:" + webSocke.getTableId() + "不在该服务器上");
|
||||
|
||||
@@ -160,5 +160,12 @@ public class PayController {
|
||||
return payService.getShopByMember(userId,shopId,page,pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping("queryMemberAccount")
|
||||
public Result queryMemberAccount(@RequestParam("memberId") String memberId,
|
||||
@RequestParam(value = "page", defaultValue = "1") int page,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
|
||||
) {
|
||||
return payService.queryMemberAccount(memberId, page, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
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.TbMerchantAccountMapper;
|
||||
@@ -79,9 +80,17 @@ public class UserContoller {
|
||||
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
|
||||
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||
if (ObjectUtil.isEmpty(shopUser)) {
|
||||
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
shopUser = new TbShopUser();
|
||||
shopUser.setName(tbUserInfo.getNickName());
|
||||
shopUser.setSex(tbUserInfo.getSex());
|
||||
shopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
shopUser.setLevel(Byte.parseByte("1"));
|
||||
String code= RandomUtil.randomNumbers(6);
|
||||
shopUser.setCode(code);
|
||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
shopUser.setIsVip(Byte.parseByte("0"));
|
||||
shopUser.setIsVip(Byte.parseByte("1"));
|
||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeNumber(0);
|
||||
|
||||
@@ -19,6 +19,7 @@ public interface TbShopUserMapper {
|
||||
int insertSelective(TbShopUser record);
|
||||
|
||||
TbShopUser selectByPrimaryKey(String id);
|
||||
List<TbShopUser> selectByPhone(String phone);
|
||||
|
||||
int updateByPrimaryKeySelective(TbShopUser record);
|
||||
|
||||
|
||||
@@ -55,10 +55,9 @@ public class CartService {
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public void createCart(JSONObject jsonObject) throws Exception {
|
||||
try {
|
||||
|
||||
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String key=tableId+"-"+shopId;
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
boolean exist = redisUtil.exists(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"));
|
||||
@@ -67,7 +66,7 @@ public class CartService {
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品库存已售罄");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, key,jsonObject.getString("userId"), true);
|
||||
throw new MsgException("该商品库存已售罄");
|
||||
}
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
@@ -77,7 +76,7 @@ public class CartService {
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品库存已售罄");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
throw new MsgException("该商品库存已售罄");
|
||||
}
|
||||
} else {
|
||||
@@ -143,7 +142,7 @@ public class CartService {
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", jsonArray);
|
||||
jsonObject1.put("amount", amount);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
@@ -151,12 +150,13 @@ public class CartService {
|
||||
|
||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||
String key=tableId+"-"+shopId;
|
||||
if (Objects.isNull(product)) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品不存在");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, userId.toString(), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
||||
throw new MsgException("该商品不存在");
|
||||
}
|
||||
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
@@ -165,7 +165,7 @@ public class CartService {
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品规格不存在");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, userId.toString(), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, userId.toString(), true);
|
||||
throw new MsgException("该商品规格不存在");
|
||||
}
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
@@ -196,8 +196,11 @@ public class CartService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createOrder(JSONObject jsonObject) throws Exception {
|
||||
public void createOrder(JSONObject jsonObject) {
|
||||
try {
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
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<>();
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
@@ -263,7 +266,7 @@ public class CartService {
|
||||
String isBuyYhq = "false";
|
||||
String isuseYhq = "false";
|
||||
if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) {
|
||||
couponId =jsonObject.getString("couponsId");
|
||||
couponId = jsonObject.getString("couponsId");
|
||||
//1:购买优惠券,0:自己持有优惠券
|
||||
Integer couponsId = jsonObject.getInteger("couponsId");
|
||||
if (jsonObject.getString("isBuyYhq").equals("1")) {
|
||||
@@ -275,7 +278,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "优惠券已售空");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -286,7 +289,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单金额小于优惠价金额");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -314,7 +317,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "优惠券已使用");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -325,7 +328,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单金额小于优惠价金额");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -347,7 +350,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单正在支付中,请稍后再试");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -398,7 +401,7 @@ public class CartService {
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
JSONObject jsonObject12 = new JSONObject();
|
||||
jsonObject12.put("status", "success");
|
||||
jsonObject12.put("msg", "成功");
|
||||
@@ -406,7 +409,10 @@ public class CartService {
|
||||
jsonObject12.put("amount", BigDecimal.ZERO);
|
||||
|
||||
jsonObject12.put("data", new JSONArray());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private TbOrderInfo getOrder(BigDecimal totalAmount, BigDecimal packAMount,
|
||||
@@ -468,13 +474,15 @@ public class CartService {
|
||||
jsonObject1.put("type", "clearCart");
|
||||
jsonObject1.put("amount", BigDecimal.ZERO);
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void pendingOrder(JSONObject jsonObject) throws IOException {
|
||||
try {
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
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<>();
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
@@ -540,7 +548,7 @@ public class CartService {
|
||||
String isBuyYhq = "false";
|
||||
String isuseYhq = "false";
|
||||
if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) {
|
||||
couponId =jsonObject.getString("couponsId");
|
||||
couponId = jsonObject.getString("couponsId");
|
||||
//1:购买优惠券,0:自己持有优惠券
|
||||
Integer couponsId = jsonObject.getInteger("couponsId");
|
||||
if (jsonObject.getString("isBuyYhq").equals("1")) {
|
||||
@@ -552,7 +560,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "优惠券已售空");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +571,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单金额小于优惠价金额");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -591,7 +599,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "优惠券已使用");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -602,7 +610,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单金额小于优惠价金额");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -624,7 +632,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "订单正在支付中,请稍后再试");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -675,8 +683,8 @@ public class CartService {
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
|
||||
redisUtil.saveMessage(RedisCst.TABLE_ORDER.concat(orderInfo.getOrderNo()),JSONObject.toJSONString(orderInfo),24*60*60);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
|
||||
redisUtil.saveMessage(RedisCst.TABLE_ORDER.concat(orderInfo.getOrderNo()), JSONObject.toJSONString(orderInfo), 24 * 60 * 60);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, jsonObject.getString("userId"), true);
|
||||
JSONObject jsonObject12 = new JSONObject();
|
||||
jsonObject12.put("status", "success");
|
||||
jsonObject12.put("msg", "成功");
|
||||
@@ -684,7 +692,7 @@ public class CartService {
|
||||
jsonObject12.put("amount", BigDecimal.ZERO);
|
||||
|
||||
jsonObject12.put("data", new JSONArray());
|
||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
@@ -697,7 +705,7 @@ public class CartService {
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
}
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
@@ -705,6 +713,6 @@ public class CartService {
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", array);
|
||||
jsonObject1.put("amount", amount);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId),"", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.MD5Utils;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -65,9 +67,9 @@ public class LoginService {
|
||||
userInfo.setConsumeAmount(BigDecimal.ZERO);
|
||||
userInfo.setTotalScore(0);
|
||||
userInfo.setLockScore(0);
|
||||
userInfo.setHeadImg(ObjectUtil.isNotNull(headImage) ? headImage : "");
|
||||
userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");
|
||||
userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
|
||||
userInfo.setTelephone(ObjectUtil.isNotNull(telephone) ? telephone : "");
|
||||
userInfo.setTelephone(telephone);
|
||||
userInfo.setMiniAppOpenId(openId);
|
||||
userInfo.setStatus(Byte.parseByte("1"));
|
||||
userInfo.setParentType("PERSON");
|
||||
@@ -82,13 +84,39 @@ public class LoginService {
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
userInfo.setCreatedAt(System.currentTimeMillis());
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
|
||||
if(CollectionUtils.isEmpty(tbShopUsers)){
|
||||
for (TbShopUser tbShopUser : tbShopUsers) {
|
||||
userInfo.setNickName(tbShopUser.getName());
|
||||
userInfo.setSex(tbShopUser.getSex());
|
||||
userInfo.setBirthDay(tbShopUser.getBirthDay());
|
||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
||||
tbShopUser.setCode(dynamicCode);
|
||||
tbShopUser.setUserId(userInfo.getId() + "");
|
||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||
}
|
||||
}
|
||||
tbUserInfoMapper.insert(userInfo);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
userInfo.setSearchWord(userInfo.getSearchWord() + "||微信用户");
|
||||
userInfo.setMiniAppOpenId(openId);
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
|
||||
}
|
||||
}else {
|
||||
String phone = userInfo.getTelephone();
|
||||
if (StringUtils.isBlank(phone) || !phone.equals(telephone)) {
|
||||
userInfo.setTelephone(telephone);
|
||||
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
|
||||
}else {
|
||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
|
||||
for (TbShopUser tbShopUser : tbShopUsers) {
|
||||
tbShopUser.setTelephone(phone);
|
||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成token 信息
|
||||
String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());
|
||||
@@ -105,7 +133,7 @@ public class LoginService {
|
||||
//展示描述
|
||||
//图标
|
||||
// map.put("", );
|
||||
// log.info("登录结果:"+ JSONUtil.toJSONString(map));
|
||||
log.info("登录结果:" + JSONUtil.toJSONString(map));
|
||||
return Result.success(CodeEnum.SUCCESS, map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -149,9 +177,19 @@ public class LoginService {
|
||||
if (StringUtils.isNotBlank(password)) {
|
||||
userInfo.setPassword(MD5Utils.MD5Encode(password, "UTF-8"));
|
||||
}
|
||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(phone);
|
||||
for (TbShopUser tbShopUser : tbShopUsers) {
|
||||
userInfo.setNickName(tbShopUser.getName());
|
||||
userInfo.setSex(tbShopUser.getSex());
|
||||
userInfo.setBirthDay(tbShopUser.getBirthDay());
|
||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
||||
String code= RandomUtil.randomNumbers(6);
|
||||
tbShopUser.setCode(code);
|
||||
tbShopUser.setUserId(userInfo.getId() + "");
|
||||
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
|
||||
}
|
||||
tbUserInfoMapper.insert(userInfo);
|
||||
TbUserInfo appUser = tbUserInfoMapper.selectByPhone(phone);
|
||||
return appUser;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,9 +219,9 @@ public class LoginService {
|
||||
return Result.fail("暂未设置密码,请使用验证码登录");
|
||||
}
|
||||
userInfo = register(username, password, username);
|
||||
}else {
|
||||
} else {
|
||||
String searchWord = userInfo.getSearchWord();
|
||||
if(!searchWord.contains("移动端用户")){
|
||||
if (!searchWord.contains("移动端用户")) {
|
||||
userInfo.setSearchWord(userInfo.getSearchWord() + "||移动端用户");
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
|
||||
@@ -257,12 +295,12 @@ public class LoginService {
|
||||
return Result.success(CodeEnum.ENCRYPT, tbUserInfo);
|
||||
}
|
||||
|
||||
public Result upPass(String userId,String oldPass,String newPass) {
|
||||
public Result upPass(String userId, String oldPass, String newPass) {
|
||||
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(!tbUserInfo.getPassword().equals(oldPass)){
|
||||
if (!tbUserInfo.getPassword().equals(oldPass)) {
|
||||
return Result.success(CodeEnum.FAIL_OLDPASS);
|
||||
}
|
||||
if(tbUserInfo.getPassword().equals(newPass)){
|
||||
if (tbUserInfo.getPassword().equals(newPass)) {
|
||||
return Result.success(CodeEnum.FAIL_NEWPASS);
|
||||
}
|
||||
tbUserInfo.setPassword(newPass);
|
||||
@@ -275,19 +313,19 @@ public class LoginService {
|
||||
}
|
||||
|
||||
|
||||
public Result resetPwd(String userId,Map<String,Object> map){
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("pwd")
|
||||
||ObjectUtil.isEmpty(map.get("pwd"))||!map.containsKey("code")
|
||||
||ObjectUtil.isEmpty(map.get("code"))
|
||||
){
|
||||
public Result resetPwd(String userId, Map<String, Object> map) {
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("pwd")
|
||||
|| ObjectUtil.isEmpty(map.get("pwd")) || !map.containsKey("code")
|
||||
|| ObjectUtil.isEmpty(map.get("code"))
|
||||
) {
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
|
||||
TbUserInfo userInfo=tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
boolean flag= validate(map.get("code").toString(), userInfo.getTelephone());
|
||||
if(!flag){
|
||||
return Result.fail("验证码错误");
|
||||
}
|
||||
TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
boolean flag = validate(map.get("code").toString(), userInfo.getTelephone());
|
||||
if (!flag) {
|
||||
return Result.fail("验证码错误");
|
||||
}
|
||||
|
||||
|
||||
userInfo.setIsPwd("1");
|
||||
@@ -295,26 +333,25 @@ public class LoginService {
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKey(userInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result modifyPwd(String userId,Map<String,Object> map){
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("pwd")
|
||||
||ObjectUtil.isEmpty(map.get("pwd"))||!map.containsKey("oldpwd")
|
||||
||ObjectUtil.isEmpty(map.get("oldpwd"))
|
||||
){
|
||||
public Result modifyPwd(String userId, Map<String, Object> map) {
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("pwd")
|
||||
|| ObjectUtil.isEmpty(map.get("pwd")) || !map.containsKey("oldpwd")
|
||||
|| ObjectUtil.isEmpty(map.get("oldpwd"))
|
||||
) {
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
|
||||
TbUserInfo userInfo=tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(ObjectUtil.isEmpty(userInfo)||ObjectUtil.isNull(userInfo)){
|
||||
TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if (ObjectUtil.isEmpty(userInfo) || ObjectUtil.isNull(userInfo)) {
|
||||
return Result.fail("用户基本信息不存在");
|
||||
}
|
||||
|
||||
if(!userInfo.getPwd().equals(MD5Utils.md5(map.get("oldpwd").toString()))){
|
||||
if (!userInfo.getPwd().equals(MD5Utils.md5(map.get("oldpwd").toString()))) {
|
||||
return Result.fail("用户旧密码错误");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -232,7 +233,7 @@ public class PayService {
|
||||
jsonObject1.put("type", "");
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, "",false);
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),"final");
|
||||
return Result.success(CodeEnum.SUCCESS,object.getJSONObject("data"));
|
||||
}else {
|
||||
@@ -271,7 +272,7 @@ public class PayService {
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, false);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, "",false);
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),"final");
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
||||
@@ -335,7 +336,7 @@ public class PayService {
|
||||
return Result.failCode("会员卡余额不足","1");
|
||||
}
|
||||
|
||||
if (N.gt(orderInfo.getPayAmount(), user.getAmount())) {
|
||||
if (N.gt(orderInfo.getOrderAmount(), user.getAmount())) {
|
||||
return Result.failCode("会员卡余额不足","2");
|
||||
}
|
||||
|
||||
@@ -428,18 +429,26 @@ public class PayService {
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayType("deposit");
|
||||
for (int i = 0; i < orderInfo.getNumber(); i++) {
|
||||
TbGroupOrderCoupon groupOrderCoupon = new TbGroupOrderCoupon();
|
||||
groupOrderCoupon.setOrderId(orderInfo.getId());
|
||||
groupOrderCoupon.setCouponNo(genCouponNumber());
|
||||
groupOrderCoupon.setIsRefund(0);
|
||||
groupOrderCouponService.insert(groupOrderCoupon);
|
||||
}
|
||||
orderInfo.setExpDate(getNextMonDate());
|
||||
//修改主单状态
|
||||
orderInfo.setStatus("unused");
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayTime(new Date());
|
||||
orderInfo.setPayType("deposit");
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("token", "");
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", orderId);
|
||||
//
|
||||
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type", "groupCreate");
|
||||
jsonObject.put("orderId", orderId);
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
else {
|
||||
@@ -480,7 +489,8 @@ public class PayService {
|
||||
payment.setOrderId(orderInfo.getOrderNo());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.insert(payment);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (payType.equals("wechatPay")) {
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
@@ -520,20 +530,14 @@ public class PayService {
|
||||
orderInfo.setPayType(payType);
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
jsonObject1.put("msg", "成功");
|
||||
jsonObject1.put("type", "");
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
} else {
|
||||
return Result.fail("支付失败");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("支付金额为");
|
||||
}
|
||||
else {
|
||||
String reqbody="";
|
||||
|
||||
if(body.length()>15){
|
||||
@@ -568,12 +572,6 @@ public class PayService {
|
||||
orderInfo.setPayType(payType);
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
jsonObject1.put("msg", "成功");
|
||||
jsonObject1.put("type", "");
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
||||
@@ -966,6 +964,17 @@ public class PayService {
|
||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||
}
|
||||
|
||||
public Result queryMemberAccount(String memberId,int page, int pageSize){
|
||||
if(StringUtils.isBlank(memberId)){
|
||||
return Result.fail("会员编号不许为空");
|
||||
}
|
||||
PageHelper.startPage(page,pageSize);
|
||||
List<Map<String,Object>> list=tbShopUserFlowMapper.selectByMemberAccountFlow(memberId);
|
||||
PageInfo pageInfo=new PageInfo(list);
|
||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1154,48 +1163,48 @@ public class PayService {
|
||||
// }
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
RestTemplate restTemplate1= new RestTemplate();
|
||||
JSONObject param=new JSONObject();
|
||||
|
||||
String priv="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIqNqTqhN8zE7eFZnwKcyBTENce2wdAtl/gaDHNuNVgg33dS27Jx0fKl9QSHXyzyxbAdG8F94niYbRBstrMymFRjuO72jH+rIH62Ym1k7l8JSLVK2dKHXt8lHDaQGUP10q0EEocnDQ9cL93oBNG1ttsV6vOAu1TPvRK9TGihRAe1AgMBAAECgYBmI8KCl0DkcrSOsRvYuC2DqZWf8el1B3eFjeZp3e/zVOCIPYv6Q5ArWg6DVSxjnWEA0KSagqvGjU+xkQMqnXzPcPMhsIS+1wyR/pP+pwiatO2ioHaQpEqHg9eXhxrgA477/xuKVw9zl5GNqaIgd++2NDXnqLh0Y6OR73f0OB5eDQJBAPihEm+UWLOam/Q/k2+k4Lm2dvxJTBur1fslBiJpgMhgcz/PlwRwpL7aPD0AuPv0NqLouuoTiKpq9icnUv12tgsCQQCOqTANw0IErCHUNdinjXewmG3ui1j9XgM41rSn5ZeTrPL4GhZc2zbS/pZT4PBKUL6NLGkfPHmw4rOmNL/Xc5E/AkBqAwQBX5eSvVHSC2mqKPtJNGv3lqlFAzfyJg8/jQzEY5vAkZsq4Xzdg+A7gptdkvvY6rMIK9wSDhl3CGVyfbORAkA1N+g1OiHmnFACWhP4bU25EyPvWQxZeDi7e1zpRTzGWj5JT3IIMb7B9zcdE0yQbI6pG2gbvvOmiOt7lTH7raEBAkBas2gugvR3f0aGqQcqMpyM627pyRppQ2h58/7KBylP3oR2BReqMUcXeiJ8TuBXzbRXpeVQ0DWOva5CWZJmBMdz";
|
||||
|
||||
PayReq req=new PayReq();
|
||||
|
||||
req.setAppId("M8002023120892f1e4");
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setIp("127.0.0.1");
|
||||
req.setMercOrderNo(System.currentTimeMillis()+"");
|
||||
req.setNotifyUrl("https");
|
||||
req.setPayAmt("0.01");
|
||||
req.setPayType("03");
|
||||
req.setPayWay("WXZF");
|
||||
req.setSubject("ddd");
|
||||
req.setUserId("or1l864NBOoJZhC5x_yeziZ26j6c");
|
||||
|
||||
Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
|
||||
req.setSign(MD5Util.encrypt(map,priv,true));
|
||||
|
||||
|
||||
ResponseEntity<String> response= restTemplate1.postForEntity("https://gatewaytestapi.sxczgkj.cn/gate-service/trans/pay",req,String.class);
|
||||
|
||||
|
||||
|
||||
// TradeQueryReq req=new TradeQueryReq();
|
||||
// req.setAppId("M800202305094c170c");
|
||||
// public static void main(String[] args){
|
||||
//
|
||||
// RestTemplate restTemplate1= new RestTemplate();
|
||||
// JSONObject param=new JSONObject();
|
||||
//
|
||||
// String priv="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIqNqTqhN8zE7eFZnwKcyBTENce2wdAtl/gaDHNuNVgg33dS27Jx0fKl9QSHXyzyxbAdG8F94niYbRBstrMymFRjuO72jH+rIH62Ym1k7l8JSLVK2dKHXt8lHDaQGUP10q0EEocnDQ9cL93oBNG1ttsV6vOAu1TPvRK9TGihRAe1AgMBAAECgYBmI8KCl0DkcrSOsRvYuC2DqZWf8el1B3eFjeZp3e/zVOCIPYv6Q5ArWg6DVSxjnWEA0KSagqvGjU+xkQMqnXzPcPMhsIS+1wyR/pP+pwiatO2ioHaQpEqHg9eXhxrgA477/xuKVw9zl5GNqaIgd++2NDXnqLh0Y6OR73f0OB5eDQJBAPihEm+UWLOam/Q/k2+k4Lm2dvxJTBur1fslBiJpgMhgcz/PlwRwpL7aPD0AuPv0NqLouuoTiKpq9icnUv12tgsCQQCOqTANw0IErCHUNdinjXewmG3ui1j9XgM41rSn5ZeTrPL4GhZc2zbS/pZT4PBKUL6NLGkfPHmw4rOmNL/Xc5E/AkBqAwQBX5eSvVHSC2mqKPtJNGv3lqlFAzfyJg8/jQzEY5vAkZsq4Xzdg+A7gptdkvvY6rMIK9wSDhl3CGVyfbORAkA1N+g1OiHmnFACWhP4bU25EyPvWQxZeDi7e1zpRTzGWj5JT3IIMb7B9zcdE0yQbI6pG2gbvvOmiOt7lTH7raEBAkBas2gugvR3f0aGqQcqMpyM627pyRppQ2h58/7KBylP3oR2BReqMUcXeiJ8TuBXzbRXpeVQ0DWOva5CWZJmBMdz";
|
||||
//
|
||||
// PayReq req=new PayReq();
|
||||
//
|
||||
// req.setAppId("M8002023120892f1e4");
|
||||
// req.setTimestamp(System.currentTimeMillis());
|
||||
// req.setOrderNumber("SXF_W_MERC_20240205182102491");
|
||||
// req.setIp("127.0.0.1");
|
||||
// req.setMercOrderNo(System.currentTimeMillis()+"");
|
||||
// req.setNotifyUrl("https");
|
||||
// req.setPayAmt("0.01");
|
||||
// req.setPayType("03");
|
||||
// req.setPayWay("WXZF");
|
||||
// req.setSubject("ddd");
|
||||
// req.setUserId("or1l864NBOoJZhC5x_yeziZ26j6c");
|
||||
//
|
||||
// Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
//
|
||||
// req.setSign(MD5Util.encrypt(map,priv,true));
|
||||
//
|
||||
// ResponseEntity<String> response= restTemplate1.postForEntity("https://gateway.api.sxczgkj.cn/gate-service/merchantOrder/tradeQuery",req,String.class);
|
||||
//
|
||||
// ResponseEntity<String> response= restTemplate1.postForEntity("https://gatewaytestapi.sxczgkj.cn/gate-service/trans/pay",req,String.class);
|
||||
//
|
||||
//
|
||||
System.out.println(">>>>>>>>>>>>>>>"+response.getBody());
|
||||
}
|
||||
//
|
||||
//// TradeQueryReq req=new TradeQueryReq();
|
||||
//// req.setAppId("M800202305094c170c");
|
||||
//// req.setTimestamp(System.currentTimeMillis());
|
||||
//// req.setOrderNumber("SXF_W_MERC_20240205182102491");
|
||||
//// Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
////
|
||||
//// req.setSign(MD5Util.encrypt(map,priv,true));
|
||||
////
|
||||
//// ResponseEntity<String> response= restTemplate1.postForEntity("https://gateway.api.sxczgkj.cn/gate-service/merchantOrder/tradeQuery",req,String.class);
|
||||
////
|
||||
////
|
||||
// System.out.println(">>>>>>>>>>>>>>>"+response.getBody());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
@@ -64,6 +65,8 @@ public class ProductService {
|
||||
|
||||
@Autowired
|
||||
private TbShopUserMapper tbShopUserMapper;
|
||||
@Autowired
|
||||
private TbUserInfoMapper tbUserInfoMapper;
|
||||
|
||||
public Result queryShopIdByTableCode(String userId,String openId,String code) {
|
||||
String shopId = tbShopTableMapper.queryShopIdByTableCode(code);
|
||||
@@ -73,9 +76,16 @@ public class ProductService {
|
||||
|
||||
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
if (ObjectUtil.isEmpty(tbShopUser)) {
|
||||
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
tbShopUser = new TbShopUser();
|
||||
tbShopUser.setName(tbUserInfo.getNickName());
|
||||
tbShopUser.setSex(tbUserInfo.getSex());
|
||||
tbShopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
tbShopUser.setLevel(Byte.parseByte("1"));
|
||||
tbShopUser.setCode(RandomUtil.randomNumbers(6));
|
||||
tbShopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
tbShopUser.setAmount(BigDecimal.ZERO);
|
||||
tbShopUser.setIsVip(Byte.parseByte("0"));
|
||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||
tbShopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
tbShopUser.setConsumeNumber(0);
|
||||
|
||||
@@ -11,7 +11,7 @@ public enum CodeEnum {
|
||||
FAIL_OLDPASS("1",false,"修改失败,旧密码错误","fail"),
|
||||
FAIL_NEWPASS("1",false,"新密码不能与旧密码相同","fail"),
|
||||
TOKEN_EXEIST("-4",false,"token不能为空","fail"),
|
||||
TOKEN_EXPIRED("-4",false,"账号已过期,请重新登陆","fail"),
|
||||
TOKEN_EXPIRED("-4",false,"请先登陆","fail"),
|
||||
SIGN_FAIL("100013",false,"签名不正确","fail"),
|
||||
|
||||
ORGAN_NO_EXEIST("100010",false,"机构代码不存在或状态异常,请联系服务商","fail"),
|
||||
|
||||
@@ -53,6 +53,18 @@ public class Result {
|
||||
|
||||
}
|
||||
|
||||
// public Result(String msg, Object data, String code, boolean encrypt, String icon) {
|
||||
// this.msg = msg;
|
||||
// this.code = code;
|
||||
// this.encrypt = encrypt;
|
||||
// this.icon = icon;
|
||||
// if(encrypt){
|
||||
// this.data= DESUtil.encode(JSONUtil.toJsonStr(data));
|
||||
// }else{
|
||||
// this.data=data;
|
||||
// }
|
||||
// }
|
||||
|
||||
public Result(CodeEnum enums) {
|
||||
this.msg = enums.getMsg();
|
||||
this.encrypt = enums.getEncrypt();
|
||||
|
||||
@@ -54,9 +54,9 @@ public class AppWebSocketServer {
|
||||
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
|
||||
*/
|
||||
//一个 AppWebSocketServer 就是一个用户,一个tableId下有一个 List<AppWebSocketServer> 也就是多个用户
|
||||
private static ConcurrentHashMap<String, List<AppWebSocketServer>> webSocketMap = new ConcurrentHashMap<>();
|
||||
private static HashMap<String, ConcurrentHashMap<String, AppWebSocketServer>> webSocketMap = new HashMap<>();
|
||||
public static ConcurrentHashMap<String, Set<String>> userMap = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = new ConcurrentHashMap<>();
|
||||
// private static ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = new ConcurrentHashMap<>();
|
||||
//购物车的记录,用于第一次扫码的人同步购物车
|
||||
private static ConcurrentHashMap<String, List<JSONObject>> recordMap = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<String, Session> sessionMap = new ConcurrentHashMap<>();
|
||||
@@ -86,12 +86,13 @@ public class AppWebSocketServer {
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("tableId") String tableId, @PathParam("shopId") String shopId, @PathParam("userId") String userId) {
|
||||
log.info("建立连接参数 tableId:{} shopId:{} userId:{}",tableId,shopId,userId);
|
||||
this.session = session;
|
||||
this.tableId = tableId;
|
||||
this.shopId = shopId;
|
||||
this.userId = userId;
|
||||
log.info("链接桌码:"+tableId);
|
||||
try {
|
||||
String key=tableId + "-" + shopId;
|
||||
TbShopTable shopTable = shopTableMapper.selectQRcode(tableId);
|
||||
if (Objects.isNull(shopTable)) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
@@ -103,27 +104,26 @@ public class AppWebSocketServer {
|
||||
sendMessage(jsonObject1);
|
||||
onClose();
|
||||
}
|
||||
if (webSocketMap.containsKey(tableId + "-" + shopId)) {
|
||||
List<AppWebSocketServer> serverList = webSocketMap.get(tableId + "-" + shopId);
|
||||
serverList.add(this);
|
||||
|
||||
if (webSocketMap.containsKey(key)) {
|
||||
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(key);
|
||||
// 在放置新条目之前检查并清除同名userId的数据
|
||||
userSocketMap.put(userId,this);
|
||||
} else {
|
||||
List<AppWebSocketServer> serverList = new ArrayList<>();
|
||||
serverList.add(this);
|
||||
webSocketMap.put(tableId + "-" + shopId, serverList);
|
||||
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap=new ConcurrentHashMap<>();
|
||||
userSocketMap.put(userId,this);
|
||||
webSocketMap.put(key,userSocketMap);
|
||||
}
|
||||
if (userMap.containsKey(tableId + "-" + shopId)) {
|
||||
Set<String> userSet = userMap.get(tableId + "-" + shopId);
|
||||
|
||||
if (userMap.containsKey(key)) {
|
||||
Set<String> userSet = userMap.get(key);
|
||||
userSet.add(userId);
|
||||
} else {
|
||||
Set<String> userSet = new HashSet<>();
|
||||
userSet.add(userId);
|
||||
userMap.put(tableId + "-" + shopId,userSet);
|
||||
userMap.put(key,userSet);
|
||||
}
|
||||
|
||||
userSocketMap.put(userId, this);
|
||||
// sessionMap.put(userId,session);
|
||||
String mes = redisUtils.getMessage(RedisCst.TABLE_CART.concat(tableId + "-" + shopId));
|
||||
String mes = redisUtils.getMessage(RedisCst.TABLE_CART.concat(key));
|
||||
if (StringUtils.isEmpty(mes)) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
@@ -138,7 +138,7 @@ public class AppWebSocketServer {
|
||||
jsonObject1.put("msg", "成功");
|
||||
jsonObject1.put("type", "addCart");
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
JSONArray jsonArray = JSON.parseArray(redisUtils.getMessage(RedisCst.TABLE_CART.concat(tableId + "-" + shopId)));
|
||||
JSONArray jsonArray = JSON.parseArray(redisUtils.getMessage(RedisCst.TABLE_CART.concat(key)));
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
amount = amount.add(object.getBigDecimal("totalAmount"));
|
||||
@@ -157,14 +157,13 @@ public class AppWebSocketServer {
|
||||
* 连接关闭调用的方法
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose() {
|
||||
if (webSocketMap.containsKey(tableId + "-" + shopId)) {
|
||||
List<AppWebSocketServer> serverList = webSocketMap.get(tableId + "-" + shopId);
|
||||
if (serverList.isEmpty()) {
|
||||
webSocketMap.remove(tableId + "-" + shopId);
|
||||
}
|
||||
serverList.remove(this);
|
||||
|
||||
public void onClose() throws IOException {
|
||||
String key=tableId + "-" + shopId;
|
||||
log.info("触发关闭操作 key为:{} userId为:{}",key,userId);
|
||||
if (webSocketMap.containsKey(key)) {
|
||||
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(key);
|
||||
// 在放置新条目之前检查并清除同名userId的数据
|
||||
userSocketMap.remove(userId);
|
||||
}
|
||||
if (userMap.containsKey(tableId + "-" + shopId)){
|
||||
Set<String> userSet = userMap.get(tableId + "-" + shopId);
|
||||
@@ -174,10 +173,7 @@ public class AppWebSocketServer {
|
||||
userSet.remove(userId);
|
||||
}
|
||||
}
|
||||
public static void onClosed(String user) throws IOException {
|
||||
Session session1 = sessionMap.get(user);
|
||||
session1.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到客户端消息后调用的方法
|
||||
*
|
||||
@@ -246,9 +242,8 @@ public class AppWebSocketServer {
|
||||
* @param error
|
||||
*/
|
||||
@OnError
|
||||
public void onError(Session session, Throwable error) {
|
||||
public void onError(Session session, Throwable error) throws IOException {
|
||||
log.error("用户错误:" + this.tableId + ",原因:" + error.getMessage());
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,29 +269,35 @@ public class AppWebSocketServer {
|
||||
* 发送自定义消息
|
||||
*
|
||||
* @param message 发送的信息
|
||||
* @param tableId 如果为null默认发送所有
|
||||
* @param tableId 如果为null默认发送所有 tableId-shopId(桌码-店铺ID)
|
||||
* @param userId userFlag为 true时 必填
|
||||
* @param userFlag true 发送给指定用户 false 群发
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void AppSendInfo(Object message, String tableId, boolean userFlag) throws IOException {
|
||||
public static void AppSendInfo(Object message, String tableId,String userId, boolean userFlag) throws IOException {
|
||||
log.info("发送消息 tableId:{} \n userFlag:{}\n message:{}",tableId,userFlag,JSONUtil.toJSONString(message));
|
||||
if (userFlag) {
|
||||
if (userSocketMap.containsKey(tableId)) {
|
||||
AppWebSocketServer server = userSocketMap.get(tableId);
|
||||
server.sendMessage(message);
|
||||
} else {
|
||||
log.error("请求的userId:" + tableId + "不在该服务器上");
|
||||
if (webSocketMap.containsKey(tableId)) {
|
||||
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId);
|
||||
if(StringUtils.isNotBlank(userId)){
|
||||
userSocketMap.get(userId).sendMessage(message);
|
||||
}
|
||||
}else {
|
||||
log.error("请求的tableId:"+tableId+" userId:" + userId + "不在该服务器上");
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isEmpty(tableId)) {
|
||||
// 向所有用户发送信息
|
||||
for (List<AppWebSocketServer> serverList : webSocketMap.values()) {
|
||||
for (AppWebSocketServer server : serverList) {
|
||||
for (ConcurrentHashMap<String, AppWebSocketServer> value : webSocketMap.values()) {
|
||||
for (AppWebSocketServer server : value.values()) {
|
||||
server.sendMessage(message);
|
||||
}
|
||||
}
|
||||
} else if (webSocketMap.containsKey(tableId)) {
|
||||
// 发送给指定用户信息
|
||||
List<AppWebSocketServer> serverList = webSocketMap.get(tableId);
|
||||
for (AppWebSocketServer server : serverList) {
|
||||
log.info("发送消息的webSocketMap:存在");
|
||||
// 对应桌码发送消息
|
||||
for (AppWebSocketServer server : webSocketMap.get(tableId).values()) {
|
||||
log.info("发送消息的webSocketMap 次数:");
|
||||
server.sendMessage(message);
|
||||
}
|
||||
} else {
|
||||
@@ -307,33 +308,33 @@ public class AppWebSocketServer {
|
||||
}
|
||||
|
||||
|
||||
public static synchronized ConcurrentHashMap<String, List<AppWebSocketServer>> getWebSocketMap() {
|
||||
return AppWebSocketServer.webSocketMap;
|
||||
}
|
||||
|
||||
public static synchronized ConcurrentHashMap<String, List<JSONObject>> getRecordMap() {
|
||||
return AppWebSocketServer.recordMap;
|
||||
}
|
||||
private byte[] serialize(Object obj) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
oos.writeObject(obj);
|
||||
return bos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Object deserialize(byte[] bytes) {
|
||||
try {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
return ois.readObject();
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// public static synchronized ConcurrentHashMap<String, Set<AppWebSocketServer>> getWebSocketMap() {
|
||||
// return AppWebSocketServer.webSocketMap;
|
||||
// }
|
||||
//
|
||||
// public static synchronized ConcurrentHashMap<String, List<JSONObject>> getRecordMap() {
|
||||
// return AppWebSocketServer.recordMap;
|
||||
// }
|
||||
// private byte[] serialize(Object obj) {
|
||||
// try {
|
||||
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
// ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
// oos.writeObject(obj);
|
||||
// return bos.toByteArray();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private Object deserialize(byte[] bytes) {
|
||||
// try {
|
||||
// ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
|
||||
// ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
// return ois.readObject();
|
||||
// } catch (IOException | ClassNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ public class TokenUtil {
|
||||
*/
|
||||
private static final String TOKEN_SECRET = "BBDFSDFHFGHSGSRTRESDFSDFS";
|
||||
|
||||
private JwtBuilder jwtBuilder;
|
||||
|
||||
public static final String AUTHORITIES_KEY = "user";
|
||||
|
||||
/**
|
||||
* 初始化生成token的参数
|
||||
* @param userId
|
||||
@@ -45,17 +41,12 @@ public class TokenUtil {
|
||||
if(ObjectUtil.isNotEmpty(openId)){
|
||||
claims.put("openId",openId);
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNotEmpty(phone)){
|
||||
claims.put("phone",phone);
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNotEmpty(userName)){
|
||||
claims.put("userName",userName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return generateToken(claims);
|
||||
}
|
||||
public static String generateJfToken(String openId,String userSign) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 9889
|
||||
# port: 9889
|
||||
servlet:
|
||||
context-path: /cashierService/
|
||||
wx:
|
||||
@@ -10,6 +10,9 @@ wx:
|
||||
custom:
|
||||
appId: wxd88fffa983758a30
|
||||
secrete: a34a61adc0602118b49400baa8812454
|
||||
# 卓尔
|
||||
# appId: wx0dcea6001b0a8fb4
|
||||
# secrete: ba42423cce61f93f02519ff3030ceb1c
|
||||
#
|
||||
spring:
|
||||
profiles:
|
||||
|
||||
@@ -122,6 +122,10 @@
|
||||
FROM
|
||||
tb_shop_user_flow f
|
||||
LEFT JOIN tb_shop_user u ON f.shop_user_id = u.id
|
||||
where 1=1
|
||||
<if test="memberId != null and memberId!=''">
|
||||
and u.id = #{memberId}
|
||||
</if>
|
||||
order by f.id desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -44,6 +44,13 @@
|
||||
from tb_shop_user
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<select id="selectByPhone" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_shop_user
|
||||
where telephone = #{phone,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from tb_shop_user
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
@@ -386,11 +393,13 @@
|
||||
|
||||
<select id="selectByUserId" resultType="java.util.Map">
|
||||
SELECT
|
||||
u.id as memberId,
|
||||
i.id as shopId,
|
||||
i.shop_name as shopName,
|
||||
i.chain_name as chainName,
|
||||
i.logo,
|
||||
i.detail,
|
||||
u.level_consume as levelConsume,
|
||||
u.amount,
|
||||
u.`code`,
|
||||
u.is_vip
|
||||
|
||||
Reference in New Issue
Block a user