Bladeren bron

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie 7 jaren geleden
bovenliggende
commit
0f35c661f1

+ 140 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/ylz/PayLog.java

@ -0,0 +1,140 @@
package com.yihu.wlyy.entity.ylz;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 易联众相关支付log表
 * Created by Reece on 2017/9/20.
 */
@Entity
@Table(name = "ylz_pay_log")
public class PayLog extends IdEntity {
    // 接口类型 0家庭签约支付 1续方支付
    private String type;
    // 业务内容
    private String content;
    // 调用接口
    private String api;
    // 调用方式
    private String method;
    // 调用参数
    private String params;
    // 调用头部信息
    private String header;
    // 返回结果
    private String response;
    // 状态 0失败 1成功 2已重试
    private String status;
    // 重试次数
    private Integer retryTimes;
    // 创建时间
    private Date createTime;
    //异常信息
    private String error;
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "api")
    public String getApi() {
        return api;
    }
    public void setApi(String api) {
        this.api = api;
    }
    @Column(name = "method")
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "params")
    public String getParams() {
        return params;
    }
    public void setParams(String params) {
        this.params = params;
    }
    @Column(name = "header")
    public String getHeader() {
        return header;
    }
    public void setHeader(String header) {
        this.header = header;
    }
    @Column(name = "response")
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "retry_times")
    public Integer getRetryTimes() {
        return retryTimes;
    }
    public void setRetryTimes(Integer retryTimes) {
        this.retryTimes = retryTimes;
    }
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "error")
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -55,7 +55,7 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
     */
    @Modifying
    @Query("update WlyyCharge a set a.tradeStatus = ?9,a.chargeTime = ?2, a.updateTime = ?3, a.totalAmount = ?4, " +
            " a.insuranceAmount = ?5, a.selfpayAmount =?6 ,a.billNo = ?7, a.miRegisterNo = ?8 where a.code = ?1 ")
            " a.insuranceAmount = ?5, a.selfpayAmount =?6 ,a.billNo = ?7, a.miRegisterNo = ?8, a.needUpload = '1' where a.code = ?1 ")
    int updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/ylz/PayLogDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.ylz;
import com.yihu.wlyy.entity.httpLog.HttpLog;
import com.yihu.wlyy.entity.ylz.PayLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/9/20.
 */
public interface PayLogDao extends PagingAndSortingRepository<PayLog, Long>,JpaSpecificationExecutor<PayLog> {
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -25,6 +25,7 @@ import com.yihu.wlyy.repository.zydict.ZyPushLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
@ -80,7 +81,7 @@ public class PatientPrescriptionPayService extends BaseService {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private LogService logService;
    private PayLogService logService;
    @Autowired
    private PatientDao patientDao;
    @Autowired

+ 60 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/ylz/PayLogService.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.service.third.ylz;
import com.yihu.wlyy.entity.httpLog.HttpLog;
import com.yihu.wlyy.entity.ylz.PayLog;
import com.yihu.wlyy.repository.httplog.HttpLogDao;
import com.yihu.wlyy.repository.ylz.PayLogDao;
import com.yihu.wlyy.service.system.SystemDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * Created by Reece on 2017/9/20.
 * 日志服务
 */
@Service
public class PayLogService {
    @Autowired
    private PayLogDao payLogDao;
    @Autowired
    private SystemDictService systemDictService;
    public String onepayType = "0"; //0家庭签约支付
    public String onepayRecipeType = "1";     //1续方支付
    /**
     * 保存http调用日志  type 0家庭签约支付 1续方支付
     */
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    {
        try {
            //成功日志是否保存
            Boolean saveSuccessLog = systemDictService.getSaveSuccessLog();
            if(!isSuccess || saveSuccessLog) {
                //新增日志
                PayLog log = new PayLog();
                log.setType(type);
                log.setApi(url);
                log.setContent(content);
                log.setMethod(method);
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                payLogDao.save(log);
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
@ -50,7 +51,7 @@ public class OnePayService {
    private Configure config;
    @Autowired
    private LogService logService;
    private PayLogService logService;
    private String signType = "MD5";
    private String encryptType = "AES";
@ -355,6 +356,7 @@ public class OnePayService {
        chargeDao.save(charge);
        //保存http日志
//        logService.saveHttpLog(isSuccess, config.getChargeType(), "家庭医生签约支付", "POST", null, msgBody, response, error, logService.onepayType);
        logService.saveHttpLog(isSuccess, config.getChargeType(), "家庭医生签约支付", "POST", null, msgBody, response, error, logService.onepayType);
        if (!isSuccess) {

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
@ -67,7 +68,7 @@ public class OnePayController extends WeixinBaseController {
    @Autowired
    private ChargeDao chargeDao;
    @Autowired
    LogService logService;
    PayLogService logService;
    @Autowired
    private Configure config;
    @Autowired
@ -325,8 +326,10 @@ public class OnePayController extends WeixinBaseController {
//                判断是否需要更新数据 needUpload为0不需要更新
            WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
            LOGGER.info("before  goto "+charge.getNeedUpload()+" == "+ outChargeNo);
            if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
                LOGGER.info("after  goto "+charge.getNeedUpload()+" == "+ outChargeNo);
            }
        } catch (Exception e) {
@ -426,8 +429,10 @@ public class OnePayController extends WeixinBaseController {
//                判断是否需要更新数据 needUpload为0不需要更新
                    WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
                    LOGGER.info("before  goto "+charge.getNeedUpload()+" == "+ outChargeNo);
                    if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                        pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
                        LOGGER.info("after  goto "+charge.getNeedUpload()+" == "+ outChargeNo);
                    }
                    response.getWriter().write("SUCCESS");