查询订单报文处理
This commit is contained in:
parent
9eb126eea0
commit
c9c9c4f678
@ -544,47 +544,33 @@ public class DeviceOtherMsgConsumer {
|
||||
//默认没有充值的订单
|
||||
reply.put("cmd",400);
|
||||
Map<String,Object> dataValue=new HashMap<>();
|
||||
// dataValue.put("cmd",1000);
|
||||
// data.put("orderNum",item.getId());//订单号
|
||||
// dataValue.put("cardId",cardId);//卡号
|
||||
// dataValue.put("areaCode",areaCode);//区域码
|
||||
// data.put("investBalance",item.getAmount().doubleValue()*100);
|
||||
// data.put("investWater",rechargecardUser.getWater()*100);
|
||||
|
||||
reply.put("msg","");
|
||||
|
||||
|
||||
//查询是否待充值的订单
|
||||
List<NgUserRechargeRecords> list = new LambdaQueryChainWrapper<>(ngUserRechargeRecordsMapper)
|
||||
List<NgUserRechargeRecords> orderList = new LambdaQueryChainWrapper<>(ngUserRechargeRecordsMapper)
|
||||
.select(NgUserRechargeRecords::getId, NgUserRechargeRecords::getStatus,NgUserRechargeRecords::getAmount)
|
||||
.eq(NgUserRechargeRecords::getCardNumber,cardId)
|
||||
.eq(NgUserRechargeRecords::getStatus,1)
|
||||
.eq(NgUserRechargeRecords::getStatus,1)//待下发状态的订单
|
||||
.list();
|
||||
//如果有待充值的订单
|
||||
if(!list.isEmpty()){
|
||||
//如果有待充值的订单则需要下发充值信息,如果有多条需要下发的充值订单,需要合并充值金额为一条,且订单号取最近的一条
|
||||
if(!orderList.isEmpty()){
|
||||
//合并订单充值金额
|
||||
BigDecimal investBalance=null;
|
||||
for(int i=0;i<orderList.size()-1;i++){
|
||||
//累加金额
|
||||
investBalance=investBalance==null?orderList.get(i).getAmount():investBalance.add(orderList.get(i).getAmount());
|
||||
}
|
||||
//取最新的订单号作为合并后的订单
|
||||
dataValue.put("orderNum",orderList.get(orderList.size()-1).getId());//订单号
|
||||
reply.put("cmd",410);
|
||||
dataValue.put("orderNum",list.get(0).getId());//订单号
|
||||
dataValue.put("cardNum",cardId);//卡号
|
||||
dataValue.put("areaCode",areaCode);//区域码
|
||||
dataValue.put("investBalance",investBalance.doubleValue()*100);//充值金额
|
||||
// dataValue.put("investWater",rechargecardUser.getWater()*100);//充值水量
|
||||
reply.put("data",dataValue);
|
||||
pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/info/reply", JSONUtil.toJsonStr(reply));
|
||||
}
|
||||
|
||||
//如果订单已经支付但并未下发
|
||||
list.forEach(item->{
|
||||
//下发指令
|
||||
// 构建回应
|
||||
Map<String,Object> recharge=new HashMap<>();
|
||||
recharge.put("cmd",1000);
|
||||
Map<String,Object> data1=new HashMap<>();
|
||||
data.put("orderNum",item.getId());//订单号
|
||||
data.put("cardNum",cardId);//卡号
|
||||
data.put("areaCode",areaCode);//区域码
|
||||
data.put("investBalance",item.getAmount().doubleValue()*100);
|
||||
data.put("investWater",1*100);
|
||||
reply.put("data",data);
|
||||
//发送回应
|
||||
pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/cmd/down", JSONUtil.toJsonStr(recharge));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user