Browse Source

修改取药码多次调用多次生成的bug

liuwenbin 7 years ago
parent
commit
6a25a1fa55

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDispensaryCodeDao.java

@ -42,4 +42,5 @@ public interface PrescriptionDispensaryCodeDao extends PagingAndSortingRepositor
    void updateToUse(String prescriptionCode, Integer type);
    PrescriptionDispensaryCode findByCodeAndIsUse(String code, Integer isUse);
    PrescriptionDispensaryCode findByPrescriptionCodeAndIsUseAndType(String prescriptionCode, Integer isUse,Integer type);
}

+ 25 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -114,28 +114,38 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        return false;
    }
    public boolean saveQRCode(String token,String prescriptionCode) throws Exception {
    @Transactional
    public void saveQRCode(String token,String prescriptionCode) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        //取药类型:1 自取 2快递配送 3健管师配送
        Integer type = prescription.getDispensaryType();
        PrescriptionDispensaryCode p1 = savePatientQRCode(token,prescriptionCode);
        PrescriptionDispensaryCode p1 = prescriptionDispensaryCodeDao.findByPrescriptionCodeAndIsUseAndType(prescriptionCode,0,1);
        if(p1==null){
            p1 = savePatientQRCode(token,prescriptionCode);
        }
        if(p1==null){
            throw new Exception("二维码生成失败!");
        }
        if(type==3){
            if(p1!=null){
            PrescriptionDispensaryCode p2 = prescriptionDispensaryCodeDao.findByPrescriptionCodeAndIsUseAndType(prescriptionCode,0,2);
            if(p2==null){
                PrescriptionDispensaryCode p2 = saveQRCode(p1.getCode(),token,prescriptionCode,2);
                if(p2!=null){
                    PrescriptionDispensaryCode p3 = saveQRCode(p1.getCode(),token,prescriptionCode,3);
                    if(p3==null){
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
                p2 = saveQRCode(p1.getCode(),token,prescriptionCode,2);
            }
            if(p2==null){
                throw new Exception("二维码生成失败!");
            }
            PrescriptionDispensaryCode p3 = prescriptionDispensaryCodeDao.findByPrescriptionCodeAndIsUseAndType(prescriptionCode,0,3);
            if(p3==null){
                p3 = saveQRCode(p1.getCode(),token,prescriptionCode,3);
            }
            if(p3==null){
                throw new Exception("二维码生成失败!");
            }
        }
        return true;
    }
    //生成居民端取药码

+ 2 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -53,12 +53,8 @@ public class PatientPrescriptionController extends WeixinBaseController {
            @ApiParam(required = true, name = "prescriptionCode", value = "处方code") @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode) {
        try {
            boolean b = prescriptionDispensaryCodeService.saveQRCode(getAccessToken(), prescriptionCode);
            if (b) {
                return write(200, "生成二维码成功!");
            } else {
                return error(-1, "生成二维码失败!");
            }
            prescriptionDispensaryCodeService.saveQRCode(getAccessToken(), prescriptionCode);
            return write(200, "生成二维码成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "生成二维码失败!");