Commit 31cc7c7c526319c09abbe212db1370da73141cae
1 parent
bdf62fbf04
Exists in
master
and in
6 other branches
二维码获取类型抽取
Showing 9 changed files with 140 additions and 16 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
- 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-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- 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/ReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/PageUtil.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
31cc7c7
| ... | ... | @@ -54,5 +54,13 @@ |
| 54 | 54 | List<Map<String,Object>> findUsedInfo(Map<String, Object> param); |
| 55 | 55 | |
| 56 | 56 | List<Map<String, Object>> findHospitals(Map<String, Object> param); |
| 57 | + | |
| 58 | + Map<String,Object> findHospitalName(Map<String, Object> param); | |
| 59 | + | |
| 60 | + String findUserName(String prodDoctor); | |
| 61 | + | |
| 62 | + String findPhone(String s); | |
| 63 | + | |
| 64 | + List<Map<String,Object>> findCouponInfo(Map<String, Object> param); | |
| 57 | 65 | } |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
View file @
31cc7c7
| ... | ... | @@ -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 @
31cc7c7
| ... | ... | @@ -63,10 +63,6 @@ |
| 63 | 63 | @Autowired |
| 64 | 64 | private WeixinQrcodeConfigService weixinQrcodeConfigService; |
| 65 | 65 | |
| 66 | - @Value("${or.code.create.type}") | |
| 67 | - private Integer type; | |
| 68 | - | |
| 69 | - @Autowired | |
| 70 | 66 | private CouponMapper couponMapper; |
| 71 | 67 | |
| 72 | 68 | @Autowired |
| ... | ... | @@ -388,7 +384,7 @@ |
| 388 | 384 | } |
| 389 | 385 | |
| 390 | 386 | @Override |
| 391 | - public String findUrl(String code) { | |
| 387 | + public String findUrl(String code, Integer type) { | |
| 392 | 388 | |
| 393 | 389 | Map<String, Object> map = couponMapper.findUrl(code); |
| 394 | 390 | String hId = map.get("create_hospital_id").toString(); |
| ... | ... | @@ -521,7 +517,7 @@ |
| 521 | 517 | } |
| 522 | 518 | |
| 523 | 519 | @Override |
| 524 | - public BaseObjectResponse findList(String userId, String hospitalId, String url) { | |
| 520 | + public BaseObjectResponse findList(String userId, String hospitalId, String url, Integer type) { | |
| 525 | 521 | Map<String, Object> param = new HashMap<>(); |
| 526 | 522 | param.put("userId", userId); |
| 527 | 523 | param.put("hospitalId", hospitalId); |
| ... | ... | @@ -531,7 +527,7 @@ |
| 531 | 527 | List<Map<String, Object>> couponInfos = couponMapper.findInfo(param); |
| 532 | 528 | for (Map<String,Object> map : couponInfos) { |
| 533 | 529 | // map.put("url", PropertiesUtil.getInstance().getDefault("or.code.url", map.get("sequence_id").toString())); |
| 534 | - map.put("url", findUrl(map.get("sequence_id").toString())); | |
| 530 | + map.put("url", findUrl(map.get("sequence_id").toString(), type)); | |
| 535 | 531 | } |
| 536 | 532 | restMap.put("couponInfos", couponInfos); |
| 537 | 533 | return RespBuilder.buildSuccess(restMap); |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
31cc7c7
| ... | ... | @@ -209,5 +209,25 @@ |
| 209 | 209 | #{hid} |
| 210 | 210 | </foreach> |
| 211 | 211 | </select> |
| 212 | + | |
| 213 | + <select id="findHospitalName" parameterType="map" resultType="map"> | |
| 214 | + select name from organization where id = #{hospitalId} | |
| 215 | + </select> | |
| 216 | + | |
| 217 | + <select id="findUserName" parameterType="string" resultType="string"> | |
| 218 | + select name from users where id = #{id} | |
| 219 | + </select> | |
| 220 | + | |
| 221 | + <select id="findPhone" parameterType="string" resultType="string"> | |
| 222 | + select phone from users where id = #{id} | |
| 223 | + </select> | |
| 224 | + | |
| 225 | + <select id="findCouponInfo" parameterType="map" resultType="map"> | |
| 226 | + select c.type, a.sequence_id, d.name | |
| 227 | + from coupon_info a, coupon_template b, coupon_type c, users d | |
| 228 | + where a.coupon_template_id = b.id and b.type_id = c.id and a.user_id = d.id and a.status=2 | |
| 229 | + and a.used_hospital_id = #{hospitalId} | |
| 230 | + limit #{currentPage},#{pageSize} | |
| 231 | + </select> | |
| 212 | 232 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
View file @
31cc7c7
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | @Value("${or.code.url}") |
| 40 | 40 | private String url; |
| 41 | 41 | |
| 42 | + @Value("${or.code.create.type}") | |
| 43 | + private Integer type; | |
| 44 | + | |
| 42 | 45 | @Autowired |
| 43 | 46 | private MongoTemplate mongoTemplate; |
| 44 | 47 | |
| ... | ... | @@ -71,7 +74,7 @@ |
| 71 | 74 | @RequestMapping(method = RequestMethod.GET, value = "/{userId}/{hospitalId}") |
| 72 | 75 | @ResponseBody |
| 73 | 76 | public BaseObjectResponse list(@PathVariable String userId, @PathVariable String hospitalId) { |
| 74 | - return couponService.findList(userId, hospitalId, url); | |
| 77 | + return couponService.findList(userId, hospitalId, url, type); | |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
31cc7c7
| ... | ... | @@ -211,6 +211,31 @@ |
| 211 | 211 | Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, |
| 212 | 212 | "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", |
| 213 | 213 | areaId, "tempId", tempId, "couponType", couponType); |
| 214 | + return reportService.coupon(param); | |
| 215 | + } | |
| 216 | + | |
| 217 | + /** | |
| 218 | + * 优惠券相关统计详情 | |
| 219 | + * @param request | |
| 220 | + * @param startDate 开始时间 | |
| 221 | + * @param endDate 结束时间 | |
| 222 | + * @param provinceId 省 | |
| 223 | + * @param cityId 市 | |
| 224 | + * @param areaId 区 | |
| 225 | + * @param hospitalId 医院id | |
| 226 | + * @param tempId 模板id | |
| 227 | + * @param couponType 优惠券类型 | |
| 228 | + * @return | |
| 229 | + */ | |
| 230 | + @ResponseBody | |
| 231 | + @TokenRequired | |
| 232 | + @RequestMapping(value = "/coupon/info", method = RequestMethod.GET) | |
| 233 | + public BaseObjectResponse couponInfo(HttpServletRequest request, Date startDate, Date endDate, | |
| 234 | + String provinceId, String cityId, String areaId, String hospitalId, String tempId, String couponType, | |
| 235 | + Integer currentPage, Integer pageSize) { | |
| 236 | + Map<String, Object> param = CollectionUtils.createMap("userId", getUserId(request), "startDate", startDate, | |
| 237 | + "endDate", endDate, "hospitalId", hospitalId, "provinceId", provinceId, "cityId", cityId, "areaId", | |
| 238 | + areaId, "tempId", tempId, "couponType", couponType); | |
| 214 | 239 | return reportService.couponInfo(param); |
| 215 | 240 | } |
| 216 | 241 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
31cc7c7
| ... | ... | @@ -67,8 +67,10 @@ |
| 67 | 67 | |
| 68 | 68 | void exportCheckInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, String name, Integer userId, HttpServletResponse resp); |
| 69 | 69 | |
| 70 | - BaseObjectResponse couponInfo(Map<String, Object> param); | |
| 70 | + BaseObjectResponse coupon(Map<String, Object> param); | |
| 71 | 71 | |
| 72 | 72 | BaseObjectResponse couponInit(Map<String, Object> userId); |
| 73 | + | |
| 74 | + BaseObjectResponse couponInfo(Map<String, Object> param); | |
| 73 | 75 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
31cc7c7
| ... | ... | @@ -6,20 +6,23 @@ |
| 6 | 6 | import com.lyms.platform.common.result.PageResult; |
| 7 | 7 | import com.lyms.platform.common.result.RespBuilder; |
| 8 | 8 | import com.lyms.platform.common.result.ResponseCode; |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 9 | 10 | import com.lyms.platform.common.utils.EnumUtil; |
| 10 | 11 | import com.lyms.platform.operate.web.dao.IReportDao; |
| 11 | 12 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
| 12 | 13 | import com.lyms.platform.operate.web.service.IReportService; |
| 13 | -import com.lyms.platform.operate.web.utils.CollectionUtils; | |
| 14 | -import com.lyms.platform.operate.web.utils.MathUtil; | |
| 15 | -import com.lyms.platform.operate.web.utils.ResponseUtil; | |
| 16 | -import com.lyms.platform.operate.web.utils.SystemDataSource; | |
| 14 | +import com.lyms.platform.operate.web.utils.*; | |
| 17 | 15 | import com.lyms.platform.permission.dao.master.CouponMapper; |
| 16 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 17 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 18 | 18 | import com.lyms.platform.pojo.BasicConfig; |
| 19 | +import com.lyms.platform.pojo.Patients; | |
| 19 | 20 | import com.lymsh.platform.reportdata.model.echarts.Series; |
| 20 | 21 | import org.apache.commons.lang.StringUtils; |
| 21 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | 23 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 24 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 25 | +import org.springframework.data.mongodb.core.query.Query; | |
| 23 | 26 | import org.springframework.stereotype.Service; |
| 24 | 27 | |
| 25 | 28 | import javax.servlet.http.HttpServletResponse; |
| ... | ... | @@ -414,7 +417,7 @@ |
| 414 | 417 | } |
| 415 | 418 | |
| 416 | 419 | @Override |
| 417 | - public BaseObjectResponse couponInfo(Map<String ,Object> param) { | |
| 420 | + public BaseObjectResponse coupon(Map<String ,Object> param) { | |
| 418 | 421 | if(StringUtils.isBlank((String) param.get("hospitalId"))) { |
| 419 | 422 | param.put("hospitalId", Arrays.asList("216", "245")); /** 模拟根据登陆人id 查询出来的医院 */ |
| 420 | 423 | } else { |
| ... | ... | @@ -480,6 +483,49 @@ |
| 480 | 483 | "hTemp", couponMapper.findHospitals(param)); |
| 481 | 484 | } |
| 482 | 485 | |
| 486 | + @Override | |
| 487 | + public BaseObjectResponse couponInfo(Map<String, Object> param) { | |
| 488 | + PageUtil.setPageInfo(param); | |
| 489 | + Map<String, Object> hospitalName = couponMapper.findHospitalName(param); | |
| 490 | + List<Map<String, Object>> couponInfos = couponMapper.findCouponInfo(param); | |
| 491 | + for (Map<String, Object> couponInfo : couponInfos) { | |
| 492 | + setAntexInfo(couponInfo); | |
| 493 | + } | |
| 494 | + return RespBuilder.buildSuccess("hospitalInfo", hospitalName, "couponInfo", couponInfos); | |
| 495 | + } | |
| 496 | + | |
| 497 | + private void setAntexInfo(Map<String, Object> map) { | |
| 498 | + String sequenceId = (String) map.get("sequence_id"); | |
| 499 | + if(StringUtils.isEmpty(sequenceId)) return; | |
| 500 | + AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntExChuModel.class); | |
| 501 | + if(antexc != null) { | |
| 502 | + map.put("checkDate", antexc.getCheckTime()); /** 产检日期 */ | |
| 503 | + Patients patients = mongoTemplate.findById(antexc.getParentId(), Patients.class); | |
| 504 | + if(patients != null) { | |
| 505 | + map.put("username", patients.getUsername()); /** 姓名 */ | |
| 506 | + } | |
| 507 | + map.put("week", DateUtil.getDays(antexc.getCheckTime(), antexc.getLastMenses()));/** 产检孕周 = 产检时间 - 末次月经 */ | |
| 508 | + map.put("number", antexc.getProdTime()); /** 产检第几次 */ | |
| 509 | + map.put("doctorName", couponMapper.findUserName(antexc.getProdDoctor())); /** 产检医生 */ | |
| 510 | + map.put("operatorOrgName", couponMapper.findUserName(antexc.getOperator() + "")); /** 产检机构 */ | |
| 511 | + map.put("phone", couponMapper.findPhone(antexc.getOperator() + "")); | |
| 512 | + } else { | |
| 513 | + AntenatalExaminationModel antenatal = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntenatalExaminationModel.class); | |
| 514 | + if(antenatal != null) { | |
| 515 | + map.put("checkDate", antenatal.getCheckDate()); /** 产检日期 */ | |
| 516 | + Patients patients = mongoTemplate.findById(antenatal.getParentId(), Patients.class); | |
| 517 | + if(patients != null) { | |
| 518 | + map.put("username", patients.getUsername()); /** 姓名 */ | |
| 519 | + } | |
| 520 | + map.put("week", antenatal.getCurrentDueDate());/** 产检孕周 = 产检时间 - 末次月经 */ | |
| 521 | + map.put("number", antenatal.getYn()); /** 产检第几次 */ | |
| 522 | + map.put("doctorName", couponMapper.findUserName(antenatal.getCheckDoctor())); /** 产检医生 */ | |
| 523 | + map.put("operatorOrgName", couponMapper.findUserName(antenatal.getOperator() + "")); /** 产检机构 */ | |
| 524 | + map.put("phone", couponMapper.findPhone(antenatal.getOperator() + "")); | |
| 525 | + } | |
| 526 | + } | |
| 527 | + } | |
| 528 | + | |
| 483 | 529 | private String findName(Object id) { |
| 484 | 530 | if(id != null) { |
| 485 | 531 | BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class); |
| ... | ... | @@ -814,5 +860,6 @@ |
| 814 | 860 | System.out.println(sql.toString()); |
| 815 | 861 | return sql.toString(); |
| 816 | 862 | } |
| 863 | + | |
| 817 | 864 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/PageUtil.java
View file @
31cc7c7
| 1 | +package com.lyms.platform.operate.web.utils; | |
| 2 | + | |
| 3 | +import java.util.Map; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * @Author: litao | |
| 7 | + * @Date: 2017/5/25 0025 17:50 | |
| 8 | + * @Version: V1.0 | |
| 9 | + */ | |
| 10 | +public class PageUtil { | |
| 11 | + public static void setPageInfo(Map<String,Object> map) { | |
| 12 | + Integer pageSize = map.get("pageSize") == null ? 15 : Integer.parseInt(map.get("pageSize").toString()); | |
| 13 | + Integer currentPage = map.get("currentPage") == null ? 1 : Integer.parseInt(map.get("currentPage").toString()); | |
| 14 | + if(pageSize < 1) { | |
| 15 | + pageSize = 10; | |
| 16 | + } | |
| 17 | + if(currentPage < 1) { | |
| 18 | + currentPage = 1; | |
| 19 | + } | |
| 20 | + map.put("currentPage", (currentPage - 1) * pageSize); | |
| 21 | + map.put("pageSize",pageSize); | |
| 22 | + } | |
| 23 | +} |