| | |
| | | import com.dsh.competition.feignclient.account.AppUserClient; |
| | | import com.dsh.competition.feignclient.account.model.AppUser; |
| | | import com.dsh.competition.feignclient.course.CoursePackagePaymentClient; |
| | | import com.dsh.competition.feignclient.course.model.PaymentDeductionClassHour; |
| | | import com.dsh.competition.feignclient.model.*; |
| | | import com.dsh.competition.feignclient.other.StoreClient; |
| | | import com.dsh.competition.model.*; |
| | | import com.dsh.competition.service.CompetitionService; |
| | | import com.dsh.competition.service.IParticipantService; |
| | |
| | | } |
| | | } |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private UserCompetitionService userCompetitionService; |
| | | |
| | | |
| | | @PostMapping("/base/competition/cancel") |
| | | public void cancel(@RequestBody Integer id){ |
| | | try { |
| | | Competition byId = cttService.getById(id); |
| | | byId.setStatus(4); |
| | | cttService.updateById(byId); |
| | | List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("competitionId", byId.getId()).eq("payStatus", 2)); |
| | | for (PaymentCompetition pay : list) { |
| | | PaymentCompetition paymentCompetition = pay; |
| | | |
| | | String code = paymentCompetition.getCode(); |
| | | Double amount = paymentCompetition.getAmount(); |
| | | Competition competition = competitionService.getById(paymentCompetition.getCompetitionId()); |
| | | |
| | | |
| | | String payOrderNo = paymentCompetition.getPayOrderNo(); |
| | | if(paymentCompetition.getPayType() == 1){//微信支付 |
| | | Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(), "/base/competition/weChatCancelPaymentCompetitionCallback"); |
| | | String return_code = map.get("return_code"); |
| | | if(!"SUCCESS".equals(return_code)){ |
| | | // return ResultUtil.error(map.get("return_msg")); |
| | | continue; |
| | | } |
| | | String refund_id = map.get("refund_id"); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | storeClient.addBackRecord(paymentCompetition.getAmount()+"_"+paymentCompetition.getAppUserId()); |
| | | |
| | | |
| | | } |
| | | if(paymentCompetition.getPayType() == 2){//支付宝支付 |
| | | Map<String, String> map = payMoneyUtil.aliRefund(payOrderNo, amount.toString()); |
| | | String return_code = map.get("code"); |
| | | if(!"10000".equals(return_code)){ |
| | | // return ResultUtil.error(map.get("msg")); |
| | | continue; |
| | | } |
| | | String refund_id = map.get("trade_no"); |
| | | paymentCompetition.setRefundOrderNo(refund_id); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | // competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); |
| | | competitionService.updateById(competition); |
| | | } |
| | | if(paymentCompetition.getPayType() == 3){//玩湃币支付 |
| | | AppUser appUser = appUserClient.queryAppUser(paymentCompetition.getAppUserId()); |
| | | appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + amount.intValue()); |
| | | appUserClient.updateAppUser(appUser); |
| | | |
| | | paymentCompetition.setRefundOrderNo(""); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | // competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); |
| | | competitionService.updateById(competition); |
| | | } |
| | | if(paymentCompetition.getPayType() == 4){//课程支付 |
| | | List<UserCompetition> list1 = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); |
| | | for (UserCompetition userCompetition : list1) { |
| | | // Participant participant = participantService.getById(userCompetition.getId()); |
| | | // Student student = studentClient.queryStudentByPhone(participant.getPhone()); |
| | | PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour(); |
| | | paymentDeductionClassHour.setId(userCompetition.getParticipantId()); |
| | | paymentDeductionClassHour.setClassHour(competition.getClassPrice()); |
| | | paymentDeductionClassHour.setCode(code); |
| | | coursePackagePaymentClient.rollbackPaymentDeductionClassHour(paymentDeductionClassHour); |
| | | } |
| | | |
| | | paymentCompetition.setRefundOrderNo(""); |
| | | paymentCompetition.setRefundTime(new Date()); |
| | | paymentCompetition.setPayStatus(3); |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | |
| | | // competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); |
| | | competitionService.updateById(competition); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |