Browse Source

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 3 years ago
parent
commit
48eb85ba16

+ 1 - 1
common/common-entity/sql记录

@ -1069,7 +1069,7 @@ CREATE TABLE `base_service_news` (
-- 2021-06-29 ysj
CREATE TABLE `base_wx_pay_http_log` (
  `id` varchar(50) NOT NULL,
  `type` varchar(1) DEFAULT NULL COMMENT '类型1 统一下单 2支付回调',
  `type` varchar(1) DEFAULT NULL COMMENT '类型1 统一下单 2支付回调 3退款 4 退款回调',
  `order_no` varchar(50) DEFAULT NULL COMMENT '订单号',
  `order_res` text,
  `order_req` text,

+ 13 - 15
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java

@ -7,6 +7,7 @@ import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
@ -41,39 +42,36 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    private BusinessOrderDao businessOrderDao;
    @GetMapping(value = "wxWapPay")
    @PostMapping(value = "wxWapPay")
    @ApiOperation(value = "微信wap支付")
    public ObjEnvelop wxWapPay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上面辅导id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) Integer orderId,
            @ApiParam(name = "patientId", value = "居民id")
            @RequestParam(value = "patientId", required = true) String patientId,HttpServletRequest request) {
            @RequestParam(value = "orderId", required = false) Integer orderId,HttpServletRequest request) {
        try{
            return  payService.wxWapPay(relationId, orderId, patientId, request);
            return  payService.wxWapPay(relationId, orderId, request);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "wxRefund")
    @PostMapping(value = "wxRefund")
    @ApiOperation(value = "微信发起退款")
    public ObjEnvelop wxRefund(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上面辅导id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) Integer orderId,
            @ApiParam(name = "patientId", value = "居民id")
            @RequestParam(value = "patientId", required = true) String patientId,HttpServletRequest request) {
    public Envelop wxRefund(
            @ApiParam(name = "desc", value = "退款说明")
            @RequestParam(value = "desc", required = true) String desc,
            @ApiParam(name = "orderNo", value = "订单id")
            @RequestParam(value = "orderNo", required = true) String orderNo) {
        try{
            return  payService.wxWapPay(relationId, orderId, patientId, request);
              payService.orderRefund(orderNo, desc);
            return success("发起退款成功");
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "wxNativePay")
    @PostMapping(value = "wxNativePay")
    @ApiOperation(value = "微信native支付")
    public ObjEnvelop wxNativePay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上面辅导id")

+ 19 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java

@ -79,16 +79,17 @@ public class PayService {
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private PatientDoorCoachOrderService doorCoachOrderService;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    /**
     * 微信退款
     * @param patient
     * @param orderNo
     * @param description
     * @return
     * @throws Exception
     */
    public Map<String,Object> orderRefund(String patient,String orderNo,String description) throws Exception {
    public void orderRefund(String orderNo,String description) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if (wxWechatDO==null){
            throw new Exception("this wechatId is null");
@ -97,7 +98,7 @@ public class PayService {
        if (businessOrderDO==null){
            throw new Exception("this orderId not exit");
        }
        BasePatientDO patientDO = patientDao.findById(patient);
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            throw new Exception("this patient not exit");
        }
@ -115,7 +116,7 @@ public class PayService {
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("CARE"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        orderRefundDO.setPatient(patient);
        orderRefundDO.setPatient(businessOrderDO.getPatient());
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
@ -123,11 +124,11 @@ public class PayService {
        Integer refundPrice1 = orderRefundDO.getRefundPrice().intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
        logger.info("map"+map);
        addHttpLog("1",businessOrderDO.getOrderNo(),null,map.toString());
        if (map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
            //退款申请提交成功
            throw new Exception(map.get("return_msg").toString());
        }
        return map;
    }
@ -202,7 +203,7 @@ public class PayService {
        if (businessOrderDO.getStatus()!=0) {
            return ObjEnvelop.getError("待支付订单才能支付",-1);
        }
        businessOrderDO.setOrderNo(getOrderNo());
        String noceStr = WxpayUtil.getNonceStr();
        // 组装统一下单信息
        SortedMap<String, String> reqMap = new TreeMap<>();
@ -247,7 +248,8 @@ public class PayService {
            } catch (Exception e) {
                e.printStackTrace();
            }
            return ObjEnvelop.getSuccess("下单成功",serverUrl+fileUrl);
            businessOrderDao.save(businessOrderDO);
            return ObjEnvelop.getSuccess("下单成功",fastdfs_file_url+fileUrl);
        } else {
            return ObjEnvelop.getError(map.get("return_msg"),-1);
        }
@ -260,7 +262,7 @@ public class PayService {
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public ObjEnvelop wxWapPay(String relationId,Integer orderId,String patientId,HttpServletRequest request) throws Exception {
    public ObjEnvelop wxWapPay(String relationId,Integer orderId,HttpServletRequest request) throws Exception {
        BusinessOrderDO businessOrderDO;
        if(StringUtil.isBlank(relationId)){
            businessOrderDO = businessOrderDao.findOne(orderId);
@ -271,7 +273,8 @@ public class PayService {
        if (businessOrderDO.getStatus()!=0) {
            return ObjEnvelop.getError("待支付订单才能支付",-1);
        }
        BasePatientDO patientDO = patientDao.findById(patientId);
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        businessOrderDO.setOrderNo(getOrderNo());
        String noceStr = WxpayUtil.getNonceStr();
        // 组装统一下单信息
@ -322,6 +325,7 @@ public class PayService {
        String paySign = WxpayUtil.createSign(payMap, apiKey);
        payMap.put("paySign", paySign);
        log.error("【微信支付】WAP支付订单信息:{}", payMap);
        businessOrderDao.save(businessOrderDO);
        return ObjEnvelop.getSuccess("下单成功",payMap);
    }
@ -371,11 +375,15 @@ public class PayService {
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setStatus(0);
        businessOrderDO.setOrderNo(""+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        businessOrderDO.setOrderNo(getOrderNo());
        businessOrderDO.setUploadStatus(0);
        businessOrderDO.setPayType(1);
        businessOrderDO.setPayPrice(Double.valueOf(price));
        businessOrderService.save(businessOrderDO);
        return businessOrderDO;
    }
    public String getOrderNo(){
        return ""+System.currentTimeMillis()+(int)(Math.random()*900)+100;
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/resources/application.yml

@ -422,7 +422,7 @@ spring:
    port: 6379  # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://10.18.43.40:8888/
  fastdfs_file_url: https://zhyzh.hzxc.gov.cn/fastdfs/
fast-dfs:
  tracker-server: 10.18.43.40:22122 #服务器地址
# 短信验证码发送的客户端标识,居民端