Commit a18a7dd9557dfbb26035c06ddbdabb0e2d209b56
1 parent
7b854fe180
Exists in
master
and in
6 other branches
其他高危
Showing 5 changed files with 55 additions and 26 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ScanController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
View file @
a18a7dd
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | |
17 | 17 | BaseObjectResponse validate(String code, Integer type, String hospitalId); |
18 | 18 | |
19 | - BaseObjectResponse findList(String userId, String hospitalId, String url); | |
19 | + BaseObjectResponse findList(String userId, String hospitalId, String url,Integer type); | |
20 | 20 | |
21 | 21 | BaseObjectResponse use(String hospitalId, String code, Integer userId, String usedId); |
22 | 22 | |
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | |
33 | 33 | BaseObjectResponse areas(String hospitalId); |
34 | 34 | |
35 | - String findUrl(String code); | |
35 | + String findUrl(String code,Integer type); | |
36 | 36 | |
37 | 37 | List<Map<String,Object>> queryCouponItemsByType(Map<String, Object> params); |
38 | 38 |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
a18a7dd
... | ... | @@ -10,8 +10,11 @@ |
10 | 10 | import com.lyms.platform.permission.dao.master.CouponMapper; |
11 | 11 | import com.lyms.platform.permission.model.CouponInfo; |
12 | 12 | import com.lyms.platform.permission.model.Organization; |
13 | +import com.lyms.platform.permission.model.WeixinQrcodeConfig; | |
14 | +import com.lyms.platform.permission.model.WeixinQrcodeConfigQuery; | |
13 | 15 | import com.lyms.platform.permission.service.CouponService; |
14 | 16 | import com.lyms.platform.permission.service.OrganizationService; |
17 | +import com.lyms.platform.permission.service.WeixinQrcodeConfigService; | |
15 | 18 | import com.lyms.platform.pojo.*; |
16 | 19 | import net.sf.json.JSONObject; |
17 | 20 | import org.apache.commons.collections.CollectionUtils; |
... | ... | @@ -57,8 +60,8 @@ |
57 | 60 | /** 建档 */ |
58 | 61 | private static final String PUT_ON_RECORD = "4"; |
59 | 62 | |
60 | - | |
61 | - | |
63 | +@Autowired | |
64 | + private WeixinQrcodeConfigService weixinQrcodeConfigService; | |
62 | 65 | @Autowired |
63 | 66 | private CouponMapper couponMapper; |
64 | 67 | |
65 | 68 | |
66 | 69 | |
67 | 70 | |
... | ... | @@ -395,26 +398,40 @@ |
395 | 398 | } |
396 | 399 | |
397 | 400 | @Override |
398 | - public String findUrl(String code) { | |
399 | - try { | |
400 | - Map<String, Object> map = couponMapper.findUrl(code); | |
401 | - String hId = map.get("create_hospital_id").toString(); | |
402 | - String userId = map.get("user_id").toString(); | |
401 | + public String findUrl(String code, Integer type) { | |
403 | 402 | |
404 | - PersonModel person = mongoTemplate.findById(userId, PersonModel.class); | |
403 | + Map<String, Object> map = couponMapper.findUrl(code); | |
404 | + String hId = map.get("create_hospital_id").toString(); | |
405 | + String userId = map.get("user_id").toString(); | |
405 | 406 | |
406 | - Map<String, String> params = new HashMap<>(); | |
407 | - params.put("hId", hId); | |
408 | -// params.put("dpId", person.getType() == 2 ? "1" : "2"); | |
409 | - params.put("dpId", person.getType() == 2 ? "2" : "1"); | |
410 | - String s = HttpClientUtil.doGet(PropertiesUtil.getInstance().getDefault("or.code.create.url"), params, "utf-8", null); | |
407 | + PersonModel person = mongoTemplate.findById(userId, PersonModel.class); | |
408 | + | |
409 | + if (person == null) | |
410 | + return "http://weixin.qq.com/r/Fi9bQyLEgH--rWYg93oE"; | |
411 | + | |
412 | + Map<String, String> params = new HashMap<>(); | |
413 | + params.put("hId", hId); | |
414 | + params.put("dpId", person.getType() == 2 ? "2" : "1"); | |
415 | + | |
416 | + if(type == 1) { | |
417 | + WeixinQrcodeConfigQuery query = new WeixinQrcodeConfigQuery(); | |
418 | + query.setDpId(person.getType() == 2 ? 2 : 1); | |
419 | + query.setHospitalId(hId); | |
420 | + | |
421 | + | |
422 | + List<WeixinQrcodeConfig> weixinQrcodeConfigs = weixinQrcodeConfigService.queryWeixinShowqrcodeConfig(query); | |
423 | + if(CollectionUtils.isNotEmpty(weixinQrcodeConfigs)) { | |
424 | + String url = weixinQrcodeConfigs.get(0).getWxUrl(); | |
425 | + return url; | |
426 | + } | |
427 | + } | |
428 | + try {String s = HttpClientUtil.doGet(PropertiesUtil.getInstance().getDefault("or.code.create.url"), params, "utf-8", null); | |
411 | 429 | JSONObject jsonObject = JSONObject.fromObject(s); |
412 | 430 | return jsonObject.get("url").toString(); |
413 | 431 | } catch (Exception e) { |
414 | 432 | e.printStackTrace(); |
415 | 433 | return "http://weixin.qq.com/r/Fi9bQyLEgH--rWYg93oE"; |
416 | 434 | } |
417 | - | |
418 | 435 | } |
419 | 436 | |
420 | 437 | @Override |
... | ... | @@ -516,7 +533,7 @@ |
516 | 533 | } |
517 | 534 | |
518 | 535 | @Override |
519 | - public BaseObjectResponse findList(String userId, String hospitalId, String url) { | |
536 | + public BaseObjectResponse findList(String userId, String hospitalId, String url,Integer type) { | |
520 | 537 | Map<String, Object> param = new HashMap<>(); |
521 | 538 | param.put("userId", userId); |
522 | 539 | param.put("hospitalId", hospitalId); |
... | ... | @@ -526,7 +543,7 @@ |
526 | 543 | List<Map<String, Object>> couponInfos = couponMapper.findInfo(param); |
527 | 544 | for (Map<String,Object> map : couponInfos) { |
528 | 545 | // map.put("url", PropertiesUtil.getInstance().getDefault("or.code.url", map.get("sequence_id").toString())); |
529 | - map.put("url", findUrl(map.get("sequence_id").toString())); | |
546 | + map.put("url", findUrl(map.get("sequence_id").toString(),type)); | |
530 | 547 | } |
531 | 548 | restMap.put("couponInfos", couponInfos); |
532 | 549 | return RespBuilder.buildSuccess(restMap); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
View file @
a18a7dd
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.base.LoginContext; |
7 | 7 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | 8 | import com.lyms.platform.common.result.RespBuilder; |
9 | +import com.lyms.platform.common.utils.PropertiesUtil; | |
9 | 10 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
10 | 11 | import com.lyms.platform.permission.service.CouponService; |
11 | 12 | import org.slf4j.Logger; |
... | ... | @@ -36,8 +37,6 @@ |
36 | 37 | @Autowired |
37 | 38 | AutoMatchFacade autoMatchFacade; |
38 | 39 | |
39 | - @Value("${or.code.url}") | |
40 | - private String url; | |
41 | 40 | |
42 | 41 | @Autowired |
43 | 42 | private MongoTemplate mongoTemplate; |
44 | 43 | |
... | ... | @@ -47,7 +46,14 @@ |
47 | 46 | |
48 | 47 | private static final Logger LOG = LoggerFactory.getLogger(CouponController.class); |
49 | 48 | |
49 | + private static String url; | |
50 | + private static String type; | |
50 | 51 | |
52 | + static { | |
53 | + type = PropertiesUtil.getInstance().getDefault("or.code.create.type"); | |
54 | + url = PropertiesUtil.getInstance().getDefault("or.code.url"); | |
55 | + } | |
56 | + | |
51 | 57 | /** |
52 | 58 | * 创建用户产检券 |
53 | 59 | * @param userId |
... | ... | @@ -71,7 +77,7 @@ |
71 | 77 | @RequestMapping(method = RequestMethod.GET, value = "/{userId}/{hospitalId}") |
72 | 78 | @ResponseBody |
73 | 79 | public BaseObjectResponse list(@PathVariable String userId, @PathVariable String hospitalId) { |
74 | - return couponService.findList(userId, hospitalId, url); | |
80 | + return couponService.findList(userId, hospitalId, url, Integer.parseInt(type)); | |
75 | 81 | } |
76 | 82 | |
77 | 83 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ScanController.java
View file @
a18a7dd
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | 3 | import com.lyms.platform.common.base.BaseController; |
4 | +import com.lyms.platform.common.utils.PropertiesUtil; | |
4 | 5 | import com.lyms.platform.permission.service.CouponService; |
5 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
6 | 7 | import org.springframework.stereotype.Controller; |
7 | 8 | |
... | ... | @@ -18,7 +19,13 @@ |
18 | 19 | |
19 | 20 | @Autowired |
20 | 21 | private CouponService couponService; |
22 | + private static String url; | |
23 | + private static String type; | |
21 | 24 | |
25 | + static { | |
26 | + type = PropertiesUtil.getInstance().getDefault("or.code.create.type"); | |
27 | + url = PropertiesUtil.getInstance().getDefault("or.code.url"); | |
28 | + } | |
22 | 29 | /** |
23 | 30 | * @auther HuJiaqi |
24 | 31 | * @createTime 2017年01月10日 16时23分 |
... | ... | @@ -27,7 +34,7 @@ |
27 | 34 | @RequestMapping("/scan") |
28 | 35 | public void scan(HttpServletResponse httpServletResponse, String code) throws Exception { |
29 | 36 | // httpServletResponse.sendRedirect("http://m.healthbaby.com.cn/download/download.html"); |
30 | - httpServletResponse.sendRedirect(couponService.findUrl(code)); | |
37 | + httpServletResponse.sendRedirect(couponService.findUrl(code,Integer.valueOf(type))); | |
31 | 38 | } |
32 | 39 | |
33 | 40 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
View file @
a18a7dd
1 | 1 | package com.lyms.platform.operate.web.utils; |
2 | 2 | |
3 | 3 | import org.apache.commons.lang3.StringUtils; |
4 | -import org.eclipse.jetty.util.StringUtil; | |
5 | 4 | import org.springframework.util.Assert; |
6 | 5 | |
7 | 6 | import java.util.*; |
... | ... | @@ -22,7 +21,7 @@ |
22 | 21 | for (int i = 0; i < args.length; i++) { |
23 | 22 | String key = args[i++].toString(); |
24 | 23 | Object value = args[i]; |
25 | - if(value != null && StringUtil.isNotBlank(value.toString())) { | |
24 | + if(value != null && StringUtils.isNotBlank(value.toString())) { | |
26 | 25 | map.put(key, value); |
27 | 26 | } |
28 | 27 | } |