Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
wangzhinan 5 years ago
parent
commit
144ebfcb80

+ 5 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java

@ -440,7 +440,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
     * @return
     * @throws Exception
     */
    public Map<String,Object> savePrescriptionOrder(String code,Double price,String wechatId) throws Exception {
    public Map<String,Object> savePrescriptionOrder(String code,Double price,String tradeType,String wechatId) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        Map<String,Object> map = new HashedMap();
        if(wxWechatDO==null){
@ -453,10 +453,13 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                openId = patientWechatDos.get(0).getOpenid();
            }
            if (!StringUtils.isNoneBlank(tradeType)){
                tradeType=WeChatConfig.TRADE_TYPE_JSAPI;
            }
            String url = wxWechatDO.getBaseUrl();
            String notifyUrl =url;
            String totalFee =businessOrderDO.getPayPrice().intValue()+"";
            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, WeChatConfig.TRADE_TYPE_JSAPI,openId,businessOrderDO.getOrderNo(),notifyUrl);
            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, tradeType,openId,businessOrderDO.getOrderNo(),notifyUrl);
        }
        return map;
    }

+ 22 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -338,7 +338,7 @@ public class BusinessOrderService extends BaseJpaService {
    }
    public Map<String,Object> selectOrderByRelationCode(String relationCode,String wechatId) throws Exception {
    public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        String body = businessOrderDO.getDescription();
@ -352,10 +352,13 @@ public class BusinessOrderService extends BaseJpaService {
            }
        }
        String ourTradeNo = businessOrderDO.getOrderNo();
        if (!StringUtils.isNoneBlank(tradeType)){
            tradeType=WeChatConfig.TRADE_TYPE_JSAPI;
        }
        String url = wxWechatDO.getBaseUrl();
        String notifyUrl =url;
        Map<String,Object> map = unifiedorder(wechatId,body,totalFee,WeChatConfig.TRADE_TYPE_JSAPI,openid,ourTradeNo,notifyUrl);
        Map<String,Object> map = unifiedorder(wechatId,body,totalFee,tradeType,openid,ourTradeNo,notifyUrl);
        return map;
    }
