Commit c00d5336825accc63c8b016545fc853eab3fdda0

Authored by changpengfei
1 parent 25bb531d8d
Exists in master

增加患者获取微信登录openid

Showing 1 changed file with 14 additions and 7 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java View file @ c00d533
... ... @@ -15,6 +15,7 @@
15 15 import com.lyms.talkonlineweb.util.*;
16 16 import lombok.extern.log4j.Log4j2;
17 17 import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.util.StringUtils;
18 19 import org.springframework.validation.BindingResult;
19 20 import org.springframework.validation.annotation.Validated;
20 21 import org.springframework.web.bind.annotation.*;
... ... @@ -162,7 +163,7 @@
162 163 log.info(ness.toString());
163 164 }
164 165  
165   - Date instDate=new Date();
  166 + Date instDate = new Date();
166 167 //需要添加医院购买卡记录
167 168 for (int i = 0; i < patient.getCcnt(); i++) {
168 169 LymsTcard tcard = new LymsTcard();
... ... @@ -215,7 +216,7 @@
215 216 * @return
216 217 */
217 218 @PostMapping("loginPatient")
218   - public BaseResponse loginPatient(@RequestBody LymsPatient patient) {
  219 + public BaseResponse loginPatient(@RequestBody LymsPatient patient, String code) {
219 220 BaseResponse baseResponse = new BaseResponse();
220 221 List<LymsPatient> dLst = lymsPatientService.list(Wrappers.query(patient));
221 222 baseResponse.setErrorcode(1);
... ... @@ -227,11 +228,17 @@
227 228  
228 229 patient.setIslogin(1);
229 230  
230   - if (patient.getHxid() == null) {
231   - JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
232   - JSONArray rArr = json.getJSONArray("entities");
233   - if (rArr.size() > 0) {
234   - patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
  231 + if (StringUtils.isEmpty(patient.getHxid()) || StringUtils.isEmpty(patient.getOpenid())) {
  232 +
  233 + if (patient.getHxid() == null) {
  234 + JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
  235 + JSONArray rArr = json.getJSONArray("entities");
  236 + if (rArr.size() > 0) {
  237 + patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
  238 + }
  239 + }
  240 + if (StringUtils.isEmpty(patient.getOpenid())) {
  241 + patient.setOpenid(WeiXinUtil.getWxOpenId(code));
235 242 }
236 243 lymsPatientService.saveOrUpdate(patient);
237 244 }