'提交代码'

dev-discount
= 3 years ago
parent 864830e1be
commit 51accb2d04
  1. 24
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  2. 19
      hai-service/src/main/java/com/hai/service/HighQzOrderService.java
  3. 111
      hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java
  4. 30
      hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java
  5. 28
      hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java

@ -25,6 +25,7 @@ import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponService;
import com.hai.service.HighOrderService;
import com.hai.service.HighQzOrderService;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
@ -86,6 +87,9 @@ public class OrderController {
@Resource
private HighCouponService highCouponService;
@Resource
private HighQzOrderService highQzOrderService;
/**
*
* @Title: orderToPay
@ -245,20 +249,14 @@ public class OrderController {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject orderDetail = null;
if (source.equals("KFC")) {
orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo);
}
if (source.equals("CINEMA")) {
orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo);
}
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
// 组装千猪订单
HighOrder qzOrder = highQzOrderService.assemblyQzOrder(orderNo, source);
return ResponseMsgUtil.success(qzOrder);
/* if (qzOrder != null) {
Map<String,Object> map = new HashMap<>();
map.put("orderNo", data.getString("orderNo"));
map.put("payPrice", data.getBigDecimal("totalPrice"));
map.put("orderNo", qzOrder.getOrderNo());
map.put("payPrice", qzOrder.getPayPrice());
map.put("orderScene", source);
map.put("body","购买产品");
map.put("subject","购买产品");
@ -293,7 +291,7 @@ public class OrderController {
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);
return ResponseMsgUtil.success(sortedMap);
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号");*/
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);

@ -0,0 +1,19 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighOrder;
/**
* 千猪订单
*/
public interface HighQzOrderService {
/**
* 组装千猪订单
* @param orderNo
* @param orderType
* @return
*/
HighOrder assemblyQzOrder(String orderNo,String orderType) throws Exception;
}

@ -0,0 +1,111 @@
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.service.HighOrderService;
import com.hai.service.HighQzOrderService;
import com.hai.service.HighUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
@Service("highQzOrderService")
public class HighQzOrderServiceImpl implements HighQzOrderService {
@Resource
private HighUserService highUserService;
@Resource
private HighOrderService highOrderService;
@Override
public HighOrder assemblyQzOrder(String orderNo,String orderType) throws Exception {
HighOrder highOrder = new HighOrder();
JSONObject orderDetail = null;
if (orderType.equals("KFC")) {
orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo);
}
if (orderType.equals("CINEMA")) {
orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo);
}
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
if (order != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单已存在");
}
HighUser highUser = highUserService.findByUnionId(data.getString("platformUniqueId"));
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.setDeductionPrice(new BigDecimal("0"));
highOrder.setOrderStatus(1);
highOrder.setCreateTime(data.getDate("createTime"));
highOrder.setRemarks(data.getString("userRemark"));
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.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.setChildOrdeStatus(1);
highChildOrder.setPraiseStatus(0);
highOrder.getHighChildOrderList().add(highChildOrder);
}
}
if (orderType.equals("CINEMA")) {
highChildOrder = new HighChildOrder();
highChildOrder.setMemId(highOrder.getMemId());
highChildOrder.setGoodsType(5);
highChildOrder.setGoodsName(data.getString("cinemaName"));
highChildOrder.setGoodsImg(data.getString("pic"));
highChildOrder.setGoodsSpecName("默认");
highChildOrder.setGoodsPrice(new BigDecimal(data.getString("unitPrice")));
highChildOrder.setSaleCount(data.getInteger("seatsCount"));
highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice()));
highChildOrder.setGoodsActualPrice(highChildOrder.getTotalPrice());
highChildOrder.setGiveawayType(false);
highChildOrder.setChildOrdeStatus(1);
highChildOrder.setPraiseStatus(0);
highOrder.getHighChildOrderList().add(highChildOrder);
}
}
highOrderService.insertOrder(highOrder);
return highOrder;
}
}

@ -2,24 +2,46 @@ package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder;
import com.hai.service.HighOrderService;
import com.hai.service.pay.PayService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
@Service("cinemaOrderService")
public class CinemaOrderService implements PayService {
@Resource
private HighOrderService highOrderService;
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
return;
}
if (payType.equals("WechatPay")) {
JSONObject orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(map.get("out_trade_no"));
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
QianZhuConfig.payMovieOrder(data.getString("orderNo"));
HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no"));
if (order != null && order.getOrderStatus() != 1) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合
order.setPayType(2); // 支付方式: 1:支付宝 2:微信 3:金币
order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
}
highOrderService.updateOrder(order);
// 支付给千猪
QianZhuConfig.payMovieOrder(order.getOrderNo());
}
}
}
}

@ -3,24 +3,44 @@ package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder;
import com.hai.service.HighOrderService;
import com.hai.service.pay.PayService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
@Service("kfcOrderService")
public class KfcOrderService implements PayService {
@Resource
private HighOrderService highOrderService;
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
return;
}
if (payType.equals("WechatPay")) {
JSONObject orderDetail = QianZhuConfig.getKfcOrderByOrderNo(map.get("out_trade_no"));
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
QianZhuConfig.payKfcOrder(data.getString("orderNo"));
HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no"));
if (order != null && order.getOrderStatus() != 1) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合
order.setPayType(2); // 支付方式: 1:支付宝 2:微信 3:金币
order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
}
highOrderService.updateOrder(order);
// 支付给千猪
QianZhuConfig.payKfcOrder(order.getOrderNo());
}
}
}

Loading…
Cancel
Save