@ -418,12 +421,29 @@ public class BusinessOrderService extends BaseJpaService {
        Map<String, Object> pay = unifiedorder(map, wxWechatDO.getAppKey());
        String returnCode = pay.get("return_code").toString();
        String resultCode = pay.get("result_code").toString();
        if (returnCode.equalsIgnoreCase("SUCCESS")){
            String appid = pay.get("appid").toString();
            String mchId = pay.get("mch_id").toString();
            String nonceStr = pay.get("nonce_str").toString();
            String prepayId = pay.get("prepay_id").toString();
            String trade = pay.get("trade_type").toString();
            if (trade.equalsIgnoreCase("Native")){
                Map<String,String> param = new HashedMap();
                param.put("appId",appid);
                param.put("package","prepay_id="+prepayId);
                param.put("nonceStr",nonceStr);
                param.put("signType","MD5");
                param.put("timeStamp",getTimeStamp());
                param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
                InputStream qrcode = QrcodeUtil.createQrcode(pay.get("code_url").toString(),300,"jpg");
                ByteToInputStream byteToInputStream = new ByteToInputStream();
                String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                param.put("qrcode","data:image/png;base64,"+ QRCodeImg);
                pay.put("native",param);
            }
            Map<String,String> param = new HashedMap();
            param.put("appId",appid);
            param.put("package","prepay_id="+prepayId);

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
    @GeneratedValue(generator = "generator")
/*    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)
    @Column(name = "id", unique = true, nullable = false)*/
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
/*    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 125 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyYkyyEndpoint.java

@ -7,10 +7,14 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.login.service.BaseLoginLogService;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.service.YkyyService;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.utils.security.MD5;
import io.swagger.annotations.Api;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
@ -34,7 +38,9 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by yeshijie on 2020/4/24.
@ -67,6 +73,8 @@ public class WlyyYkyyEndpoint extends AbstractEndpoint {
    private AuthenticationManager authenticationManager;
    @Autowired
    private WlyyTokenGranter tokenGranter;
    @Autowired
    private BasePatientDao basePatientDao;
    @PostConstruct
@ -156,6 +164,123 @@ public class WlyyYkyyEndpoint extends AbstractEndpoint {
        return ObjEnvelop.getError("登录失败!");
    }
    /**
     * 眼科居民登录
     * @param verifyCode
     * @param client_id
     * @param login_type 用户类型 1或默认为user,2:居民登录
     * @return
     */
    @RequestMapping(value = "/oauth/ykyyPatientLogin", method = RequestMethod.POST)
    public ObjEnvelop ykyyPatientLogin(String verifyCode, String client_id,String login_type) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        if (StringUtils.isEmpty(login_type)) {
            throw new InvalidRequestException("login_type is null");
        }
        try {
            logger.info("verifyCode :"+verifyCode);
            String data = ykyyService.getPatientInfoByVerifycode(verifyCode);
            JSONObject jsonObject = JSONObject.parseObject(data);
            if(!jsonObject.getString("code").equalsIgnoreCase("10000")){
                logger.info(jsonObject.getString("message"));
                return ObjEnvelop.getError("授权登录失败!");
            }
            JSONObject value = jsonObject.getJSONObject("value");
            String userId = value.getString("userId");
            String tel = value.getString("tel");
            String idCard = value.getString("Idcard");
            String yktId = value.getString("yktId");
            String name = value.getString("name");
            List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
//            String idCard = "352103197207090030";
            if(basePatientDOS == null||basePatientDOS.size()==0){
                BasePatientDO basePatientDO = new BasePatientDO();
                basePatientDO.setDel("1");
                basePatientDO.setName(name);
                basePatientDO.setCreateTime(new Date());
                basePatientDO.setUpdateTime(new Date());
                basePatientDO.setYktId(yktId);
                basePatientDO.setUserId(userId);
                basePatientDO.setIdcard(idCard);
                if (org.apache.commons.lang3.StringUtils.isNoneBlank(idCard)){
                    Integer age = IdCardUtil.getAgeForIdcard(idCard);
                    String sex = IdCardUtil.getSexForIdcard_new(idCard);
                    Integer sexx = null;
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(sex)){
                        sexx = Integer.parseInt(sex);
                    }
                    basePatientDO.setSex(sexx);
                    String birthday = IdCardUtil.getBirthdayForIdcardStr(idCard);
                    Date birthDay = null;
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(birthday)){
                        birthDay = DateUtil.strToDate(birthday+" 00:00:00");;
                    }
                    basePatientDO.setBirthday(birthDay);
                }
                basePatientDO.setMobile(tel);
                String salt = UUID.randomUUID().toString().substring(0,5);
                String pw = tel.substring(tel.length()-6,tel.length());
                basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                basePatientDO.setSalt(salt);
                basePatientDO.setLocked(0);
                basePatientDO.setEnabled(1);
                basePatientDO.setPatientStatus("1");
                basePatientDao.save(basePatientDO);
            }
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            Map<String, String> parameters = new HashedMap();
            parameters.put("username", tel);
            parameters.put("grant_type", "ihealthCode");
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            if (authenticatedClient != null) {
                oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            }
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            String loginType = parameters.get("login_type");
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogService.save(baseLoginLogDO);
            return ObjEnvelop.getSuccess("success",wlyyUserSimple);
        }catch (Exception e){
            logger.error(e);
        }
        return ObjEnvelop.getError("登录失败!");
    }
    @Override
    protected TokenGranter getTokenGranter() {
        return this.tokenGranter;

+ 10 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/YkyyService.java

@ -46,6 +46,16 @@ public class YkyyService {
        return httpClientUtil.get(yktUrl1+url+"?verifyCode="+verifyCode,"GBK");
    }
    /**
     * 眼科医院单点登录接口
     * @return
     */
    public String getPatientInfoByVerifycode(String verifyCode){
        String url = "/api/patient/GetPatientInfoByVerifycode";
        return httpClientUtil.get(yktUrl1+url+"?verifyCode="+verifyCode,"GBK");
    }
    /**
     *获取家庭成员信息
     *

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java

@ -155,9 +155,11 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop findPatientCard(@ApiParam(name = "code", value = "处方code")
                                       @RequestParam(value = "code", required = true)String code,
                                       @ApiParam(name = "price", value = "支付费用")
                                       @RequestParam(value = "price", required = false)Double price)throws Exception {
                                       @RequestParam(value = "price", required = false)Double price,
                                      @ApiParam(name = "tradeType", value = "支付方式")
                                          @RequestParam(value = "tradeType", required = false)String tradeType)throws Exception {
        try {
            return success("ok",prescriptionService.savePrescriptionOrder(code,price,wxId));
            return success("ok",prescriptionService.savePrescriptionOrder(code,price,tradeType,wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

@ -321,9 +321,11 @@ public class YkyyController extends EnvelopRestEndpoint {
    @ApiOperation("获取微信支付参数")
    public ObjEnvelop selectOrderByRelationCode(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode) throws Exception {
            @RequestParam(required = true)String relationCode,
            @ApiParam(name = "tradeType", value = "tradeType", required = false)
            @RequestParam(required = false)String tradeType) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,wxId));
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }