Trick 6 роки тому
батько
коміт
89a1873775

+ 33 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxUrlConfigService.java

@ -1,14 +1,20 @@
package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.wx.WxUrlConfigDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.restmodel.base.wx.WxContants;
import com.yihu.jw.restmodel.base.wx.WxSaasVO;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxUrlConfigDao;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -23,11 +29,36 @@ public class WxUrlConfigService {
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public Map<String,Object> getWxWechatConfig(String url){
        WxUrlConfigDO wxUrlConfigDO = wxUrlConfigDao.findByUrl(url);
        if(wxUrlConfigDO!=null){
            WxWechatDO wxWechatDO = wechatDao.findById(wxUrlConfigDO.getWxId());
            List<WxSaasVO> saasVOs = getWxSaasVOs(wxWechatDO.getId());
            Map<String,Object> map = new HashedMap();
            map.put("wxId",wxUrlConfigDO.getWxId());
            map.put("wxAppId",wxWechatDO.getAppId());
            map.put("publicType",wxWechatDO.getPublicType());
            map.put("saasVOs",saasVOs);
            return map;
        }else{
            return null;
        }
    }
        WxWechatDO wxWechatDO = wechatDao.findById(wxUrlConfigDO.getWxId());
        return null;
    public List<WxSaasVO> getWxSaasVOs(String id){
        String sql ="SELECT " +
                " bs.`name` AS saasName, " +
                " bs.id AS saasid" +
                " FROM " +
                " wx_wechat_saas s " +
                " JOIN base_saas bs ON bs.id = s.saas_id " +
                " WHERE " +
                " s.wechat_id = '"+id+"'";
        List<WxSaasVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxSaasVO.class));
        return list;
    }

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java

@ -28,6 +28,7 @@ public class PatientRequestMapping {
        public static final String api_error ="error";
        public static final String getSign ="/getSign";
        public static final String getWxWechatConfig ="/getWxWechatConfig";
    }
    /**

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageVO.java

@ -32,6 +32,8 @@ public class ServicePackageVO {
    private List<SerivePackageItemVO> items;//服务项描述
    private Integer signType;//判断当前居民是否签约:1为签约,2为未签约
    public String getId() {
        return id;
    }
@ -191,4 +193,12 @@ public class ServicePackageVO {
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Integer getSignType() {
        return signType;
    }
    public void setSignType(Integer signType) {
        this.signType = signType;
    }
}

+ 3 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/servicepackage/PackageServiceEndpoint.java

@ -49,11 +49,13 @@ public class PackageServiceEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "labelCode", required = false)String labelCode,
                                         @ApiParam(name = "labelType", value = "标签类型")
                                         @RequestParam(value = "labelType", required = false)String labelType,
                                         @ApiParam(name = "patient", value = "居民code(判断居民是否签约,非必传)")
                                         @RequestParam(value = "patient", required = false)String patient,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page", required = true)Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = true)Integer size) {
        return packageService.findPackageService(city,labelCode,labelType,page,size);
        return packageService.findPackageService(city,labelCode,labelType,patient,page,size);
    }

+ 21 - 2
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatInfoEndPoint.java

@ -1,14 +1,18 @@
package com.yihu.jw.patient.endpoint.wechat;
import com.sun.net.httpserver.Authenticator;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.wechat.service.WxUrlConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.security.MessageDigest;
@ -40,15 +45,29 @@ public class WechatInfoEndPoint extends EnvelopRestEndpoint {
    private WechatInfoService wechatInfoService;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private WxUrlConfigService wxUrlConfigService;
    @RequestMapping(value =  PatientRequestMapping.Wechat.getWxWechatConfig, method = RequestMethod.GET)
    @ResponseBody
    public ObjEnvelop<Map<String,Object>> getWxWechatConfig(@ApiParam(name = "url", value = "域名地址")
                                                                @RequestParam(value = "url", required = true)String url){
        return success(PatientRequestMapping.Wechat.api_success,wxUrlConfigService.getWxWechatConfig(url));
    }
    /**
     * 获取签名signature
     *
     * @param pageUrl 需要签名的页面全地址(?后的也需要除了#后的不需要)
     * @return
     */
    @RequestMapping(value = "getSign", method = RequestMethod.POST)
    @RequestMapping(value = PatientRequestMapping.Wechat.getSign, method = RequestMethod.POST)
    @ResponseBody
    public Envelop getSign(String pageUrl,String wxId) {
    public Envelop getSign(@ApiParam(name = "pageUrl", value = "授权页面")
                           @RequestParam(value = "pageUrl", required = true)String pageUrl,
                           @ApiParam(name = "wxId", value = "微信id")
                           @RequestParam(value = "wxId", required = true)String wxId) {
        String ticket = getJsapi_ticketByToken(wxId);
            Map<Object, Object> map = new HashMap<Object, Object>();

+ 15 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/servicepackage/PackageService.java

@ -69,7 +69,7 @@ public class PackageService {
    @Autowired
    private PatientLabelDao patientLabelDao;
    public MixEnvelop findPackageService(String city,String labelCode,String labelType,Integer page,Integer size){
    public MixEnvelop findPackageService(String city,String labelCode,String labelType,String patient,Integer page,Integer size){
        String totalSql ="SELECT " +
                " count(1) as total " +
@ -122,6 +122,20 @@ public class PackageService {
        sql +=  "ORDER BY p.sort ASC LIMIT " + (page - 1) * size + "," + size + "";
        List<ServicePackageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServicePackageVO.class));
        //判断是否签约
        if(StringUtils.isNotBlank(patient)){
            if(list!=null&&list.size()>0){
                for(ServicePackageVO servicePackageVO:list){
                    if(findPatientSignExist(patient,servicePackageVO.getId())){
                        servicePackageVO.setSignType(1);
                    }else {
                        servicePackageVO.setSignType(0);
                    }
                }
            }
        }
        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
    }