Commit d142c75c25e27de771fb002b886c62c053f498d5

Authored by yangfei

Merge remote-tracking branch 'origin/master'

Showing 12 changed files

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java View file @ d142c75
... ... @@ -82,5 +82,9 @@
82 82 List<Map<String,Object>> findUserSendInfo(Map<String, Object> param);
83 83  
84 84 Integer findUserSendInfoCount(Map<String, Object> param);
  85 +
  86 + List<String> findSendUserIds(Map<String, Object> param);
  87 +
  88 + List<String> findUsedUserIds(Map<String, Object> param);
85 89 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java View file @ d142c75
... ... @@ -12,7 +12,7 @@
12 12 * @Version: V1.0
13 13 */
14 14 public interface CouponService{
15   - BaseObjectResponse create(String userId, String hospitalId, Integer createUserId);
  15 + BaseObjectResponse create(String userId, String hospitalId, Integer createUserId, String patientId);
16 16  
17 17 BaseObjectResponse validate(String code, Integer type, String hospitalId);
18 18  
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ d142c75
... ... @@ -25,6 +25,7 @@
25 25 import org.springframework.data.mongodb.core.MongoTemplate;
26 26 import org.springframework.data.mongodb.core.query.Criteria;
27 27 import org.springframework.data.mongodb.core.query.Query;
  28 +import org.springframework.data.mongodb.core.query.Update;
28 29 import org.springframework.stereotype.Service;
29 30  
30 31 import java.util.*;
... ... @@ -94,7 +95,7 @@
94 95 };
95 96  
96 97 @Override
97   - public BaseObjectResponse create(String userId, String hospitalId, Integer createUserId) {
  98 + public BaseObjectResponse create(String userId, String hospitalId, Integer createUserId, String patientId) {
98 99 if(isCreated(userId, hospitalId)) {
99 100 return RespBuilder.buildErro(ResponseCode.COUPON_IS_CREATED);
100 101 }
... ... @@ -124,6 +125,10 @@
124 125 }
125 126  
126 127 sendCoupon(temps, hospitalId, createUserId, userId, person.getType(), areaCode);
  128 +
  129 + /** 记录为已经发放过优惠券 */
  130 + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientId)), Update.update("isSendCoupon", true), Patients.class);
  131 +
127 132 return RespBuilder.buildSuccess();
128 133 }
129 134  
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ d142c75
... ... @@ -239,6 +239,23 @@
239 239 group by b.coupon_order, b.type, a.used_hospital_id
240 240 </select>
241 241  
  242 + <select id="findUsedUserIds" parameterType="map" resultType="string">
  243 + select distinct(b.user_id)
  244 + from organization a, coupon_info b, coupon_template c, coupon_type d
  245 + where a.id = b.used_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id
  246 + and a.id = #{hid}
  247 + and d.type in
  248 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  249 + #{type}
  250 + </foreach>
  251 + <if test="startDate != null">
  252 + and b.use_date >= #{startDate}
  253 + </if>
  254 + <if test="endDate != null">
  255 + and b.use_date <![CDATA[ < ]]> #{endDate}
  256 + </if>
  257 + </select>
  258 +
242 259 <select id="findHospitalUsedInfo" parameterType="map" resultType="map">
243 260 select a.id, count(distinct(b.user_id)) as user_used_count, count(1) as coupon_used_count, a.area_id, a.city_id, a.province_id
244 261 from organization a, coupon_info b, coupon_template c, coupon_type d
... ... @@ -253,6 +270,23 @@
253 270 </if>
254 271 <if test="endDate != null">
255 272 and b.use_date <![CDATA[ < ]]> #{endDate}
  273 + </if>
  274 + </select>
  275 +
  276 + <select id="findSendUserIds" parameterType="map" resultType="string">
  277 + select distinct(b.user_id)
  278 + from organization a, coupon_info b, coupon_template c, coupon_type d
  279 + where a.id = b.create_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id
  280 + and a.id = #{hid}
  281 + and d.type in
  282 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  283 + #{type}
  284 + </foreach>
  285 + <if test="startDate != null">
  286 + and b.create_date >= #{startDate}
  287 + </if>
  288 + <if test="endDate != null">
  289 + and b.create_date <![CDATA[ < ]]> #{endDate}
256 290 </if>
257 291 </select>
258 292  
platform-common/src/main/java/com/lyms/platform/common/result/PageResult.java View file @ d142c75
... ... @@ -21,6 +21,7 @@
21 21 this.page = page;
22 22 this.limit = limit;
23 23 this.grid = rows;
  24 +// this.page = ((count - 1)/this.limit) + 1;
