zhaowenxuan
8 小时以前 accdd17211eac7b9b91553769224d6b99ab2c452
ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java
@@ -1,6 +1,7 @@
package com.ltkj.web.controller.app;
import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -14,8 +15,10 @@
import com.ltkj.framework.config.JwtUtils;
import com.ltkj.framework.config.UserHoder;
import com.ltkj.hosp.domain.GetPhone;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.Wxuser;
import com.ltkj.hosp.service.IAbucoderWxuserService;
import com.ltkj.hosp.service.ITjCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -42,10 +45,7 @@
import java.security.Security;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
 * @Author: 西安路泰科技有限公司/赵佳豪
@@ -60,7 +60,8 @@
@Api(tags = "A小程序端登录接口大全")
@Slf4j
public class WxloginController extends BaseController {
    @Resource
    private ITjCustomerService customerService;
    @Resource
    private IAbucoderWxuserService wxuserService;
@@ -135,6 +136,7 @@
        Wxuser wxuser = UserHoder.getWxuser();
        LambdaQueryWrapper<Wxuser> wq = new LambdaQueryWrapper<>();
        wq.eq(Wxuser::getOpenid, wxuser.getOpenid());
//        System.out.println("获取 ->"+wxuser.getOpenid());
        Wxuser one = wxuserService.getOne(wq);
        return AjaxResult.success(one);
    }
@@ -191,6 +193,23 @@
            }
        }
        return AjaxResult.success();
    }
    @PostMapping("/wx/bindPhoneV2")
    public AjaxResult bindPhoneV2(@RequestBody String json) {
        cn.hutool.json.JSONObject entries = JSONUtil.parseObj(json);
        String phone = entries.getStr("phone");
        Wxuser wxuser = UserHoder.getWxuser();
        LambdaQueryWrapper<Wxuser> wq = new LambdaQueryWrapper<>();
        wq.eq(Wxuser::getOpenid, wxuser.getOpenid());
        Wxuser one = wxuserService.getOne(wq);
//        System.out.println("绑定 ->"+wxuser.getOpenid()+",json = "+json);
        if (one != null){
            one.setPhone(phone);
            wxuserService.updateById(one);
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    /**
@@ -366,6 +385,15 @@
            one.setUpdateTime(new DateTime());
            final boolean b = wxuserService.updateById(one);
            if (b){
                LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
                qw.eq(TjCustomer::getCusPhone, phone);
                List<TjCustomer> tjCustomer1 = customerService.list(qw);
                if (tjCustomer1 != null && tjCustomer1.size()>0) {
                    for (TjCustomer tjCustomer : tjCustomer1) {
                        tjCustomer.setConnect(openId);
                        customerService.updateById(tjCustomer);
                    }
                }
                return AjaxResult.success("绑定成功!");
            }
        }