Commit ce94556c9f164024c5496fd73d8d00e6b9fafe58
1 parent
ed6c6c92c0
Exists in
master
and in
6 other branches
同步
Showing 2 changed files with 207 additions and 12 deletions
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
ce94556
| ... | ... | @@ -335,7 +335,22 @@ |
| 335 | 335 | </select> |
| 336 | 336 | |
| 337 | 337 | <select id="findUsedUserIds" parameterType="map" resultType="string"> |
| 338 | - select distinct(b.user_id) | |
| 338 | + select distinct( user_id) from (select c.id from coupon_template c INNER JOIN (select id from coupon_type d where d.type in | |
| 339 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 340 | + #{type} | |
| 341 | + </foreach> | |
| 342 | + ) t on c.type_id = t.id) m INNER JOIN | |
| 343 | + ( select coupon_template_id,status,use_date,user_id,used_hospital_id from coupon_info where used_hospital_id = #{hid} and status = 2 | |
| 344 | + <if test="startDate != null"> | |
| 345 | + and b.use_date >= #{startDate} | |
| 346 | + </if> | |
| 347 | + <if test="endDate != null"> | |
| 348 | + and b.use_date <![CDATA[ < ]]> #{endDate} | |
| 349 | + </if> | |
| 350 | + ) a on m.id = a.coupon_template_id | |
| 351 | + | |
| 352 | + | |
| 353 | + <!--select distinct(b.user_id) | |
| 339 | 354 | from organization a, coupon_info b, coupon_template c, coupon_type d |
| 340 | 355 | where a.id = b.used_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id |
| 341 | 356 | and a.id = #{hid} |
| 342 | 357 | |
| ... | ... | @@ -349,11 +364,54 @@ |
| 349 | 364 | </if> |
| 350 | 365 | <if test="endDate != null"> |
| 351 | 366 | and b.use_date <![CDATA[ < ]]> #{endDate} |
| 352 | - </if> | |
| 367 | + </if>--> | |
| 353 | 368 | </select> |
| 354 | 369 | |
| 355 | 370 | <select id="findUsedUserIds2" parameterType="map" resultType="string"> |
| 356 | - select distinct(b.user_id) | |
| 371 | + | |
| 372 | + SELECT | |
| 373 | + distinct( user_id) | |
| 374 | + FROM | |
| 375 | + ( | |
| 376 | + SELECT | |
| 377 | + c.id | |
| 378 | + FROM | |
| 379 | + coupon_template c | |
| 380 | + INNER JOIN ( | |
| 381 | + SELECT | |
| 382 | + id | |
| 383 | + FROM | |
| 384 | + coupon_type d | |
| 385 | + WHERE | |
| 386 | + d.type IN | |
| 387 | + ( | |
| 388 | + '1' | |
| 389 | + , | |
| 390 | + '2' | |
| 391 | + ) | |
| 392 | + ) t ON c.type_id = t.id | |
| 393 | + ) m | |
| 394 | + INNER JOIN ( | |
| 395 | + SELECT | |
| 396 | + coupon_template_id, | |
| 397 | + user_id, | |
| 398 | + used_hospital_id, | |
| 399 | + create_date | |
| 400 | + FROM | |
| 401 | + coupon_info | |
| 402 | + WHERE | |
| 403 | + used_hospital_id = #{hid} | |
| 404 | + and status = 2 | |
| 405 | + <if test="startDate != null"> | |
| 406 | + and use_date >= #{startDate} | |
| 407 | + </if> | |
| 408 | + <if test="endDate != null"> | |
| 409 | + and use_date <![CDATA[ < ]]> #{endDate} | |
| 410 | + </if> | |
| 411 | + ) a ON m.id = a.coupon_template_id | |
| 412 | + | |
| 413 | + | |
| 414 | + <!-- select distinct(b.user_id) | |
| 357 | 415 | from organization a, (select * from coupon_info where used_hospital_id = #{hid}) b, coupon_template c, |
| 358 | 416 | coupon_type d |
| 359 | 417 | where a.id = b.used_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id |
| ... | ... | @@ -368,7 +426,7 @@ |
| 368 | 426 | </if> |
| 369 | 427 | <if test="endDate != null"> |
| 370 | 428 | and b.use_date <![CDATA[ < ]]> #{endDate} |
| 371 | - </if> | |
| 429 | + </if>--> | |
| 372 | 430 | </select> |
| 373 | 431 | |
| 374 | 432 | <select id="findHospitalUsedInfo" parameterType="map" resultType="map"> |
| ... | ... | @@ -391,7 +449,55 @@ |
| 391 | 449 | </select> |
| 392 | 450 | |
| 393 | 451 | <select id="findHospitalUsedInfo2" parameterType="map" resultType="map"> |
| 394 | - select a.id, count(distinct(b.user_id)) as user_used_count, count(1) as coupon_used_count, a.area_id, a.city_id, | |
| 452 | + SELECT | |
| 453 | + o.id, | |
| 454 | + count(DISTINCT(user_id)) AS user_used_count, | |
| 455 | + count(1) AS coupon_used_count, | |
| 456 | + o.area_id, | |
| 457 | + o.city_id, | |
| 458 | + o.province_id | |
| 459 | + FROM | |
| 460 | + ( | |
| 461 | + SELECT | |
| 462 | + c.id | |
| 463 | + FROM | |
| 464 | + coupon_template c | |
| 465 | + INNER JOIN ( | |
| 466 | + SELECT | |
| 467 | + id | |
| 468 | + FROM | |
| 469 | + coupon_type d | |
| 470 | + WHERE | |
| 471 | + d.type IN | |
| 472 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 473 | + #{type} | |
| 474 | + </foreach> | |
| 475 | + ) t ON c.type_id = t.id | |
| 476 | + ) m | |
| 477 | + INNER JOIN ( | |
| 478 | + SELECT | |
| 479 | + coupon_template_id, | |
| 480 | + STATUS, | |
| 481 | + use_date, | |
| 482 | + user_id, | |
| 483 | + used_hospital_id | |
| 484 | + FROM | |
| 485 | + coupon_info | |
| 486 | + WHERE | |
| 487 | + used_hospital_id = #{hid} | |
| 488 | + AND STATUS = 2 | |
| 489 | + <if test="startDate != null"> | |
| 490 | + and use_date >= #{startDate} | |
| 491 | + </if> | |
| 492 | + <if test="endDate != null"> | |
| 493 | + and use_date <![CDATA[ < ]]> #{endDate} | |
| 494 | + </if> | |
| 495 | + ) a ON m.id = a.coupon_template_id | |
| 496 | + INNER JOIN organization o ON a.used_hospital_id = o.id | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + <!--select a.id, count(distinct(b.user_id)) as user_used_count, count(1) as coupon_used_count, a.area_id, a.city_id, | |
| 395 | 501 | a.province_id |
| 396 | 502 | from organization a, (select * from coupon_info where used_hospital_id = #{hid}) b, coupon_template c, |
| 397 | 503 | coupon_type d |
| ... | ... | @@ -407,7 +513,7 @@ |
| 407 | 513 | </if> |
| 408 | 514 | <if test="endDate != null"> |
| 409 | 515 | and b.use_date <![CDATA[ < ]]> #{endDate} |
| 410 | - </if> | |
| 516 | + </if> --> | |
| 411 | 517 | </select> |
| 412 | 518 | |
| 413 | 519 | <select id="findSendUserIds" parameterType="map" resultType="string"> |
| ... | ... | @@ -428,7 +534,47 @@ |
| 428 | 534 | </select> |
| 429 | 535 | |
| 430 | 536 | <select id="findSendUserIds2" parameterType="map" resultType="string"> |
| 431 | - select distinct(b.user_id) | |
| 537 | + SELECT | |
| 538 | + distinct( user_id) | |
| 539 | + FROM | |
| 540 | + ( | |
| 541 | + SELECT | |
| 542 | + c.id | |
| 543 | + FROM | |
| 544 | + coupon_template c | |
| 545 | + INNER JOIN ( | |
| 546 | + SELECT | |
| 547 | + id | |
| 548 | + FROM | |
| 549 | + coupon_type d | |
| 550 | + WHERE | |
| 551 | + d.type IN | |
| 552 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 553 | + #{type} | |
| 554 | + </foreach> | |
| 555 | + ) t ON c.type_id = t.id | |
| 556 | + ) m | |
| 557 | + INNER JOIN ( | |
| 558 | + SELECT | |
| 559 | + coupon_template_id, | |
| 560 | + user_id, | |
| 561 | + used_hospital_id, | |
| 562 | + create_date | |
| 563 | + FROM | |
| 564 | + coupon_info | |
| 565 | + WHERE | |
| 566 | + create_hospital_id = #{hid} | |
| 567 | + <if test="startDate != null"> | |
| 568 | + and create_date >= #{startDate} | |
| 569 | + </if> | |
| 570 | + <if test="endDate != null"> | |
| 571 | + and create_date <![CDATA[ < ]]> #{endDate} | |
| 572 | + </if> | |
| 573 | + ) a ON m.id = a.coupon_template_id | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + <!-- select distinct(b.user_id) | |
| 432 | 578 | from organization a, (select * from coupon_info where create_hospital_id = #{hid}) b, coupon_template c, |
| 433 | 579 | coupon_type d |
| 434 | 580 | where a.id = b.create_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id |
| ... | ... | @@ -442,7 +588,7 @@ |
| 442 | 588 | </if> |
| 443 | 589 | <if test="endDate != null"> |
| 444 | 590 | and b.create_date <![CDATA[ < ]]> #{endDate} |
| 445 | - </if> | |
| 591 | + </if>--> | |
| 446 | 592 | </select> |
| 447 | 593 | |
| 448 | 594 | <select id="findHospitalSendInfo" parameterType="map" resultType="map"> |
| ... | ... | @@ -465,7 +611,56 @@ |
| 465 | 611 | </select> |
| 466 | 612 | |
| 467 | 613 | <select id="findHospitalSendInfo2" parameterType="map" resultType="map"> |
| 468 | - select a.id, count(distinct(b.user_id)) as people_send_count, count(1) as coupon_send_count, a.area_id, | |
| 614 | + | |
| 615 | + SELECT | |
| 616 | + o.id, | |
| 617 | + count(distinct(user_id)) as people_send_count, | |
| 618 | + count(1) as coupon_send_count, | |
| 619 | + o.area_id, | |
| 620 | + o.city_id, | |
| 621 | + o.province_id | |
| 622 | + FROM | |
| 623 | + ( | |
| 624 | + SELECT | |
| 625 | + c.id | |
| 626 | + FROM | |
| 627 | + coupon_template c | |
| 628 | + INNER JOIN ( | |
| 629 | + SELECT | |
| 630 | + id | |
| 631 | + FROM | |
| 632 | + coupon_type d | |
| 633 | + WHERE | |
| 634 | + d.type IN | |
| 635 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 636 | + #{type} | |
| 637 | + </foreach> | |
| 638 | + ) t ON c.type_id = t.id | |
| 639 | + ) m | |
| 640 | + INNER JOIN ( | |
| 641 | + SELECT | |
| 642 | + coupon_template_id, | |
| 643 | + STATUS, | |
| 644 | + use_date, | |
| 645 | + user_id, | |
| 646 | + used_hospital_id, | |
| 647 | + create_hospital_id | |
| 648 | + FROM | |
| 649 | + coupon_info | |
| 650 | + WHERE | |
| 651 | + create_hospital_id = #{hid} | |
| 652 | + <if test="startDate != null"> | |
| 653 | + and create_date >= #{startDate} | |
| 654 | + </if> | |
| 655 | + <if test="endDate != null"> | |
| 656 | + and create_date <![CDATA[ < ]]> #{endDate} | |
| 657 | + </if> | |
| 658 | + ) a ON m.id = a.coupon_template_id | |
| 659 | + INNER JOIN organization o ON a.create_hospital_id = o.id | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + <!--select a.id, count(distinct(b.user_id)) as people_send_count, count(1) as coupon_send_count, a.area_id, | |
| 469 | 664 | a.city_id, a.province_id |
| 470 | 665 | from organization a, (select * from coupon_info where create_hospital_id = #{hid}) b, coupon_template c, |
| 471 | 666 | coupon_type d |
| ... | ... | @@ -480,7 +675,7 @@ |
| 480 | 675 | </if> |
| 481 | 676 | <if test="endDate != null"> |
| 482 | 677 | and b.create_date <![CDATA[ < ]]> #{endDate} |
| 483 | - </if> | |
| 678 | + </if>--> | |
| 484 | 679 | </select> |
| 485 | 680 | |
| 486 | 681 | <select id="findHospitalNameById" parameterType="string" resultType="string"> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/DischargeAbstractFacade.java
View file @
ce94556
| ... | ... | @@ -404,8 +404,8 @@ |
| 404 | 404 | // Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); |
| 405 | 405 | // Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); |
| 406 | 406 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 407 | - Criteria criteria = Criteria.where("yn").is("1").and("hospitalId").is(hospitalId); | |
| 408 | - Criteria pCriteria = Criteria.where("yn").is("1"); | |
| 407 | + Criteria criteria = Criteria.where("yn").is(1).and("hospitalId").is(hospitalId); | |
| 408 | + Criteria pCriteria = Criteria.where("yn").is(1); | |
| 409 | 409 | boolean flag = false; |
| 410 | 410 | if (StringUtils.isNotEmpty(queryNo)) { |
| 411 | 411 | pCriteria.orOperator(Criteria.where("cardNo").regex(queryNo), |