提交代码

2.0-dev
胡锐 7 months ago
parent 70fce1b0c1
commit c29f27225e
  1. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 108
      hai-cweb/src/main/java/com/cweb/controller/QzOrderController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/controller/tPigController.java
  4. 34
      hai-order/src/main/java/com/web/controller/OrderPayController.java
  5. 8
      hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java
  6. 51
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  7. 6
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  8. 157
      hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java

File diff suppressed because one or more lines are too long

@ -0,0 +1,108 @@
package com.cweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.security.AESEncodeUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.WxOrderConfig;
import com.hai.dao.HighGasOrderRefundMapper;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOrderRefund;
import com.hai.entity.HighOrder;
import com.hai.model.OrderRefundModel;
import com.hai.service.HighOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.Date;
@Controller
@RequestMapping(value = "/qianzhu")
@Api(value = "千猪回调")
public class QzOrderController {
private static Logger log = LoggerFactory.getLogger(QzOrderController.class);
@Resource
private HighOrderService highOrderService;
@RequestMapping(value = "/orderNotify", method = RequestMethod.POST)
@ApiOperation(value = "千猪订单回调")
public void orderNotify(@RequestBody String reqBodyStr,HttpServletRequest request, HttpServletResponse response) {
try {
log.info(reqBodyStr);
JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
HighOrder order = highOrderService.getOrderByOrderNo(dataObject.getString("orderNo"));
if (order != null) {
JSONObject data = dataObject.getJSONObject("data");
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
// 4:KFC肯德基 5:电影票
if (childOrder.getGoodsType() == 4) {
// 10:已出票 -5:已取消 -3:部分取消 -10:退款
if (dataObject.getInteger("eventType") == -5) {
// 微信退款
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("cancelReason"), data.getBigDecimal("cancelReason"));
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
childOrder.setChildOrderStatus(5);
order.setOrderStatus(5);
order.setCancelTime(new Date());
order.setCancelRemarks(data.getString("cancelReason"));
highOrderService.updateOrderDetail(order);
}
}
if (dataObject.getInteger("eventType") == -10) {
// 微信退款
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("refundAmount"), data.getBigDecimal("refundAmount"));
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
childOrder.setChildOrderStatus(4);
order.setOrderStatus(4);
//order.setRefundTime(new Date());
//order.setRefundPrice(data.getBigDecimal("refundAmount"));
highOrderService.updateOrderDetail(order);
}
}
}
if (childOrder.getGoodsType() == 5) {
// 5:已支付(默认不发) 10:已出票 -5:已取消 15:交易成功
if (dataObject.getInteger("eventType") == -5) {
childOrder.setChildOrderStatus(5);
order.setOrderStatus(5);
order.setCancelTime(new Date());
order.setCancelRemarks(data.getString("cancelReason"));
}
if (dataObject.getInteger("eventType") == 15) {
childOrder.setChildOrderStatus(3);
order.setOrderStatus(3);
order.setFinishTime(new Date());
}
}
}
highOrderService.updateOrder(order);
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("success");
}
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
}
}
}

@ -58,7 +58,7 @@ public class tPigController {
}
}
@RequestMapping(value = "/getTPigCinemaToken", method = RequestMethod.GET)
@RequestMapping(value = "/queryCinemaUrl", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "【小程序】电影票获取千猪Token")
public ResponseData queryCinemaUrl() {

@ -108,6 +108,8 @@ public class OrderPayController {
@Resource
private SecConfigService secConfigService;
@Resource
private HighQzOrderService qzOrderService;
@Resource
private HuiConfig huiConfig;
@ -778,6 +780,38 @@ public class OrderPayController {
}
}
@RequestMapping(value = "/huiftPayQz", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "贵行V家园小程序支付千猪【电影票】")
public ResponseData huiftPayQz(@RequestBody JSONObject body, HttpServletRequest request) {
try {
if (body == null || StringUtils.isBlank(body.getString("orderNo"))) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 组装订单
HighOrder order = qzOrderService.assemblyQzOrder(body.getString("orderNo"), "CINEMA");
if (order == null) {
log.error("orderToPay error!", "创建订单失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "创建订单失败");
}
JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order);
order.setPayChannel(3);
order.setPayChannelOrderNo(thirdPreOrder.getString("preOrderNo"));
order.setProfitSharingStatus(false);
orderService.updateOrderData(order);
return ResponseMsgUtil.success(thirdPreOrder);
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "wechatCombinePay" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "微信合单支付")

@ -66,6 +66,14 @@ public interface OrderCreateHandleService {
*/
List<HighChildOrder> thirdPartyOrder(HighOrder order, JSONObject object) throws Exception;
/**
* 电影票订单组装
* @param order
* @return
* @throws Exception
*/
HighChildOrder cinemaRecharge(HighOrder order) throws Exception;
/**
* @Author Sum1Dream
* @Name prepaidRecharge

@ -934,6 +934,57 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
return childOrderList;
}
@Override
public HighChildOrder cinemaRecharge(HighOrder order) throws Exception {
// 查询电影票订单
JSONObject orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(order.getOrderNo());
if (orderDetail == null || !orderDetail.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "电影票订单创建失败");
}
JSONObject data = orderDetail.getJSONObject("data");
HighChildOrder highChildOrder = new HighChildOrder();
highChildOrder.setGoodsType(GoodsType.goodsType5.getType());
highChildOrder.setOrderNo(order.getOrderNo());
highChildOrder.setMemId(order.getMemId());
highChildOrder.setMemName(order.getMemName());
highChildOrder.setMemPhone(order.getMemPhone());
highChildOrder.setChildOrderNo(System.currentTimeMillis()+"");
highChildOrder.setStoreId(data.getLong("hallId"));
highChildOrder.setStoreName(data.getString("cinemaName"));
highChildOrder.setStoreAddress(data.getString("cinemaAddr"));
highChildOrder.setGoodsId(data.getLong("filmId"));
highChildOrder.setGoodsName(data.getString("filmName"));
highChildOrder.setGoodsDesc(data.getString("seatsDesc"));
highChildOrder.setGoodsImg(data.getString("pic"));
highChildOrder.setGoodsSpecName(StringUtils.isBlank(data.getString("versionTypes"))?"默认":data.getString("versionTypes"));
highChildOrder.setGoodsPrice(new BigDecimal(data.getString("unitPrice")));
highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice")));
highChildOrder.setSaleCount(data.getInteger("seatsCount"));
highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice()));
highChildOrder.setTotalActualPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsActualPrice()));
highChildOrder.setTotalDeductionPrice(new BigDecimal("0"));
highChildOrder.setGiveawayType(false);
highChildOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber());
highChildOrder.setPraiseStatus(0);
highChildOrder.setCreateTime(order.getCreateTime());
// 观看时间
JSONObject showTimeObject = new JSONObject();
showTimeObject.put("showTime", data.getString("showTime"));
showTimeObject.put("showEndTime", data.getString("showEndTime"));
highChildOrder.setExt1(showTimeObject.toJSONString());
// 影厅名称
highChildOrder.setExt2(data.getString("hallName"));
// 影片语言
highChildOrder.setExt3(data.getString("language"));
return highChildOrder;
}
@Override
public HighChildOrder mobileRecharge(HighOrder order , JSONObject object) throws Exception {
// 初始化话费订单对象

@ -246,6 +246,10 @@ public class OrderServiceImpl implements OrderService {
// 电影票
} else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) {
HighChildOrder childOrder = orderCreateHandleService.cinemaRecharge(order);
childOrderList.add(childOrder);
order.setTitle(childOrder.getGoodsName());
order.setProductType(OrderProductType.PRODUCT_TYPE10.getNumber());
// 话费充值
} else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) {
@ -622,7 +626,7 @@ public class OrderServiceImpl implements OrderService {
if (orderData.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
// 10分钟内未支付,自动取消订单
Message<HighOrder> rocketMsg = MessageBuilder.withPayload(order).build();
rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14);
// rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14);
} else if (orderData.getOrderStatus().equals(OrderStatus.STATUS2.getNumber())) {
// 支付校验

@ -9,154 +9,79 @@ 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("KFC")) {
orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo);
}
if (orderType.equals("CINEMA")) {
orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo);
}
if (orderType.equals("MOBILE")) {
/* 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");
HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
if (order != null) {
return order;
}
HighUser highUser = highUserService.findByUnionId(data.getString("platformUniqueId"));
// 查询用户信息
HighUser highUser = highUserService.findByPhone(data.getString("userMobile"));
if (highUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户");
}
highOrder.setHighChildOrderList(new ArrayList<>());
highOrder.setOrderNo(orderNo);
highOrder.setMemId(highUser.getId());
highOrder.setMemName(data.getString("userName"));
highOrder.setMemPhone(data.getString("userMobile"));
//highOrder.setPayModel(2);
highOrder.setPayType(2);
highOrder.setPayPrice(data.getBigDecimal("totalPrice"));
highOrder.setTotalPrice(data.getBigDecimal("totalPrice"));
highOrder.setTotalDeductionPrice(new BigDecimal("0"));
highOrder.setOrderStatus(1);
highOrder.setCreateTime(data.getDate("createTime"));
HighChildOrder highChildOrder;
if (orderType.equals("KFC")) {
// 商品信息
JSONObject kfcPlaceOrder = data.getJSONObject("kfcPlaceOrder");
JSONArray items = kfcPlaceOrder.getJSONArray("items");
for (Object goodsObject : items) {
JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(goodsObject), JSONObject.class);
highChildOrder = new HighChildOrder();
highChildOrder.setMemId(highOrder.getMemId());
highChildOrder.setGoodsType(4);
highChildOrder.setStoreName(kfcPlaceOrder.getString("storeName"));
highChildOrder.setStoreAddress(kfcPlaceOrder.getString("storeAddress"));
highChildOrder.setGoodsName(object.getString("productName"));
highChildOrder.setGoodsImg(object.getString("imageUrl"));
highChildOrder.setGoodsSpecName("默认");
highChildOrder.setGoodsPrice(new BigDecimal(object.getString("originPrice")));
highChildOrder.setGoodsActualPrice(new BigDecimal(object.getString("price")));
highChildOrder.setSaleCount(object.getInteger("quantity"));
highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice()));
highChildOrder.setGiveawayType(false);
highChildOrder.setChildOrderStatus(1);
highChildOrder.setPraiseStatus(0);
/* // 计算原始价格
highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString()));
highOrder.setTotalPrice();*/
// 1:堂食 2:外带 3:外卖
highChildOrder.setExt1(kfcPlaceOrder.getString("eatType"));
highOrder.getHighChildOrderList().add(highChildOrder);
}
}
if (orderType.equals("CINEMA")) {
highChildOrder = new HighChildOrder();
highChildOrder.setMemId(highOrder.getMemId());
highChildOrder.setGoodsType(5);
//highChildOrder.setStoreId(data.getLong("hallId"));
highChildOrder.setStoreName(data.getString("cinemaName"));
highChildOrder.setStoreAddress(data.getString("cinemaAddr"));
//highChildOrder.setGoodsId(data.getLong("filmId"));
highChildOrder.setGoodsName(data.getString("filmName"));
highChildOrder.setGoodsDesc(data.getString("seatsDesc"));
highChildOrder.setGoodsImg(data.getString("pic"));
highChildOrder.setGoodsSpecName("默认");
highChildOrder.setGoodsPrice(new BigDecimal(data.getString("marketUnitPrice")));
highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice")));
highChildOrder.setSaleCount(data.getInteger("seatsCount"));
highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice()));
highChildOrder.setGiveawayType(false);
highChildOrder.setChildOrderStatus(1);
highChildOrder.setPraiseStatus(0);
/*// 计算原始价格
highOrder.setTotalPrice(highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString())));*/
// 观看时间
JSONObject showTimeObject = new JSONObject();
showTimeObject.put("showTime", data.getString("showTime"));
showTimeObject.put("showEndTime", data.getString("showEndTime"));
highChildOrder.setExt1(showTimeObject.toJSONString());
// 影厅名称
highChildOrder.setExt2(data.getString("hallName"));
// 影片语言
highChildOrder.setExt3(data.getString("language"));
highOrder.getHighChildOrderList().add(highChildOrder);
}
if (orderType.equals("MOBILE")) {
highChildOrder = new HighChildOrder();
highChildOrder.setMemId(highOrder.getMemId());
highChildOrder.setGoodsType(6);
highChildOrder.setGoodsName("手机充值"+data.getString("rechargeDenomination")+"元");
highChildOrder.setGoodsSpecName(data.getString("rechargeMobile"));
highChildOrder.setGoodsPrice(new BigDecimal(data.getString("rechargeDenomination")));
highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice")));
highChildOrder.setSaleCount(data.getInteger("quantity"));
highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice()));
highChildOrder.setGiveawayType(false);
highChildOrder.setChildOrderStatus(1);
highChildOrder.setPraiseStatus(0);
/* // 计算原始价格
highOrder.setTotalPrice(highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString())));*/
highOrder.getHighChildOrderList().add(highChildOrder);
}
highOrderService.insertOrder(highOrder);
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;
}

Loading…
Cancel
Save