From 9ac01b48ef00a0855306d72e8c680b912a9a8d03 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 07 八月 2025 08:44:50 +0800
Subject: [PATCH] zjh20250807

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java |  158 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 147 insertions(+), 11 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java
index b65f275..3e5f0f0 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java
@@ -1,5 +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;
@@ -13,8 +15,13 @@
 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.TjOrder;
 import com.ltkj.hosp.domain.Wxuser;
 import com.ltkj.hosp.service.IAbucoderWxuserService;
+import com.ltkj.hosp.service.ITjCustomerService;
+import com.ltkj.hosp.service.ITjOrderRemarkService;
+import com.ltkj.hosp.service.ITjOrderService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -24,7 +31,9 @@
 import okhttp3.Response;
 import org.aspectj.bridge.MessageWriter;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.client.RestTemplate;
 import sun.misc.BASE64Decoder;
@@ -40,10 +49,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: 瑗垮畨璺嘲绉戞妧鏈夐檺鍏徃/璧典匠璞�
@@ -58,10 +64,16 @@
 @Api(tags = "A灏忕▼搴忕鐧诲綍鎺ュ彛澶у叏")
 @Slf4j
 public class WxloginController extends BaseController {
-
+    @Resource
+    private ITjCustomerService customerService;
 
     @Resource
     private IAbucoderWxuserService wxuserService;
+    @Autowired
+    private ITjOrderService orderService;
+
+    @Resource
+    private ITjOrderRemarkService remarkService;
 
     @Value("${xcx.appid}")
     private String appid;
@@ -71,6 +83,7 @@
 
     /**
      * 灏忕▼搴忕櫥褰�
+     *
      * @param code 灏忕▼搴弚x.login杩斿洖鐨勪复鏃跺嚟璇�
      * @return
      */
@@ -110,7 +123,7 @@
                 wxuser.setCreateTime(new Date());
                 wxuser.setWxMiniOpenId(openId);
                 wxuserService.save(wxuser);
-                map.put("wxuser",wxuser);
+                map.put("wxuser", wxuser);
             }
             // 鐢熸垚浠ょ墝
             String token = JwtUtils.getToken(map);
@@ -130,11 +143,13 @@
     @ApiOperation(value = "灏忕▼搴忚幏鍙栫敤鎴疯鎯呬俊鎭帴鍙�")
     public AjaxResult getWxInfo() {
         Wxuser wxuser = UserHoder.getWxuser();
-        LambdaQueryWrapper<Wxuser>wq=new LambdaQueryWrapper<>();
-        wq.eq(Wxuser::getOpenid,wxuser.getOpenid());
+        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);
     }
+
     /**
      * 寰俊鎵嬫満鍙风爜缁戝畾
      */
@@ -156,7 +171,7 @@
                 byte[] raw = decoder.decodeBuffer(sessionKey);
                 SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
                 IvParameterSpec iv1 = new IvParameterSpec(decoder.decodeBuffer(iv));
-                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding","BC");
+                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC");
                 cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv1);
                 OkHttpClient client = new OkHttpClient();
                 Request okrequest = new Request.Builder()
@@ -189,8 +204,85 @@
         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();
