You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.5 KiB
88 lines
3.5 KiB
package com.hai.service.impl;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.hai.common.exception.ErrorCode;
|
|
import com.hai.common.exception.ErrorHelp;
|
|
import com.hai.common.exception.SysCode;
|
|
import com.hai.config.QianZhuConfig;
|
|
import com.hai.entity.HighChildOrder;
|
|
import com.hai.entity.HighOrder;
|
|
import com.hai.entity.HighUser;
|
|
import com.hai.enum_type.GoodsType;
|
|
import com.hai.order.model.CreateOrderChildModel;
|
|
import com.hai.order.model.CreateOrderModel;
|
|
import com.hai.order.service.OrderService;
|
|
import com.hai.order.type.OrderChildStatus;
|
|
import com.hai.order.type.OrderProductType;
|
|
import com.hai.order.type.OrderStatus;
|
|
import com.hai.service.HighOrderService;
|
|
import com.hai.service.HighQzOrderService;
|
|
import com.hai.service.HighUserService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Service("highQzOrderService")
|
|
public class HighQzOrderServiceImpl implements HighQzOrderService {
|
|
|
|
@Resource
|
|
private HighUserService highUserService;
|
|
@Resource
|
|
private HighOrderService highOrderService;
|
|
@Resource
|
|
private OrderService orderService;
|
|
|
|
@Override
|
|
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
|
|
public HighOrder assemblyQzOrder(String orderNo,String orderType) throws Exception {
|
|
// 查询订单 已存在返回订单,未存在创建订单
|
|
HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
|
|
if (order != null) {
|
|
return order;
|
|
}
|
|
HighOrder highOrder = null;
|
|
JSONObject orderDetail = null;
|
|
if (orderType.equals("CINEMA")) {
|
|
orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo);
|
|
}
|
|
/* if (orderType.equals("KFC")) {
|
|
orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo);
|
|
}*/
|
|
/*if (orderType.equals("MOBILE")) {
|
|
orderDetail = QianZhuConfig.getMobileOrderByOrderNo(orderNo);
|
|
}*/
|
|
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
|
|
highOrder = new HighOrder();
|
|
JSONObject data = orderDetail.getJSONObject("data");
|
|
|
|
// 查询用户信息
|
|
HighUser highUser = highUserService.findByPhone(data.getString("userMobile"));
|
|
if (highUser == null) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户");
|
|
}
|
|
|
|
CreateOrderModel createOrderModel = new CreateOrderModel();
|
|
createOrderModel.setCompanyId(58L);
|
|
createOrderModel.setProductType(OrderProductType.PRODUCT_TYPE10.getNumber());
|
|
createOrderModel.setOrderNo(orderNo);
|
|
createOrderModel.setMemId(highUser.getId());
|
|
createOrderModel.setMemName(highUser.getName());
|
|
createOrderModel.setMemPhone(highUser.getPhone());
|
|
|
|
List<CreateOrderChildModel> orderChildList = new ArrayList<>();
|
|
CreateOrderChildModel orderChild = new CreateOrderChildModel();
|
|
orderChild.setGoodsType(GoodsType.goodsType5.getType());
|
|
orderChildList.add(orderChild);
|
|
createOrderModel.setChildOrderList(orderChildList);
|
|
return orderService.createOrder(createOrderModel);
|
|
}
|
|
return highOrder;
|
|
}
|
|
}
|
|
|