|
|
@ -8,13 +8,13 @@ import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.utils.DateUtil; |
|
|
|
import com.hai.common.utils.DateUtil; |
|
|
|
import com.hai.common.utils.IDGenerator; |
|
|
|
import com.hai.common.utils.IDGenerator; |
|
|
|
|
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
import com.hai.config.HuiLianTongConfig; |
|
|
|
import com.hai.config.HuiLianTongConfig; |
|
|
|
|
|
|
|
import com.hai.config.HuiLianTongUnionCardConfig; |
|
|
|
|
|
|
|
import com.hai.config.TuanYouConfig; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.model.HighCouponHandselModel; |
|
|
|
import com.hai.model.*; |
|
|
|
import com.hai.model.HighCouponModel; |
|
|
|
|
|
|
|
import com.hai.model.HighOrderData; |
|
|
|
|
|
|
|
import com.hai.model.HighOrderModel; |
|
|
|
|
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.*; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -43,6 +43,9 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighOrderMapperExt highOrderMapperExt; |
|
|
|
private HighOrderMapperExt highOrderMapperExt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighUserCardService highUserCardService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighChildOrderMapper highChildOrderMapper; |
|
|
|
private HighChildOrderMapper highChildOrderMapper; |
|
|
|
|
|
|
|
|
|
|
@ -76,6 +79,9 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighMerchantStoreService highMerchantStoreService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
public void insertOrder(HighOrder highOrder) throws Exception { |
|
|
|
public void insertOrder(HighOrder highOrder) throws Exception { |
|
|
@ -272,6 +278,197 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
updateOrder(highOrder); |
|
|
|
updateOrder(highOrder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void hltUnionCardPay(Long userCardId, Long orderId) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighUserCard userCard = highUserCardService.getDetailById(userCardId); |
|
|
|
|
|
|
|
if(userCard == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询订单信息
|
|
|
|
|
|
|
|
HighOrder order = getOrderById(orderId); |
|
|
|
|
|
|
|
if (order == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String goodsDesc = ""; |
|
|
|
|
|
|
|
String tranDesc = ""; |
|
|
|
|
|
|
|
String businessType = "hisen_consume"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order.getHighChildOrderList().get(0).getGoodsType() == 1) { |
|
|
|
|
|
|
|
businessType = "sinopec_oil_code"; |
|
|
|
|
|
|
|
goodsDesc = "购买加油券"; |
|
|
|
|
|
|
|
tranDesc = order.getHighChildOrderList().get(0).getGoodsName(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 2) { |
|
|
|
|
|
|
|
goodsDesc = "积分充值"+order.getPayPrice()+"元"; |
|
|
|
|
|
|
|
tranDesc = "嗨森逛积分充值"+order.getPayPrice()+"元"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 工会卡支付
|
|
|
|
|
|
|
|
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, goodsDesc, tranDesc); |
|
|
|
|
|
|
|
if(!consumption.getString("respCode").equals("0000")) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); |
|
|
|
|
|
|
|
if (consumptionResult.getBoolean("success") != true) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败,请使用其他支付方式"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户
|
|
|
|
|
|
|
|
HighUser highUser = highUserService.findByUserId(order.getMemId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
order.setMemCardId(userCard.getId()); |
|
|
|
|
|
|
|
order.setMemCardNo(userCard.getCardNo()); |
|
|
|
|
|
|
|
order.setMemCardType(userCard.getType()); |
|
|
|
|
|
|
|
order.setPaySerialNo(consumption.getString("orderId")); // 支付流水号
|
|
|
|
|
|
|
|
order.setPayRealPrice(order.getPayPrice()); // 实付金额
|
|
|
|
|
|
|
|
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 highChildOrder : order.getHighChildOrderList()) { |
|
|
|
|
|
|
|
// 商品类型 商品类型 1:卡卷 2:金币充值
|
|
|
|
|
|
|
|
if (highChildOrder.getGoodsType() == 1) { |
|
|
|
|
|
|
|
highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
|
|
|
|
|
|
|
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); |
|
|
|
|
|
|
|
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
|
|
|
|
|
|
|
|
code.setReceiveTime(new Date()); |
|
|
|
|
|
|
|
highCouponCodeService.updateCouponCode(code); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId()); |
|
|
|
|
|
|
|
// 贵州中石化
|
|
|
|
|
|
|
|
if (coupon.getCouponSource() == 4) { |
|
|
|
|
|
|
|
// 获取token
|
|
|
|
|
|
|
|
JSONObject tokenObject = HuiLianTongConfig.getToken(); |
|
|
|
|
|
|
|
if (!tokenObject.getString("result").equals("success")) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> push = new HashMap<>(); |
|
|
|
|
|
|
|
push.put("token", "data"); |
|
|
|
|
|
|
|
push.put("couTypeCode", coupon.getCouponKey()); |
|
|
|
|
|
|
|
push.put("distCouCount", highChildOrder.getSaleCount()); |
|
|
|
|
|
|
|
push.put("userPhone", highUser.getPhone()); |
|
|
|
|
|
|
|
push.put("thirdUserId", highUser.getUnionId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 推送给高速
|
|
|
|
|
|
|
|
JSONObject returnParam = HuiLianTongConfig.couJointDist(tokenObject.getString("data"), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); |
|
|
|
|
|
|
|
if (returnParam != null && returnParam.getString("result").equals("success")) { |
|
|
|
|
|
|
|
JSONArray dataArray = returnParam.getJSONArray("data"); |
|
|
|
|
|
|
|
for (Object data : dataArray) { |
|
|
|
|
|
|
|
JSONObject dataObject = (JSONObject) data; |
|
|
|
|
|
|
|
HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); |
|
|
|
|
|
|
|
couponCodeOther.setType(1); |
|
|
|
|
|
|
|
couponCodeOther.setOrderId(order.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setChildOrderId(highChildOrder.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); |
|
|
|
|
|
|
|
couponCodeOther.setCouNo(dataObject.getString("couNo")); |
|
|
|
|
|
|
|
couponCodeOther.setStatus(20); |
|
|
|
|
|
|
|
couponCodeOther.setCreateTime(new Date()); |
|
|
|
|
|
|
|
couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); |
|
|
|
|
|
|
|
couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); |
|
|
|
|
|
|
|
couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); |
|
|
|
|
|
|
|
highCouponCodeOtherMapper.insert(couponCodeOther); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷关联用户
|
|
|
|
|
|
|
|
HighUserCoupon highUserCoupon = new HighUserCoupon(); |
|
|
|
|
|
|
|
highUserCoupon.setMerchantId(coupon.getMerchantId()); |
|
|
|
|
|
|
|
highUserCoupon.setCouponId(coupon.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setUserId(order.getMemId()); |
|
|
|
|
|
|
|
highUserCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); |
|
|
|
|
|
|
|
highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); |
|
|
|
|
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
highUserCouponMapper.insert(highUserCoupon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 推送记录
|
|
|
|
|
|
|
|
HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); |
|
|
|
|
|
|
|
highGasOrderPush.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highGasOrderPush.setCode(returnParam.getString("result")); |
|
|
|
|
|
|
|
highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); |
|
|
|
|
|
|
|
highGasOrderPush.setReturnContent(returnParam.toJSONString()); |
|
|
|
|
|
|
|
highGasOrderPushMapper.insert(highGasOrderPush); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 卡卷关联用户
|
|
|
|
|
|
|
|
HighUserCoupon highUserCoupon = new HighUserCoupon(); |
|
|
|
|
|
|
|
highUserCoupon.setMerchantId(code.getMerchantId()); |
|
|
|
|
|
|
|
highUserCoupon.setCouponId(code.getCouponId()); |
|
|
|
|
|
|
|
highUserCoupon.setUserId(order.getMemId()); |
|
|
|
|
|
|
|
highUserCoupon.setCouponCodeId(code.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highUserCoupon.setQrCodeImg(code.getExt1()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算使用有效期
|
|
|
|
|
|
|
|
Calendar userEndTime = Calendar.getInstance(); |
|
|
|
|
|
|
|
userEndTime.setTime(new Date()); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.MINUTE, 59); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.SECOND, 59); |
|
|
|
|
|
|
|
userEndTime.add(Calendar.DATE, coupon.getRecycleDay()); |
|
|
|
|
|
|
|
if (userEndTime.getTime().compareTo(code.getUseEndTime()) == 1) { |
|
|
|
|
|
|
|
highUserCoupon.setUseEndTime(code.getUseEndTime()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
highUserCoupon.setUseEndTime(userEndTime.getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
highUserCouponMapper.insert(highUserCoupon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (highChildOrder.getGoodsType() == 2) { |
|
|
|
|
|
|
|
highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
|
|
|
|
|
|
|
// 金币 1:100
|
|
|
|
|
|
|
|
Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); |
|
|
|
|
|
|
|
highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (highChildOrder.getGoodsType() == 3) { |
|
|
|
|
|
|
|
highChildOrder.setChildOrdeStatus(3); |
|
|
|
|
|
|
|
HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); |
|
|
|
|
|
|
|
// 推送团油订单
|
|
|
|
|
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
|
|
|
|
paramMap.put("gasId", store.getStoreKey()); |
|
|
|
|
|
|
|
paramMap.put("oilNo", highChildOrder.getGasOilNo()); |
|
|
|
|
|
|
|
paramMap.put("gunNo", highChildOrder.getGasGunNo()); |
|
|
|
|
|
|
|
BigDecimal priceGun = highChildOrder.getGasPriceGun(); |
|
|
|
|
|
|
|
BigDecimal priceVip = highChildOrder.getGasPriceVip(); |
|
|
|
|
|
|
|
paramMap.put("priceGun", priceGun); // 枪单价
|
|
|
|
|
|
|
|
paramMap.put("priceVip", priceVip); // 优惠价
|
|
|
|
|
|
|
|
paramMap.put("driverPhone", order.getMemPhone()); |
|
|
|
|
|
|
|
paramMap.put("thirdSerialNo", order.getOrderNo()); |
|
|
|
|
|
|
|
paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 油品类型 1:汽油:2:柴油;3:天然气
|
|
|
|
|
|
|
|
if (highChildOrder.getGasOilType() == 1) { |
|
|
|
|
|
|
|
paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); |
|
|
|
|
|
|
|
} else if (highChildOrder.getGasOilType() == 2) { |
|
|
|
|
|
|
|
paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); |
|
|
|
|
|
|
|
// 推送团油订单记录
|
|
|
|
|
|
|
|
HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); |
|
|
|
|
|
|
|
highGasOrderPush.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highGasOrderPush.setCode(orderPushObject.getString("code")); |
|
|
|
|
|
|
|
highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); |
|
|
|
|
|
|
|
highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); |
|
|
|
|
|
|
|
highGasOrderPushMapper.insert(highGasOrderPush); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { |
|
|
|
|
|
|
|
highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
updateOrder(order); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
public void updateOrder(HighOrder highOrder) { |
|
|
|
public void updateOrder(HighOrder highOrder) { |
|
|
|