package com.stylefeng.guns.modular.call.server.impl;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar;
|
import com.stylefeng.guns.modular.account.controller.AppOrderController;
|
import com.stylefeng.guns.modular.call.dao.OrderCallMapper;
|
import com.stylefeng.guns.modular.call.model.OrderCall;
|
import com.stylefeng.guns.modular.call.server.IOrderCallService;
|
import com.stylefeng.guns.modular.system.model.SysIntegral;
|
import com.stylefeng.guns.modular.system.model.UserInfo;
|
import com.stylefeng.guns.modular.system.service.IIncomeService;
|
import com.stylefeng.guns.modular.system.service.ISysIntegralService;
|
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
|
import com.stylefeng.guns.modular.system.service.IUserInfoService;
|
import com.stylefeng.guns.modular.system.util.PayMoneyUtil;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.util.UUIDUtil;
|
import com.stylefeng.guns.modular.taxi.model.PaymentRecord;
|
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
|
import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
|
@Service
|
public class OrderCallServiceImpl extends ServiceImpl<OrderCallMapper, OrderCall> implements IOrderCallService {
|
|
@Autowired
|
private IUserInfoService userInfoService;
|
|
@Autowired
|
private PayMoneyUtil payMoneyUtil;
|
|
@Autowired
|
private IPaymentRecordService paymentRecordService;
|
|
@Autowired
|
private ISysIntegralService sysIntegralService;
|
|
@Autowired
|
private IIncomeService incomeService;
|
|
@Autowired
|
private ITransactionDetailsService transactionDetailsService;
|
|
@Autowired
|
private ISystemNoticeService systemNoticeService;
|
|
|
|
@Override
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
public ResultUtil payThankYouFee(Integer uid, Integer orderId, Double money, Integer payType, Integer type) throws Exception {
|
UserInfo userInfo = userInfoService.selectById(uid);
|
OrderCall orderCall = this.selectById(orderId);
|
ResultUtil resultUtil = ResultUtil.success();
|
if(payType == 1){//微信支付
|
String app = type == 1 ? "APP" : "JSAPI";
|
resultUtil = payMoneyUtil.weixinpay("感谢费", "", orderId + "_7_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/wxPayThankYouFee", app, userInfo.getAppletsOpenId());
|
paymentRecordService.saveData(3, uid, 1, orderId, 7, 1, money, "", 1);//添加预支付数据
|
}
|
if(payType == 2){//支付宝支付
|
resultUtil = payMoneyUtil.alipay("感谢费", "感谢费", "", orderId + "_7_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/aliPayThankYouFee");
|
paymentRecordService.saveData(1, uid, 1, orderId, 7, 2, money, "", 1);//添加预支付数据
|
}
|
if(payType == 3){//余额支付
|
if(userInfo.getBalance() == null || userInfo.getBalance() < money){
|
return ResultUtil.error("余额不足,无法完成支付");
|
}
|
// resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money);
|
// if(resultUtil.getCode()==500){
|
// return ResultUtil.error("电子余额不足,无法完成支付");
|
// }
|
|
userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
|
|
SysIntegral query1 = sysIntegralService.selectOne(new EntityWrapper<SysIntegral>().eq("companyId", orderCall.getCompanyId()));
|
userInfo.setIntegral(userInfo.getIntegral() + (money.intValue() * query1.getIntegral()));//积分
|
|
//添加交易明细
|
transactionDetailsService.saveData(uid, "助老模式-感谢费", money, 2, 1, 1, 7, orderId);
|
userInfoService.updateById(userInfo);
|
|
orderCall.setThankYouFee(money);
|
this.updateById(orderCall);
|
|
//添加已收入明细
|
incomeService.saveData(1, 1, 6, orderCall.getId(), 7, money);
|
systemNoticeService.addSystemNotice(1, "您已使用余额成功完成感谢费支付,谢谢使用!", uid, 1);
|
|
}
|
if(payType==4){
|
Double payMoney = orderCall.getThankYouFee();
|
Integer integer = paymentRecordService.saveData(1, uid, 1, orderId, 7, 4, money, "", 1);
|
resultUtil = appOrderController.placeAnOrder(new BigDecimal(money), 4,orderId,2,integer);
|
}
|
return resultUtil;
|
}
|
|
@Autowired
|
private AppOrderController appOrderController;
|
|
@Override
|
public void payThankYouFeeCallback(Integer orderId, String order_id, Integer payType) throws Exception {
|
OrderCall orderCall = this.selectById(orderId);
|
PaymentRecord query = paymentRecordService.query(3, orderCall.getUserId(), 1, orderId, 7, payType, 1);
|
query.setState(2);
|
query.setCode(order_id);
|
paymentRecordService.updateById(query);
|
|
UserInfo userInfo = userInfoService.selectById(orderCall.getUserId());
|
SysIntegral query1 = sysIntegralService.selectOne(new EntityWrapper<SysIntegral>().eq("companyId", orderCall.getCompanyId()));
|
userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
|
//添加交易明细
|
transactionDetailsService.saveData(userInfo.getId(), "助老模式-感谢费", query.getAmount(), 2, 1, 1, 7, orderId);
|
userInfoService.updateById(userInfo);
|
orderCall.setThankYouFee(query.getAmount());
|
this.updateById(orderCall);
|
|
//添加已收入明细
|
incomeService.saveData(1, 1, 6, orderCall.getId(), 7, query.getAmount());
|
systemNoticeService.addSystemNotice(1, "您已使用" + (payType == 1 ? "微信" : (payType==2?"支付宝":"云闪付")) + "成功完成感谢费支付,谢谢使用!", userInfo.getId(), 1);
|
}
|
}
|