liubing 3 년 전
부모
커밋
ddb6fcdec2

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/pay/WxPayHttpLogDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.care.dao.pay;
package com.yihu.jw.pay.dao;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 105 - 0
business/base-service/src/main/java/com/yihu/jw/pay/service/CloudCarePayService.java

@ -0,0 +1,105 @@
package com.yihu.jw.pay.service;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.pay.dao.WxPayHttpLogDao;
import com.yihu.jw.wechat.dao.WechatDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
import static jxl.biff.FormatRecord.logger;
/**
 * Created with IntelliJ IDEA.
 * @Author: yeshijie
 * @Date: 2021/6/28
 * @Description:
 */
@Service
public class CloudCarePayService {
    private Logger log = LoggerFactory.getLogger(CloudCarePayService.class);
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
//    @Value("${wechat.id}")
    public String wechatId="hz_yyyzh_wx";
    @Autowired
    private WxPayHttpLogDao wxPayHttpLogDao;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private BusinessOrderRefundDao orderRefundDao;
    /**
     * 微信退款
     * @param orderNo
     * @return
     * @throws Exception
     */
    public void orderRefund(String orderNo) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if (wxWechatDO==null){
            throw new Exception("this wechatId is null");
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("this orderId not exit");
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            throw new Exception("this patient not exit");
        }
        BusinessOrderRefundDO orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
        if (orderRefundDO==null){
            throw new Exception("this refund not exit");
        }
        Integer orderPrice = orderRefundDO.getOrderPrice().intValue();
        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());
        }
    }
    /**
     * 添加支付日志
     * @param type
     * @param orderNo
     * @param res
     * @param req
     */
    public void addHttpLog(String type,String orderNo,String res,String req){
        WxPayHttpLogDO logDO = new WxPayHttpLogDO();
        logDO.setType(type);
        logDO.setOrderNo(orderNo);
        logDO.setOrderReq(req);
        logDO.setOrderRes(res);
        wxPayHttpLogDao.save(logDO);
    }
    public String getOrderNo(){
        return ""+System.currentTimeMillis()+(int)(Math.random()*900)+100;
    }
}

+ 35 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/order/PayService.java

