|
@@ -20,6 +20,7 @@ import com.usky.dxtop.common.enums.BusinessType;
|
|
|
import com.usky.dxtop.common.exception.CustomException;
|
|
|
import com.usky.dxtop.common.utils.*;
|
|
|
import com.usky.dxtop.common.utils.http.HttpUtils;
|
|
|
+import com.usky.dxtop.framework.web.domain.server.Sys;
|
|
|
import com.usky.dxtop.mapper.OrderMapper;
|
|
|
import com.usky.dxtop.model.*;
|
|
|
import com.usky.dxtop.service.*;
|
|
@@ -35,6 +36,7 @@ import ma.glasnost.orika.impl.DefaultMapperFactory;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.aop.framework.AopContext;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
@@ -202,7 +204,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
msgLog.setExchange(RabbitmqBeenCode.CART_CHARGE_CONSUMER.getName());
|
|
|
msgLog.setRoutingKey(RabbitmqBeenCode.CART_CHARGE_CONSUMER.getName());
|
|
|
msgLog.setMsg(JSON.toJSONString(chargeVo));
|
|
|
- msgLog.setId(System.currentTimeMillis());
|
|
|
+ msgLog.setId(System.nanoTime());
|
|
|
msgLog.setCreateTime(new Date());
|
|
|
msgLogService.save(msgLog);
|
|
|
chargeVo.setSeq(msgLog.getId());
|
|
@@ -783,10 +785,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
*/
|
|
|
public void sendMessage(List<Order> orderList,List<MsgLog> msgLogs){
|
|
|
AtomicBoolean b = new AtomicBoolean(true);
|
|
|
+ RabbitTemplate rabbitmqTemplate = RabbitmqUtils.getRabbitmqTemplate(RabbitmqBeenCode.CART_CHARGE_CONSUMER);
|
|
|
msgLogs.forEach(msgLog -> {
|
|
|
try {
|
|
|
CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
- RabbitmqUtils.getRabbitmqTemplate(RabbitmqBeenCode.CART_CHARGE_CONSUMER).convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), msgLog.getChargeVO(),correlationData);
|
|
|
+ rabbitmqTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), msgLog.getChargeVO(),correlationData);
|
|
|
}catch (Exception e){
|
|
|
b.set(false);
|
|
|
log.error("---order---卡充值消息发送异常"+ e.getMessage());
|
|
@@ -848,9 +851,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
if (CollectionUtils.isEmpty(orderFileVOS)){
|
|
|
throw new CustomException("表格数据为空");
|
|
|
}
|
|
|
- return BeanMapperUtils.mapList(orderFileVOS,OrderFileVO.class,Order.class);
|
|
|
+ List<Order> orderList = BeanMapperUtils.mapList(orderFileVOS, OrderFileVO.class, Order.class);
|
|
|
+ long count = orderList.stream().filter(order -> null == order.getMoney() && order.getMoney().compareTo(BigDecimal.ZERO) == 0).count();
|
|
|
+ if (count > 0){
|
|
|
+ throw new CustomException("订单金额不能为空");
|
|
|
+ }
|
|
|
+ long count1 = orderList.stream().filter(order -> StringUtils.isBlank(order.getUserName())).count();
|
|
|
+ if (count1 > 0){
|
|
|
+ throw new CustomException("用户名称不能为空");
|
|
|
+ }
|
|
|
+ long count2 = orderList.stream().filter(order -> StringUtils.isBlank(order.getUserPhone())).count();
|
|
|
+ if (count2 > 0){
|
|
|
+ throw new CustomException("用户手机号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ return orderList;
|
|
|
}catch (Exception e){
|
|
|
- throw new CustomException("解析订单异常"+e.getMessage());
|
|
|
+ throw new CustomException("解析订单异常,检查订单格式"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -887,7 +904,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
order.setCard(staff.getCardId());
|
|
|
order.setPayType(OrderPayType.XJ.getPayCode());
|
|
|
order.setScene(OrderSceneCode.BACK_STAGE.getCode());
|
|
|
- order.setOrderFlag(OrderStatus.SUCCESS.getCode());
|
|
|
+ order.setOrderFlag(OrderStatus.PAYMENT_ERROR_DEBIT.getCode());
|
|
|
String orderNumber = TopApiConfiger.getOrderNumber();
|
|
|
order.setOrderNumber(orderNumber);
|
|
|
return true;
|
|
@@ -900,7 +917,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
* @return
|
|
|
*/
|
|
|
public MsgLog enhanceMsgLog(Order order){
|
|
|
- Long seq = System.currentTimeMillis();
|
|
|
+ long seq = System.nanoTime();
|
|
|
ChargeVO chargeVo = new ChargeVO();
|
|
|
chargeVo.setAmt(order.getMoney());
|
|
|
if (null != order.getRealMoney() && order.getRealMoney().compareTo(BigDecimal.ZERO) != 0){
|
|
@@ -908,15 +925,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
chargeVo.setCard(order.getCard());
|
|
|
chargeVo.setSeq(seq);
|
|
|
-
|
|
|
MsgLog msgLog = new MsgLog();
|
|
|
msgLog.setBusinessId(String.format("%s%s",MsgLogBusinessCode.ORDER,order.getId()));
|
|
|
msgLog.setExchange(RabbitmqBeenCode.CART_CHARGE_CONSUMER.getName());
|
|
|
msgLog.setRoutingKey(RabbitmqBeenCode.CART_CHARGE_CONSUMER.getName());
|
|
|
- msgLog.setId(seq);
|
|
|
msgLog.setCreateTime(new Date());
|
|
|
msgLog.setMsg(JSON.toJSONString(chargeVo));
|
|
|
msgLog.setChargeVO(chargeVo);
|
|
|
+ msgLog.setId(seq);
|
|
|
return msgLog;
|
|
|
}
|
|
|
|
|
@@ -950,4 +966,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
throw new CustomException("上传文件失败"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|