| | |
| | | import com.yami.trading.service.c2c.C2cPaymentMethodService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | throw new YamiShopBindException("广告不存在"); |
| | | } |
| | | |
| | | C2cPaymentMethod method =c2cPaymentMethodService.get(payment_method_id); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | if (C2cAdvert.DIRECTION_SELL.equals(c2cAdvert.getDirection())) { |
| | | C2cPaymentMethod method =c2cPaymentMethodService.get(payment_method_id); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (StringUtils.isEmptyString(order_type) || !Arrays.asList("by_amount", "by_num").contains(order_type)) { |
| | | throw new YamiShopBindException("订单类型不正确"); |
| | |
| | | return resultObject; |
| | | } |
| | | |
| | | @ApiOperation("校验是否设置支付方式") |
| | | @GetMapping(action + "payMethodCheck.action") |
| | | public Object payMethodCheck(HttpServletRequest request) { |
| | | String order_no = request.getParameter("order_no"); |
| | | Result resultObject = new Result(); |
| | | |
| | | try { |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if (null == partyId) { |
| | | throw new BusinessException("请重新登录"); |
| | | } |
| | | C2cOrder order = this.c2cOrderService.get(order_no); |
| | | if (null == order) { |
| | | throw new BusinessException("订单不存在"); |
| | | } |
| | | if (order.getMethodType() == 0) { |
| | | throw new BusinessException("订单已提交,请等待商家设置收款方式"); |
| | | } |
| | | resultObject.setCode(0); |
| | | } catch (BusinessException e) { |
| | | resultObject.setCode(1); |
| | | resultObject.setMsg(e.getMessage()); |
| | | log.error("error: {}", e.getMessage()); |
| | | } catch (Throwable t) { |
| | | resultObject.setCode(1); |
| | | //resultObject.setMsg("程序错误"); |
| | | resultObject.setMsg(t.getMessage()); |
| | | log.error("error:", t); |
| | | } |
| | | return resultObject; |
| | | } |
| | | |
| | | @RequestMapping(action + "pay_finish.action") |
| | | public Object pay_finish(HttpServletRequest request) { |
| | | String order_no = request.getParameter("order_no"); |
| | | String safe_password = request.getParameter("safe_password"); |
| | | String img = request.getParameter("img"); |
| | | |
| | | Result resultObject = new Result(); |
| | | |
| | |
| | | throw new BusinessException("订单不存在"); |
| | | } |
| | | |
| | | if (img == null || img.isEmpty()) { |
| | | throw new BusinessException("请先上传支付凭证"); |
| | | } |
| | | |
| | | if (partyId.equals(order.getPartyId())) { |
| | | // 用户操作 |
| | | if (!"buy".equals(order.getDirection())) { |
| | |
| | | |
| | | order.setState("1"); |
| | | order.setPayTime(new Date()); |
| | | order.setImg(img); |
| | | this.c2cOrderService.updateById(order); |
| | | |
| | | if (Arrays.asList("0", "1").contains(order.getState())) { |