@ -1,10 +1,13 @@
package com.yihu.jw.base.service.order;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.pay.service.CloudCarePayService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.apache.commons.lang3.StringUtils;
@ -13,6 +16,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@ -30,6 +34,10 @@ public class PayService {
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private BusinessOrderRefundDao businessOrderRefundDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private CloudCarePayService payService;
    /**
     * 订单列表
@ -133,8 +141,14 @@ public class PayService {
        JSONObject result = new JSONObject();
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if ( null== businessOrderDO){
             result.put(ResponseContant.resultFlag, ResponseContant.fail);
             result.put(ResponseContant.resultMsg, "订单不存在");
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "订单不存在");
            return result;
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "患者不存在");
            return result;
        }
        if ( 3 != businessOrderDO.getStatus()){
@ -158,7 +172,8 @@ public class PayService {
        return result;
    }
    public JSONObject agreeRefund(String orderNo){
    @Transactional(rollbackFor = Exception.class)
    public JSONObject agreeRefund(String orderNo) throws Exception {
        JSONObject result = new JSONObject();
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if ( null== businessOrderDO){
@ -171,18 +186,34 @@ public class PayService {
            result.put(ResponseContant.resultMsg, "订单未申请退款或已退款,无法操作");
            return result;
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "患者不存在");
            return result;
        }
        BusinessOrderRefundDO businessOrderRefundDO = businessOrderRefundDao.selectByOrderNo(orderNo);
        if (null == businessOrderRefundDO){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "订单不存在");
            return result;
        }
        if (businessOrderRefundDO.getStatus()!=1){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "订单已处理");
            return result;
        }
        businessOrderDO.setStatus(4);
        businessOrderRefundDO.setStatus(3);
        //退款流程
        payService.orderRefund(orderNo);
        businessOrderRefundDO.setStatus(2);
        businessOrderDao.save(businessOrderDO);
        businessOrderRefundDao.save(businessOrderRefundDO);
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg, "success");
        return result;
    }

+ 21 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -267,4 +267,25 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
            return failedException2(e);
        }
    }
    @PostMapping(value = "registerForFamily")
    @ApiOperation("注册账号--绑定家人不存在时注册")
    public ObjEnvelop registerForFamily(
            @ApiParam(name="archiveType")@RequestParam(value = "archiveType")Integer archiveType,
            @ApiParam(name="idcard")@RequestParam(value = "idcard")String idcard,
            @ApiParam(name="name")@RequestParam(value = "name")String name,
            @ApiParam(name="sex")@RequestParam(value = "sex")Integer sex,
            @ApiParam(name="mobile")@RequestParam(value = "mobile")String mobile
            ){
        try {
            JSONObject result = patientService.registerForFamily(archiveType,idcard,mobile,name,sex);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("添加家人账号成功",result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
}

+ 9 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -872,8 +872,15 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                    if (businessOrderDO!=null){
                        if (1 == businessOrderDO.getStatus()){
                            //退款流程
                            payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                            orderDO.setPayStatus(2);
                            try {
                                payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                orderDO.setPayStatus(2);
                            }catch (Exception e){
                                e.printStackTrace();
                                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                                result.put(ResponseContant.resultMsg,"退款失败,无法拒绝工单!");
                                return result;
                            }
                        }
                    }
                }

+ 52 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -13,6 +13,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
@ -27,10 +28,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 
@ -341,4 +339,54 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        }
        return result;
    }
    /**
     * 为家人注册账号
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject registerForFamily(Integer archiveType,String idcard,String mobile,String name,Integer sex){
        JSONObject result = new JSONObject();
        BasePatientDO patientDetail = new BasePatientDO();
        patientDetail.setArchiveType(archiveType);
        patientDetail.setIdcard(idcard);
        patientDetail.setMobile(mobile);
        patientDetail.setName(name);
        patientDetail.setSex(sex);
        if (StringUtils.isNotBlank(patientDetail.getIdcard())){
            if (null != patientDao.findByIdcard(patientDetail.getIdcard())){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"此居民已存在,无法注册");
                return result;
            }
        }else {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"身份证不能为空");
            return result;
        }
        if (StringUtils.isNotBlank(patientDetail.getMobile())){
            if (patientDao.findByMobileAndDel(patientDetail.getMobile(),"1").size()>0){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"此居民已存在,无法注册");
                return result;
            }
        }
        idcard = patientDetail.getIdcard();
        String pw = idcard.substring(idcard.length()-6);
        String salt = UUID.randomUUID().toString().substring(0,5);
        patientDetail.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
        patientDetail.setSalt(salt);
        patientDetail.setDel("1");
        patientDetail.setEnabled(1);
        patientDetail.setArchiveStatus(3);
        patientDetail.setLocked(0);
        patientDetail.setCreateTime(new Date());
        patientDetail.setUpdateTime(new Date());
        patientDao.save(patientDetail);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,patientDetail);
        return result;
    }
}

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

@ -8,7 +8,6 @@ import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachFeeDetailDao;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareFeeDetailDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.dao.pay.WxPayHttpLogDao;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.util.WxpayUtil;
@ -26,6 +25,7 @@ import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.pay.dao.WxPayHttpLogDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.util.common.IpUtil;
@ -57,7 +57,7 @@ import static jxl.biff.FormatRecord.logger;
 */
@Service
public class PayService {
    private Logger log = LoggerFactory.getLogger(PatientDoorCoachOrderService.class);
    private Logger log = LoggerFactory.getLogger(PayService.class);
    @Autowired
    private BasePatientDao patientDao;
@ -472,9 +472,10 @@ public class PayService {
        log.error("【支付通知】请求,payWater:{}", orderDO);
        String type = "";
        //防止重复支付
        if (orderDO.getStatus()!=0) {
        if (orderDO.getStatus()!=1) {
            return;
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderDO.getOrderNo());
        switch (type){
            case "1":
                //desc = "招生报名";
@ -484,11 +485,11 @@ public class PayService {
                break;
            case "3":
                //desc = "上门辅导";
//                doorCoachOrderService.payOrderAfter(orderDO.getRelationCode());
                doorCoachOrderService.refundOrderAfter(businessOrderDO.getRelationCode());
                break;
            case "4":
                //desc = "生活照料服务";
               // lifeCareOrderService.payOrderAfter(orderDO.getRelationCode());
                lifeCareOrderService.refundOrderAfter(businessOrderDO.getRelationCode());
                break;
            default:
                break;