client 标签打印 长链接

会员绑定
This commit is contained in:
2024-06-21 09:18:56 +08:00
parent 4d7e6c3650
commit 4a4c5623aa
15 changed files with 493 additions and 21 deletions

View File

@@ -116,9 +116,15 @@ public class LoginService {
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectAllByUserId(userInfo.getId().toString());
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setTelephone(phone);
tbShopUser.setUserId("");
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
tbShopUserMapper.upUserBYId(tbShopUser);
}
List<TbShopUser> tbShopUsers1 = tbShopUserMapper.selectByPhone(telephone);
for (TbShopUser tbShopUser : tbShopUsers1) {
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUser.setUserId(userInfo.getId().toString());
tbShopUserMapper.upUserBYId(tbShopUser);
}
}
}

View File

@@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.PayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
@@ -148,6 +149,9 @@ public class PayService {
if(!"unpaid".equals(orderInfo.getStatus())&&!"paying".equals(orderInfo.getStatus())){
return Result.fail("订单状态异常,不允许支付");
}
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
}
if(ObjectUtil.isNull(orderInfo.getMerchantId())||ObjectUtil.isEmpty(orderInfo.getMerchantId())){
return Result.fail("没有对应的商户");
@@ -304,6 +308,9 @@ public class PayService {
if (ObjectUtil.isEmpty(orderInfo)) {
return Result.fail("订单信息不存在");
}
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
}
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
@@ -321,7 +328,7 @@ public class PayService {
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus()) ) {
return Result.fail("订单状态异常");
return Result.fail("订单状态异常");
}
@@ -384,7 +391,7 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(orderId);
sendOrderToClient(orderInfo);
return Result.success(CodeEnum.SUCCESS,"1");
}
@@ -717,7 +724,8 @@ public class PayService {
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
return Result.success(CodeEnum.SUCCESS,orderId);
case "REFUND_ING":
cartStatus="refunding";
@@ -751,11 +759,6 @@ public class PayService {
}
// if("0".equals(userInfo.getIsPwd())){
// return Result.fail("用户支付密码未设置");
// }
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if(ObjectUtil.isEmpty(shopInfo)){
return Result.fail("对应的店铺信息不存在");
@@ -872,7 +875,8 @@ public class PayService {
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
return "SUCCESS";
}
@@ -917,6 +921,8 @@ public class PayService {
coupons.put("type","buy");
coupons.put("orderId",orderInfo.getId().toString());
producer.printCoupons(coupons.toJSONString());
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
return "SUCCESS";
}
@@ -979,7 +985,11 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public void test(String payOrderNO) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPayOrderNo(payOrderNO);
sendOrderToClient(orderInfo);
}
@@ -1170,6 +1180,34 @@ public class PayService {
return "SUCCESS";
}
public void sendOrderToClient(TbOrderInfo orderInfo) {
List<TbCashierCart> tbCashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), null);
JSONObject client = new JSONObject();
JSONObject order = new JSONObject();
order.put("orderNo",orderInfo.getOrderNo());
order.put("masterId",StringUtils.isNotBlank(orderInfo.getMasterId())?orderInfo.getMasterId():"");
order.put("tableName",StringUtils.isNotBlank(orderInfo.getTableName())?orderInfo.getTableName():"");
client.put("carts", tbCashierCarts);
client.put("type", "order");
client.put("amount", orderInfo.getPayAmount());
client.put("remark", StringUtils.isNotBlank(orderInfo.getRemark())?orderInfo.getRemark():"");
client.put("orderInfo", order);
client.put("createdAt", orderInfo.getCreatedAt());
client.put("outNumber", StringUtils.isNotBlank(orderInfo.getOutNumber())?orderInfo.getOutNumber():"");
// client.put("outNumberCode", "");
// if(StringUtils.isNotBlank(orderInfo.getOutNumber())){
// try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
// QrCodeUtils.createCodeToOutputStream(orderInfo.getOutNumber(), outputStream);
// String s = Base64Utils.encodeToString(outputStream.toByteArray());
// client.put("outNumberCode", s);
// } catch (Exception e) {
// log.info("生成 失败");
// e.printStackTrace();
// }
// }
PushToClientChannelHandlerAdapter.getInstance().AppSendInfo(client.toString(), orderInfo.getShopId(), "", false);
}
// public Result returnOrder(){
//