Prechádzať zdrojové kódy

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
#	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
yeshijie 3 rokov pred
rodič
commit
a314b5d599

+ 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,

+ 10 - 12
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;
@ -47,11 +48,9 @@ public class PayEndpoint extends EnvelopRestEndpoint {
            @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);
        }
@ -59,15 +58,14 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    @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);
        }

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

@ -84,13 +84,12 @@ public class PayService {
    /**
     * 微信退款
     * @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");
@ -99,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");
        }
@ -117,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);
@ -125,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;
    }
@ -204,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<>();
@ -249,6 +248,7 @@ public class PayService {
            } catch (Exception e) {
                e.printStackTrace();
            }
            businessOrderDao.save(businessOrderDO);
            return ObjEnvelop.getSuccess("下单成功",fastdfs_file_url+fileUrl);
        } else {
            return ObjEnvelop.getError(map.get("return_msg"),-1);
@ -262,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);
@ -273,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();
        // 组装统一下单信息
@ -324,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);
    }
@ -373,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;
    }
}