| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.beetl.ShiroExtUtil; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.system.controller.general.TDriverController; |
| | | import com.stylefeng.guns.modular.system.controller.util.Base64Util; |
| | | import com.stylefeng.guns.modular.system.controller.util.GetOpenBodySig; |
| | | import com.stylefeng.guns.modular.system.controller.util.Util; |
| | | import com.stylefeng.guns.modular.system.dao.LineShiftDriverMapper; |
| | | import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.unionpay.upyzt.exception.UpyztException; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import com.stylefeng.guns.modular.system.util.HttpRequestUtil; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushURL; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.BufferedReader; |
| | |
| | | endTime = timeArray[1]; |
| | | } |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(tOrderCrossCityService.getCrossCityOrderList(page,beginTime,endTime,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),orderNum,orderSource,userName,userPhone,passengers,passengersPhone,serverCarModelId,driver,lineId,state)); |
| | | page.setRecords(tOrderCrossCityService.getCrossCityOrderList(page, beginTime, endTime, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, lineId, state)); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | |
| | | @ResponseBody |
| | | public Object cancel(@RequestParam Integer tOrderCrossCityId) throws Exception { |
| | | TOrderCrossCity tOrderCrossCity = tOrderCrossCityService.selectById(tOrderCrossCityId); |
| | | ShiroUser user = ShiroKit.getUser(); |
| | | ShiroUser user = ShiroExtUtil.getUser(); |
| | | |
| | | TOrderCrossCity orderCrossCity = tOrderCrossCityService.selectById(tOrderCrossCityId); |
| | | if(orderCrossCity.getState() > 5 && orderCrossCity.getState() != 11 && orderCrossCity.getState() != 7){ |
| | |
| | | if(orderCrossCity.getPayType()==5){ |
| | | TDriver driver = tDriverService.selectById(orderCrossCity.getDriverId()); |
| | | if(orderCrossCity.getPayMoney().doubleValue()>0) { |
| | | createAllocationReq(1, driver.getId(), 1, orderCrossCity.getPayMoney().doubleValue()); |
| | | } |
| | | } |
| | | |
| | |
| | | transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城出行取消退款", orderCrossCity.getPayMoney().doubleValue(), 1, 1, 1, 3, tOrderCrossCityId); |
| | | if(orderCrossCity.getPayMoney().doubleValue()>0){ |
| | | if(orderCrossCity.getOrderSource()==4){ |
| | | tDriverController.createAllocationReq(1,orderCrossCity.getDriverId(),1,orderCrossCity.getPayMoney().doubleValue()); |
| | | }else { |
| | | createAllocationReqUser(1,userInfo.getId(),1,orderCrossCity.getPayMoney().doubleValue()); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | userService.updateById(userInfo); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城出行取消退款", orderCrossCity.getPayMoney().doubleValue(), 1, 1, 1, 3, tOrderCrossCityId); |
| | | if(orderCrossCity.getPayMoney().doubleValue()>0) { |
| | | if (orderCrossCity.getOrderSource() == 4) { |
| | | // 退给司机 |
| | | createAllocationReq(1, orderCrossCity.getDriverId(), 1, orderCrossCity.getPayMoney().doubleValue()); |
| | | } else { |
| | | createAllocationReqUser(1, orderCrossCity.getUserId(), 1, orderCrossCity.getPayMoney().doubleValue()); |
| | | } |
| | | } |
| | | |
| | | System.out.println("退款"); |
| | | String billNo = orderCrossCity.getBillNo(); |
| | | // cancleMoney(orderCrossCity.getPayMoney(),billNo); |
| | |
| | | tOrderCrossCityService.updateById(tOrderCrossCity); |
| | | return SUCCESS_TIP; |
| | | } |
| | | // appId: 8a81c1bf831e72e30187ad640adf49be |
| | | // appKey: 6463dcd46c6d410eb40e68ee40e86e84 |
| | | // md5key: NxDhJztSzCDFzs3Z5Fzck7BAG2sRA4DY5aKScJDZrAzMkCh7 |
| | | // msgSrcId: 34U0 |
| | | // mid: 898150841210108 |
| | | // tid: 84UJWSE8 |
| | | // instMid: QRPAYDEFAULT |
| | | |
| | | |
| | | |
| | | public static ResultUtil cancleMoney(BigDecimal amount,String no) throws Exception { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); // 报文请求时间 |
| | |
| | | @Autowired |
| | | private IUserWithdrawalService userWithdrawalService; |
| | | |
| | | public String createAllocationReq(Integer companyId,Integer userId,int type,double money){ |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TDriver tUser = tDriverService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if(userWithdrawals.size()==0){ |
| | | return "error"; |
| | | } |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } |
| | | |
| | | } |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money){ |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TUser tUser = userService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if(userWithdrawals.size()==0){ |
| | | return "error"; |
| | | } |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | ResultUtil resultUtil = cancleMoney(new BigDecimal(0.01), "34U02023062418175413584261700"); |
| | | } |
| | | } |