+    }
+
+
+    @PostMapping("/wx/wenzhenxinxi")
+    @ApiOperation("灏忕▼搴忛棶璇婁俊鎭�")
+    public AjaxResult wenzhenxinxi(@RequestBody String json) {
+        cn.hutool.json.JSONObject entries = JSONUtil.parseObj(json);
+        String idCard = entries.getStr("idCard");
+        TjCustomer tjCustomer = customerService.getTjCustomerByCusIdCard(idCard);
+        if(null != tjCustomer){
+            List<Map<String, Object>> mapList = new ArrayList<>();
+            LambdaQueryWrapper<TjOrder> wq=new LambdaQueryWrapper<>();
+            wq.eq(TjOrder::getUserId, tjCustomer.getCusId());
+            List<TjOrder> list = orderService.list(wq);
+            if(null != list && !list.isEmpty()){
+                for (TjOrder order : list) {
+                    Map<String, Object> map = new HashMap<>();
+                    if(order.getPacId().equals("0")){
+                        map.put("pacName","鏅�氫綋妫�");
+                    }else {
+                        map.put("pacName",orderService.getpacName(order.getPacId()));
+                    }
+                    map.put("zjq",orderService.gettjzj(order.getOrderId()));
+                    map.put("tjsj",order.getCreateTime());
+                    map.put("tjxm",remarkService.getTjxm(order.getTjNumber()));
+                    int czwj = remarkService.panduaniscunzaiweijian(order.getTjNumber());
+                    int sfwc = remarkService.panduaniswancheng(order.getTjNumber());
+                    Date checkTime = order.getCheckTime();
+                    Date reportTime = order.getReportTime();
+                    Integer heshouStatus = order.getHeshouStatus();
+                    Date lastTime = order.getPrintLastTime();
+                    if (czwj == 0) {
+                        map.put("tjzt","鏈");
+                    }
+                    if (czwj > 0) {
+                        map.put("tjzt","鍦ㄦ");
+                    }
+                    if (sfwc == 0) {
+                        map.put("tjzt","宸插畬鎴�");
+                    }
+                    if (null != checkTime) {
+                        map.put("tjzt","宸插鏍�");
+                    }
+                    if (null != reportTime) {
+                        map.put("tjzt","鐢熸垚鎶ュ憡");
+                    }
+                    if (1 == heshouStatus) {
+                        map.put("tjzt","鎶ュ憡鏍告敹");
+                    }
+                    if (null != lastTime) {
+                        map.put("tjzt","宸叉墦鍗�");
+                    }
+                    mapList.add(map);
+                }
+                return AjaxResult.success(mapList);
+            }
+        }
+
+        return AjaxResult.error("鏆傛棤闂瘖璁板綍");
+    }
+
     /**
      * 鍙戦�佽姹傜敤code鎹㈠彇sessionKey鍜岀浉鍏充俊鎭�
+     *
      * @param code
      * @return
      */
@@ -208,7 +300,15 @@
      * @param sessionKey
      * @param iv
      * @return
+     *
      */
+    /**
+     * 瑙e喅java涓嶆敮鎸丄ES/CBC/PKCS7Padding妯″紡瑙e瘑
+     */
+    static {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
     public static JSONObject decryptionUserInfo(String encryptedData, String sessionKey, String iv) {
         // 琚姞瀵嗙殑鏁版嵁
         byte[] dataByte = Base64.decode(encryptedData);
@@ -218,7 +318,7 @@
         byte[] ivByte = Base64.decode(iv);
 
         try {
-        // 濡傛灉瀵嗛挜涓嶈冻16浣嶏紝閭d箞灏辫ˉ瓒�. 杩欎釜if 涓殑鍐呭寰堥噸瑕�
+            // 濡傛灉瀵嗛挜涓嶈冻16浣嶏紝閭d箞灏辫ˉ瓒�. 杩欎釜if 涓殑鍐呭寰堥噸瑕�
             int base = 16;
             if (keyByte.length % base != 0) {
                 int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0);
@@ -227,8 +327,12 @@
                 System.arraycopy(keyByte, 0, temp, 0, keyByte.length);
                 keyByte = temp;
             }
-        // 鍒濆鍖�
+            // 鍒濆鍖�
             Security.addProvider(new BouncyCastleProvider());
+            /**
+             * 瑙e喅java涓嶆敮鎸丄ES/CBC/PKCS7Padding妯″紡瑙e瘑
+             */
+
             Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
             SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
             AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
@@ -245,6 +349,7 @@
         }
         return null;
     }
+
 
     /**
      * 鍙戦�乭ttps璇锋眰
@@ -332,5 +437,36 @@
         return response;
     }
 
+
+    @PostMapping("/wx/wxbindphone")
+    @ApiOperation("鎵嬪姩缁戝畾鎵嬫満鍙锋帴鍙�")
+    @Transactional
+    public AjaxResult wxbindphone(@RequestParam @ApiParam(value = "openId") String openId,
+                                  @RequestParam @ApiParam(value = "phone") String phone) {
+
+        LambdaQueryWrapper<Wxuser> wq = new LambdaQueryWrapper<>();
+        wq.eq(Wxuser::getOpenid, openId);
+        Wxuser one = wxuserService.getOne(wq);
+
+        if (one!=null){
+            one.setPhone(phone);
+            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.isEmpty()) {
+                    for (TjCustomer tjCustomer : tjCustomer1) {
+                        tjCustomer.setConnect(openId);
+                        customerService.updateById(tjCustomer);
+                    }
+                }
+                return AjaxResult.success("缁戝畾鎴愬姛锛�");
+            }
+        }
+        return AjaxResult.error("缁戝畾澶辫触锛�");
+    }
+
 }
 

--
Gitblit v1.8.0