Parcourir la source

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

liubing il y a 3 ans
Parent
commit
d7897ef316

+ 39 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/order/PayService.java

@ -2,11 +2,14 @@ package com.yihu.jw.base.service.order;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
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.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.pay.dao.WxPayHttpLogDao;
import com.yihu.jw.pay.service.CloudCarePayService;
import com.yihu.jw.pay.service.CloudCarePayService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -14,10 +17,12 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -38,6 +43,12 @@ public class PayService {
    private BasePatientDao patientDao;
    private BasePatientDao patientDao;
    @Autowired
    @Autowired
    private CloudCarePayService payService;
    private CloudCarePayService payService;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Value("${wechat.id}")
    public String wechatId;
    @Autowired
    private WxPayHttpLogDao wxPayHttpLogDao;
    /**
    /**
     * 订单列表
     * 订单列表
@ -99,8 +110,8 @@ public class PayService {
                                    Integer page,Integer pageSize){
                                    Integer page,Integer pageSize){
        page = page>0?page-1:0;
        page = page>0?page-1:0;
        String sql = " select pay.patient,pay.patient_name,pay.order_no,pay.order_type,pay.order_category,pay.relation_code, " +
        String sql = " select pay.patient,pay.patient_name,pay.order_no,pay.order_type,pay.order_category,pay.relation_code, " +
                " pay.relation_name,pay.description,pay.pay_type,pay.pay_price,pay.yk_order_id,DATE_FORMAT(re.create_time,'%Y-%m-%d %H:%i:%S') create_time, " +
                " re.enclosure,re.refund_desc,re.`status` from base_business_order_pay pay inner JOIN base_business_order_refund re on  " +
                " pay.relation_name,pay.description payDescription,pay.pay_type,pay.pay_price,pay.yk_order_id,DATE_FORMAT(re.create_time,'%Y-%m-%d %H:%i:%S') create_time, " +
                " re.enclosure,re.refund_desc description,re.refuse_desc,re.`status` from base_business_order_pay pay inner JOIN base_business_order_refund re on  " +
                " pay.order_no = re.order_no where pay.status>=3  ";
                " pay.order_no = re.order_no where pay.status>=3  ";
        String sqlCount = "select count(re.id) from base_business_order_pay pay inner JOIN " +
        String sqlCount = "select count(re.id) from base_business_order_pay pay inner JOIN " +
                " base_business_order_refund re on pay.order_no = re.order_no where pay.status>=3 ";
                " base_business_order_refund re on pay.order_no = re.order_no where pay.status>=3 ";
@ -205,16 +216,37 @@ public class PayService {
        }
        }
        businessOrderDO.setStatus(4);
        businessOrderDO.setStatus(4);
        businessOrderRefundDO.setStatus(3);
        businessOrderRefundDO.setStatus(3);
        //退款流程
        payService.orderRefund(orderNo);
        businessOrderRefundDO.setStatus(2);
        businessOrderDao.save(businessOrderDO);
        businessOrderDao.save(businessOrderDO);
        businessOrderRefundDao.save(businessOrderRefundDO);
        businessOrderRefundDao.save(businessOrderRefundDO);
        //退款流程
        Integer orderPrice = new BigDecimal(businessOrderRefundDO.getOrderPrice()*100).intValue();
        Integer refundPrice1 = new BigDecimal(businessOrderRefundDO.getRefundPrice()*100).intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,businessOrderRefundDO.getOrderNo(),businessOrderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),businessOrderRefundDO.getRefundDesc());
        log.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());
        }
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg, "success");
        result.put(ResponseContant.resultMsg, "success");
        return result;
        return result;
    }
    }
    /**
     * 添加支付日志
     * @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);
    }
}
}

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

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -37,8 +36,6 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    private CarePatientService patientService;
    private CarePatientService patientService;
    @Autowired
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    ServicesAuthAOP servicesAuthAOP;
    public int num = 20;
    public int num = 20;
    @GetMapping(value = "testException")
    @GetMapping(value = "testException")

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -548,4 +548,16 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
            return failedListEnvelopException2(e);
        }
        }
    }
    }
    @GetMapping(value="findAllAgedPatient")
    @ApiOperation(value = "获取所有老人根据身份证或姓名")
    public ListEnvelop findAllPatient(@ApiParam(name="name",value = "姓名或身份证",required = false)
                                          @RequestParam(value = "name")String name){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findAllAgedPatient(name));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}
}

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

@ -873,7 +873,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                        if (1 == businessOrderDO.getStatus()){
                        if (1 == businessOrderDO.getStatus()){
                            //退款流程
                            //退款流程
                            try {
                            try {
                                payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                payService.dispatcherOrderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                orderDO.setPayStatus(2);
                                orderDO.setPayStatus(2);
                            }catch (Exception e){
                            }catch (Exception e){
                                e.printStackTrace();
                                e.printStackTrace();
@ -1375,8 +1375,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            switch (statustemp){
            switch (statustemp){
                case -1:statusName="已取消";break;
                case -1:statusName="已取消";break;
                case 0:statusName="待付款";break;
                case 0:statusName="待付款";break;
                case 1:statusName="待服务";break;
                case 2:statusName="待服务";break;
                case 1:statusName="待接单";break;
                case 2:statusName="待接单";break;
                case 3:statusName="待服务";break;
                case 3:statusName="待服务";break;
                case 4:statusName="待服务";break;
                case 4:statusName="待服务";break;
                case 5:statusName="已完成";break;
                case 5:statusName="已完成";break;

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

@ -240,12 +240,12 @@ public class PayService {
        }
        }
        if("3".equals(type)){
        if("3".equals(type)){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if(!"6".equals(orderDO.getStatus())){
            if(6!=orderDO.getStatus()){
                return "工单为已完成状态时,才可申请退款";
                return "工单为已完成状态时,才可申请退款";
            }
            }
        }else if("4".equals(type)){
        }else if("4".equals(type)){
            LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
            LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
            if(!"2".equals(orderDO.getStatus())){
            if(2!=orderDO.getStatus()){
                return "工单为已完成状态时,才可申请退款";
                return "工单为已完成状态时,才可申请退款";
            }
            }
        }
        }
@ -410,6 +410,56 @@ public class PayService {
    }
    }
    /**
     * 调度员拒单工单微信退款(不生成售后数据)
     * @param orderNo
     * @param description
     * @return
     * @throws Exception
     */
    public void dispatcherOrderRefund(String orderNo,String description) 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){
            orderRefundDO = new BusinessOrderRefundDO();
        }
        orderRefundDO.setCreateTime(new Date());
        orderRefundDO.setUpdateTime(new Date());
        orderRefundDO.setStatus(1);
        orderRefundDO.setOrderNo(orderNo);
        orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setRefundPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("CAREDISPATCHER"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        orderRefundDO.setPatient(businessOrderDO.getPatient());
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
        Integer orderPrice = new BigDecimal(orderRefundDO.getOrderPrice()*100).intValue();
        Integer refundPrice1 = new BigDecimal(orderRefundDO.getRefundPrice()*100).intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
        log.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 type
@ -499,8 +549,12 @@ public class PayService {
        }
        }
        orderDO.setStatus(2);
        orderDO.setStatus(2);
        orderDO.setRefundTime(new Date());
        orderDO.setRefundTime(new Date());
        businessOrderDO.setStatus(4);
        orderRefundDao.save(orderDO);
        if (orderDO.getOutRefundNo().contains("CAREDISPATCHER")){//调度员拒单时 不生成售后订单
            orderRefundDao.delete(orderDO.getId());
        }else {
            businessOrderDO.setStatus(4);
            orderRefundDao.save(orderDO);
        }
        businessOrderDao.save(businessOrderDO);
        businessOrderDao.save(businessOrderDO);
        log.info("【退款通知】成功,type:{}", type);
        log.info("【退款通知】成功,type:{}", type);
    }
    }

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -555,4 +555,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        }
        }
        return jdbcTemplate.queryForList(sql);
        return jdbcTemplate.queryForList(sql);
    }
    }
    public List<Map<String,Object>> findAllAgedPatient(String name){
        String sql ="SELECT distinct p.id,p.name,p.sex,p.idcard,p.photo,p.mobile from base_patient p where p.archive_type=1 and p.del=1  ";
        if (StringUtils.isNotBlank(name)){
            sql+=" and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        return jdbcTemplate.queryForList(sql);
    }
}
}