web socket
支付 会员
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user