| | |
| | | package com.doumee.api.web.mall; |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.api.web.ApiController; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.config.wx.WxMiniConfig; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.utils.ID; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.model.ActivitySign; |
| | | import com.doumee.dao.business.model.Fund; |
| | | import com.doumee.dao.business.model.Goodsorder; |
| | | import com.doumee.service.business.OrdersService; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | @CrossOrigin |
| | | public class PaymentCallback extends ApiController { |
| | | |
| | | @Autowired |
| | | private OrdersService ordersService; |
| | | |
| | | |
| | | @PostMapping("/web/api/wxPayNotify") |
| | | public String wxPay_notify(@RequestBody String xmlResult) { |
| | |
| | | //微信订单号 |
| | | String paymentNo = result.getTransactionId(); |
| | | |
| | | if (Constants.SUCCESS_STR.equals(result.getReturnCode())) { |
| | | |
| | | |
| | | if (Constants.SUCCESS.equals(result.getReturnCode())) { |
| | | // 支付成功 |
| | | switch (result.getAttach()) { |
| | | //活动参与支付 |
| | | case "ActivitySign": { |
| | | ActivitySign activitySign = activitySignService.findById(Integer.valueOf(outTradeNo)); |
| | | if(Objects.isNull(activitySign)){ |
| | | return WxPayNotifyResponse.fail( "支付回调信息("+ wxId + ") = > 未查询到支付对象信息!"); |
| | | } |
| | | if(activitySign.getStatus().equals(Constants.ONE)){ |
| | | return WxPayNotifyResponse.success("处理成功!"); |
| | | } |
| | | activitySign.setPayStatus(Constants.ONE); |
| | | activitySign.setPayDate(new Date()); |
| | | activitySign.setPayOrderId(paymentNo); |
| | | activitySign.setStatus(Constants.ONE); |
| | | activitySignService.updateById(activitySign); |
| | | //寄存订单 |
| | | case "storageOrder": { |
| | | ordersService.handleStorageOrderPayNotify(outTradeNo, paymentNo); |
| | | break; |
| | | } |
| | | case "terraceMall": { |
| | | Goodsorder DBGoodsOrder = new Goodsorder(); |
| | | DBGoodsOrder.setCode(Long.valueOf(outTradeNo)); |
| | | Goodsorder goodsOrder = goodsorderService.findOne(DBGoodsOrder); |
| | | if(Objects.isNull(goodsOrder)){ |
| | | return WxPayNotifyResponse.fail( "支付回调信息("+ wxId + ") = > 未查询到支付对象信息!"); |
| | | } |
| | | if(goodsOrder.getStatus().equals(Constants.ONE)){ |
| | | return WxPayNotifyResponse.success("处理成功!"); |
| | | } |
| | | goodsOrder.setPayStatus(Constants.ONE); |
| | | goodsOrder.setPayDate(new Date()); |
| | | goodsOrder.setPayOrderId(paymentNo); |
| | | goodsOrder.setStatus(Constants.OrderStatus.PAY_DONE.getKey()); |
| | | goodsOrder.setPayMethod(Constants.ZERO); |
| | | goodsorderService.updateById(goodsOrder); |
| | | //生成 咖啡计划订单明细表 |
| | | if(goodsOrder.getType().equals(Constants.TWO)){ |
| | | planorderDetailService.createPlanOrderDetail(goodsOrder); |
| | | } |
| | | Fund fund = new Fund(); |
| | | fund.setOrderCode(goodsOrder.getPayOrderId()); |
| | | fund.setCreator(goodsOrder.getMemberId()); |
| | | fund.setCreateDate(new Date()); |
| | | fund.setIsdeleted(Constants.ZERO); |
| | | fund.setRemark(goodsOrder.getCode().toString()); |
| | | fund.setMemberId(goodsOrder.getMemberId()); |
| | | fund.setTitle("订单支付"); |
| | | fund.setContent("订单支付"); |
| | | fund.setObjId(goodsOrder.getId()); |
| | | fund.setObjType(Constants.ONE); |
| | | fund.setType(Constants.ZERO); |
| | | fund.setNum(goodsOrder.getPrice()); |
| | | fundService.create(fund); |
| | | //店铺押金订单 |
| | | case "shopDeposit": { |
| | | ordersService.handleShopDepositPayNotify(outTradeNo, paymentNo); |
| | | break; |
| | | } |
| | | case "shopGoods": { |
| | | Goodsorder DBGoodsOrder = new Goodsorder(); |
| | | DBGoodsOrder.setCode(Long.valueOf(outTradeNo)); |
| | | Goodsorder goodsOrder = goodsorderService.findOne(DBGoodsOrder); |
| | | if(Objects.isNull(goodsOrder)){ |
| | | return WxPayNotifyResponse.fail( "支付回调信息("+ wxId + ") = > 未查询到支付对象信息!"); |
| | | } |
| | | if(goodsOrder.getStatus().equals(Constants.ONE)){ |
| | | return WxPayNotifyResponse.success("处理成功!"); |
| | | } |
| | | goodsOrder.setPayStatus(Constants.ONE); |
| | | goodsOrder.setPayDate(new Date()); |
| | | goodsOrder.setPayOrderId(paymentNo); |
| | | goodsOrder.setStatus(Constants.OrderStatus.PAY_DONE.getKey()); |
| | | //生成核销码 |
| | | if(Constants.equalsInteger(goodsOrder.getReceiveType(),Constants.ONE)){ |
| | | goodsOrder.setExchangeCode(goodsorderService.createExchangeCode()); |
| | | } |
| | | goodsOrder.setPayMethod(Constants.ZERO); |
| | | goodsorderService.updateById(goodsOrder); |
| | | if(Objects.nonNull(goodsOrder.getPickUpShopId())){ |
| | | //发送站内信 - 经销商 |
| | | noticeService.orderPayNotice(goodsOrder.getPickUpShopId(),goodsOrder.getId(),goodsOrder.getReceiveType()); |
| | | } |
| | | Fund fund = new Fund(); |
| | | fund.setOrderCode(goodsOrder.getPayOrderId()); |
| | | fund.setCreator(goodsOrder.getMemberId()); |
| | | fund.setCreateDate(new Date()); |
| | | fund.setIsdeleted(Constants.ZERO); |
| | | fund.setRemark(goodsOrder.getCode().toString()); |
| | | fund.setMemberId(goodsOrder.getMemberId()); |
| | | fund.setTitle("订单支付"); |
| | | fund.setContent("订单支付"); |
| | | fund.setObjId(goodsOrder.getId()); |
| | | fund.setObjType(Constants.ONE); |
| | | fund.setType(Constants.ZERO); |
| | | fund.setNum(goodsOrder.getPrice()); |
| | | fundService.create(fund); |
| | | //逾期费用订单 |
| | | case "overdueFee": { |
| | | ordersService.handleOverdueFeePayNotify(outTradeNo, paymentNo); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | return WxPayNotifyResponse.success("处理成功!"); |
| | | } |