| | |
| | | package com.stylefeng.guns.modular.CharteredCar.server.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.CharteredCar.dao.OrderCharteredCarMapper; |
| | | import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar; |
| | | import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; |
| | | import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.OrderCancel; |
| | | import com.stylefeng.guns.modular.system.model.SensitiveWords; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderCancelService; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | 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.system.warpper.PreferentialDataVo; |
| | | import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | 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 javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private ISystemNoticeService systemNoticeService; |
| | | |
| | | @Resource |
| | | private OrderPrivateCarMapper orderPrivateCarMapper; |
| | | |
| | | @Resource |
| | | private OrderTaxiMapper orderTaxiMapper; |
| | | |
| | | @Resource |
| | | private OrderCrossCityMapper orderCrossCityMapper; |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | | @Autowired |
| | | private ITransactionDetailsService transactionDetailsService; |
| | | |
| | | @Autowired |
| | | private ISysIntegralService sysIntegralService; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public ResultUtil orderCharteredCar(Date travelTime, Integer carTime, Integer serverCarModelId, String modelUse, Integer peopleNumber, |
| | | String contactPerson, String contactPhone, String placeLonLat, Integer uid) throws Exception { |
| | | |
| | | /** |
| | | * 1.出租车、专车、跨城有待支付的订单不能叫车 |
| | | * 2.小件物流有未完成的订单可以下跨城、专车、出租车 |
| | | * 3.出租车、专车、跨城有预约单可以下即时单 |
| | | */ |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(uid, null, 1, 7, 12); |
| | | if(orderPrivateCars.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | | List<OrderTaxi> list = orderTaxiMapper.queryByState_(uid, null, 1, 7, 12); |
| | | if(list.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | | List<OrderCrossCity> orderCrossCities1 = orderCrossCityMapper.queryByState(uid, 7, 12); |
| | | if(orderCrossCities1.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | | |
| | | |
| | | OrderCharteredCar orderCharteredCar = new OrderCharteredCar(); |
| | | orderCharteredCar.setUserId(uid); |
| | | Company query = companyCityService.query(placeLonLat.split(",")[0], placeLonLat.split(",")[1]); |
| | |
| | | } |
| | | |
| | | OrderCharteredCar orderCharteredCar = this.selectById(id); |
| | | if(null == uid){ |
| | | uid = orderCharteredCar.getUserId(); |
| | | } |
| | | if(null == orderCharteredCar){ |
| | | return ResultUtil.error("取消订单失败,订单信息有误"); |
| | | } |
| | |
| | | public synchronized String getOrderNum() throws Exception{ |
| | | int size = this.selectCount(null); |
| | | return "CHARTERED" + String.valueOf(1000000 + size + 1).substring(1); |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil payThankYouFee(Integer uid, Integer orderId, Double money, Integer payType, Integer type) throws Exception { |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | OrderCharteredCar orderCharteredCar = this.selectById(orderId); |
| | | ResultUtil resultUtil = ResultUtil.success(); |
| | | if(payType == 1){//微信支付 |
| | | String app = type == 1 ? "APP" : "JSAPI"; |
| | | resultUtil = payMoneyUtil.weixinpay("感谢费", "", orderId + "_6_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/wxPayThankYouFee", app, userInfo.getAppletsOpenId()); |
| | | paymentRecordService.saveData(3, uid, 1, orderId, 6, 1, money, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 2){//支付宝支付 |
| | | resultUtil = payMoneyUtil.alipay("感谢费", "感谢费", "", orderId + "_6_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/aliPayThankYouFee"); |
| | | paymentRecordService.saveData(1, uid, 1, orderId, 6, 2, money, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() == null || userInfo.getBalance() < money){ |
| | | 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", orderCharteredCar.getCompanyId())); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (money.intValue() * query1.getIntegral()));//积分 |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "包车-感谢费", money, 2, 1, 1, 6, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | orderCharteredCar.setThankYouFee(money); |
| | | this.updateById(orderCharteredCar); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, 1, 6, orderCharteredCar.getId(), 6, money); |
| | | systemNoticeService.addSystemNotice(1, "您已使用余额成功完成感谢费支付,谢谢使用!", uid, 1); |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | @Override |
| | | public void payThankYouFeeCallback(Integer orderId, String order_id, Integer payType) throws Exception { |
| | | OrderCharteredCar orderCharteredCar = this.selectById(orderId); |
| | | PaymentRecord query = paymentRecordService.query(3, orderCharteredCar.getUserId(), 1, orderId, 6, payType, 1); |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | |
| | | UserInfo userInfo = userInfoService.selectById(orderCharteredCar.getUserId()); |
| | | SysIntegral query1 = sysIntegralService.selectOne(new EntityWrapper<SysIntegral>().eq("companyId", orderCharteredCar.getCompanyId())); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分 |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(userInfo.getId(), "包车-感谢费", query.getAmount(), 2, 1, 1, 6, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | orderCharteredCar.setThankYouFee(query.getAmount()); |
| | | this.updateById(orderCharteredCar); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, 1, 6, orderCharteredCar.getId(), 6, query.getAmount()); |
| | | systemNoticeService.addSystemNotice(1, "您已使用" + (payType == 1 ? "微信" : "支付宝") + "成功完成感谢费支付,谢谢使用!", userInfo.getId(), 1); |
| | | } |
| | | |
| | | @Override |
| | | public PreferentialDataVo queryBalance1(Integer orderId, Integer uid) throws Exception { |
| | | PreferentialDataVo preferentialDataVo = new PreferentialDataVo(); |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | preferentialDataVo.setBalance(userInfo.getBalance()); |
| | | return preferentialDataVo; |
| | | } |
| | | } |