24 25 this.lastPage = ((count - 1)/this.limit) + 1;
25 26 }
26 27  
platform-dal/src/main/java/com/lyms/platform/pojo/Patients.java View file @ d142c75
... ... @@ -247,6 +247,9 @@
247 247  
248 248 private Integer isAutoFm;
249 249  
  250 + // 是否发放过优惠券
  251 + private boolean isSendCoupon;
  252 +
250 253 public Integer getIsAutoFm() {
251 254 return isAutoFm;
252 255 }
... ... @@ -1053,6 +1056,14 @@
1053 1056  
1054 1057 public void setStreetRegisterId(String streetRegisterId) {
1055 1058 this.streetRegisterId = streetRegisterId;
  1059 + }
  1060 +
  1061 + public boolean isSendCoupon() {
  1062 + return isSendCoupon;
  1063 + }
  1064 +
  1065 + public void setSendCoupon(boolean sendCoupon) {
  1066 + isSendCoupon = sendCoupon;
1056 1067 }
1057 1068  
1058 1069 @Override
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java View file @ d142c75
... ... @@ -57,9 +57,9 @@
57 57 @RequestMapping(method = RequestMethod.POST)
58 58 @ResponseBody
59 59 @TokenRequired
60   - public BaseObjectResponse create(String userId, String hospitalId, HttpServletRequest request) {
  60 + public BaseObjectResponse create(String userId, String hospitalId, String patientId, HttpServletRequest request) {
61 61 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
62   - return couponService.create(userId, hospitalId, loginState.getId());
  62 + return couponService.create(userId, hospitalId, loginState.getId(), patientId);
63 63 }
64 64  
65 65 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ d142c75
... ... @@ -1075,6 +1075,10 @@
1075 1075  
1076 1076 private PregnantInfoResult getResult(Patients p) {
1077 1077 PregnantInfoResult result = new PregnantInfoResult();
  1078 +
  1079 + /** 是否发放过优惠券 */
  1080 + result.setSendCoupon(p.isSendCoupon());
  1081 +
1078 1082 result.setId(p.getId());
1079 1083 /**********孕妇基本信息***************/
1080 1084 result.setPregnantName(p.getUsername());
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java View file @ d142c75
... ... @@ -103,6 +103,9 @@
103 103  
104 104  
105 105 Map<String, Object> map = new HashMap<>();
  106 +
  107 + map.put("isSendCoupon", data.isSendCoupon());
  108 +
106 109 map.put("id", data.getId());
107 110 /* 孕妇基础数据 */
108 111 map.put("username", data.getUsername());
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PregnantInfoResult.java View file @ d142c75
... ... @@ -6,6 +6,9 @@
6 6 * Created by Administrator on 2016/6/15.
7 7 */
8 8 public class PregnantInfoResult {
  9 +
  10 + private boolean isSendCoupon;
  11 +
9 12 /***********孕妇基本信息***********/
10 13  
11 14 //建档Id
... ... @@ -135,6 +138,13 @@
135 138 //分娩状态 0未终止妊娠 1终止妊娠
136 139 private Integer dueStatus;
137 140  
  141 + public boolean isSendCoupon() {
  142 + return isSendCoupon;
  143 + }
  144 +
  145 + public void setSendCoupon(boolean sendCoupon) {
  146 + isSendCoupon = sendCoupon;
  147 + }
138 148  
139 149 public Integer getDueStatus() {
140 150 return dueStatus;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ d142c75
... ... @@ -468,7 +468,13 @@
468 468 Map<String, Object> sendInfo = couponMapper.findHospitalSendInfo(param);
469 469  
470 470 Map<String, Object> tempMap = packCouponMap(sendInfo, usedInfo, hNameMap, hid, xAxis, param);
  471 +
471 472 if(MapUtils.isNotEmpty(tempMap)) {
  473 + /** 方法/使用人数id */
  474 + List<String> sendUserIds = couponMapper.findSendUserIds(param);
  475 + List<String> usedUserIds = couponMapper.findUsedUserIds(param);
  476 + tempMap.put("sendUserIds", sendUserIds);
  477 + tempMap.put("usedUserIds", usedUserIds);
472 478 couponReport.add(tempMap);
473 479 }
474 480 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java View file @ d142c75
... ... @@ -51,6 +51,7 @@
51 51 * @return
52 52 */
53 53 public List<Map<String, Object>> getListByGroup(List<Patients> patients) {
  54 +
54 55 Map<String, Integer> codeMap = new HashMap<>(); /** key为 provinceId_cityId_areaId_month */
55 56 Map<Integer, Integer> otherMap = new HashMap<>(); /** key为 month */
56 57