Commit 68236c3297a17635fed348d6f3a78e0981a66f47

Authored by litao
1 parent d061441605

二维码地址抽取

Showing 3 changed files with 40 additions and 20 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java View file @ 68236c3
... ... @@ -2,6 +2,7 @@
2 2  
3 3 import com.lyms.platform.common.result.BaseObjectResponse;
4 4  
  5 +import java.util.Map;
5 6 import java.util.Set;
6 7  
7 8 /**
8 9  
... ... @@ -14,10 +15,14 @@
14 15  
15 16 BaseObjectResponse validate(String code, Integer type, String hospitalId);
16 17  
17   - BaseObjectResponse findList(String userId, String hospitalId);
  18 + BaseObjectResponse findList(String userId, String hospitalId, String url);
18 19  
19 20 BaseObjectResponse use(String hospitalId, String code, Integer userId);
20 21  
21 22 Set<Integer> findTypes(String hospital);
  23 +
  24 + Map<String, Object> getPatientsInfo(String userId);
  25 +
  26 + Map<String, Object> getPatientsInfoByCode(String code);
22 27 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ 68236c3
... ... @@ -21,13 +21,11 @@
21 21 import org.slf4j.Logger;
22 22 import org.slf4j.LoggerFactory;
23 23 import org.springframework.beans.factory.annotation.Autowired;
24   -import org.springframework.beans.factory.annotation.Value;
25 24 import org.springframework.data.domain.Sort;
26 25 import org.springframework.data.mongodb.core.MongoTemplate;
27 26 import org.springframework.data.mongodb.core.query.Criteria;
28 27 import org.springframework.data.mongodb.core.query.Query;
29 28 import org.springframework.stereotype.Service;
30   -import org.springframework.util.Assert;
31 29  
32 30 import java.util.*;
33 31  
34 32  
... ... @@ -58,9 +56,8 @@
58 56 /** 建档 */
59 57 private static final String PUT_ON_RECORD = "4";
60 58  
61   - @Value("${or.code.url}")
62   - private String url;
63 59  
  60 +
64 61 @Autowired
65 62 private CouponMapper couponMapper;
66 63  
67 64  
68 65  
69 66  
70 67  
71 68  
72 69  
73 70  
74 71  
75 72  
76 73  
... ... @@ -227,40 +224,54 @@
227 224 return RespBuilder.buildErro(ResponseCode.COUPON_NOT_UNIQUE);
228 225  
229 226 CouponInfo couponInfo = couponInfos.get(0);
  227 + Map<String, Object> patientsInfo = getPatientsInfo(couponInfo.getUserId());
  228 +
230 229 if(couponInfo.getStatus() == -1) {
231   - return RespBuilder.buildErro(ResponseCode.COUPON_IS_DISABLED);
  230 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_DISABLED, patientsInfo);
232 231 }
233 232 if(couponInfo.getStatus() == 2) {
234   - return RespBuilder.buildErro(ResponseCode.COUPON_IS_USERD);
  233 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_USERD, patientsInfo);
235 234 }
236 235  
237 236 Map<String, Object> data = couponMapper.findValidateParam(param);
238 237 if(MapUtils.isEmpty(data)) {
239   - return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE);
  238 + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE, patientsInfo);
240 239 }
241 240  
242 241 /** 验证时间 */
243   - if(!validateDate(couponInfo.getUserId(), Integer.parseInt(data.get("actual_start").toString()), Integer.parseInt(data.get("actual_end").toString()), Integer.parseInt(data.get("unit_type").toString()),
  242 + /*if(!validateDate(couponInfo.getUserId(), Integer.parseInt(data.get("actual_start").toString()), Integer.parseInt(data.get("actual_end").toString()), Integer.parseInt(data.get("unit_type").toString()),
244 243 data.get("create_hospital_id").toString(), Integer.parseInt(data.get("type").toString())))
245   - return RespBuilder.buildErro(ResponseCode.COUPON_TIME_OUT);
  244 + return RespBuilder.buildErro(ResponseCode.COUPON_TIME_OUT, patientsInfo);*/
246 245  
247 246 /** 验证区域 */
248   - if(!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), hospitalId)) {
249   - return RespBuilder.buildErro(ResponseCode.COUPON_AREA_NO_USE);
250   - }
  247 + /* if(!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), hospitalId)) {
  248 + return RespBuilder.buildErro(ResponseCode.COUPON_AREA_NO_USE, patientsInfo);
  249 + }*/
  250 + return RespBuilder.buildSuccess(patientsInfo);
  251 + }
251 252  
252   -
  253 + @Override
  254 + public Map<String, Object> getPatientsInfo(String userId) {
253 255 Map<String, Object> restMap = new HashMap<>();
254   - restMap.put("userId", couponInfo.getUserId());
255   - Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(couponInfo.getUserId())), Patients.class);
  256 + restMap.put("userId", userId);
  257 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class);
256 258 if(patients != null) {
257 259 restMap.put("vcCardNo", patients.getVcCardNo()); /** 就诊卡号 */
258 260 restMap.put("cardNo", patients.getCardNo()); /** 证件号 */
259 261 restMap.put("pcerteTypeId", patients.getPcerteTypeId()); /** 证件类型id */
260 262 }
  263 + return restMap;
  264 + }
261 265  
262   -
263   - return RespBuilder.buildSuccess(restMap);
  266 + @Override
  267 + public Map<String, Object> getPatientsInfoByCode(String code) {
  268 + Map<String, Object> param = new HashMap<>();
  269 + param.put("code", code);
  270 + List<CouponInfo> list = couponMapper.findList(param);
  271 + if(CollectionUtils.isNotEmpty(list)) {
  272 + return getPatientsInfo(list.get(0).getUserId());
  273 + }
  274 + return null;
264 275 }
265 276  
266 277 /** 1=省 2=市 3=区 4=单医院 */
... ... @@ -340,7 +351,7 @@
340 351 }
341 352  
342 353 @Override
343   - public BaseObjectResponse findList(String userId, String hospitalId) {
  354 + public BaseObjectResponse findList(String userId, String hospitalId, String url) {
344 355 Map<String, Object> param = new HashMap<>();
345 356 param.put("userId", userId);
346 357 param.put("hospitalId", hospitalId);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java View file @ 68236c3
... ... @@ -7,6 +7,7 @@
7 7 import com.lyms.platform.operate.web.facade.AutoMatchFacade;
8 8 import com.lyms.platform.permission.service.CouponService;
9 9 import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.beans.factory.annotation.Value;
10 11 import org.springframework.stereotype.Controller;
11 12 import org.springframework.web.bind.annotation.PathVariable;
12 13 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -30,6 +31,9 @@
30 31 @Autowired
31 32 AutoMatchFacade autoMatchFacade;
32 33  
  34 + @Value("${or.code.url}")
  35 + private String url;
  36 +
33 37 /**
34 38 * 创建用户产检券
35 39 * @param userId
... ... @@ -54,7 +58,7 @@
54 58 @RequestMapping(method = RequestMethod.GET, value = "/{userId}/{hospitalId}")
55 59 @ResponseBody
56 60 public BaseObjectResponse list(@PathVariable String userId, @PathVariable String hospitalId) {
57   - return couponService.findList(userId, hospitalId);
  61 + return couponService.findList(userId, hospitalId, url);
58 62 }
59 63  
60 64