From 4b7a37f8905d0610b323bce293962a8e1a3554e0 Mon Sep 17 00:00:00 2001
From: "DESKTOP-369JRHT\\12997" <9>
Date: Fri, 31 May 2024 10:37:17 +0800
Subject: [PATCH] no message

---
 .../business/member/utils/QrCodeUtils.java    | 37 +++++++++
 .../controller/QRCodeController.java          |  5 ++
 .../service/IQRCodeService.java               |  1 +
 .../service/impl/QRCodeServiceImpl.java       | 39 ++++++++++
 pos-uni/pagesHome/AddVip/AddCode.vue          | 77 ++++++++++++++++---
 5 files changed, 149 insertions(+), 10 deletions(-)

diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
index bb5c31a93..70629ebca 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
@@ -129,6 +129,43 @@ public class QrCodeUtils {
         }
     }
 
+    public void createLogoCodePictureByPos(InputStream backgroundStream, InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
+        try {
+            // 读取原图片信息
+            //使用工具类生成二维码
+            Image image = createQrCode(null, url, 200, 200);
+
+//            查询当前店铺信息
+            if (ObjectUtils.isNotEmpty(storeId)){
+                LJStore store = storeService.selectStoreByStoreId(storeId);
+//            查询加油员信息
+                LJStaff staff = null;
+                if (ObjectUtil.isNotEmpty(staffId)){
+                    staff = staffService.selectStaffById(staffId);
+                }
+                LJStaff staff1 = staffService.selectStaffByStoreId(storeId);
+            }else {
+            }
+            // 输出图片
+            String urlsss = "/temp/qrCode/";
+            if (ObjectUtils.isNotEmpty(urls)){
+                urlsss = urls;
+            }
+            File file1 = new File(urlsss);
+            // 判断目录是否存在
+            if (!file1.exists()) {
+                file1.mkdirs();
+            }
+
+            FileOutputStream outImgStream = new FileOutputStream(outImgPath);
+            ImageIO.write((RenderedImage) image, "jpg", outImgStream);
+            outImgStream.flush();
+            outImgStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     public void createLogoCodePictures(InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
         try {
             // 读取原图片信息
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/QRCodeController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/QRCodeController.java
index 6086a258a..85e9043a7 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/QRCodeController.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/QRCodeController.java
@@ -40,6 +40,11 @@ public class QRCodeController extends BaseController {
         String type = map.get("type");
         return getSuccessResult(iqrCodeService.createStoreQrCode(type,request));
     }
+    @PostMapping("/createStoreQrCodeByPos")
+    public ResponseObject createStoreQrCodeByPos(HttpServletRequest request, @RequestBody Map<String,String> map) throws Exception {
+        String type = map.get("type");
+        return getSuccessResult(iqrCodeService.createStoreQrCodeByPos(type,request));
+    }
 
     /**
      * 根据店铺id查询二维码信息
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/IQRCodeService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/IQRCodeService.java
index 034fc7d6e..8576c9b26 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/IQRCodeService.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/IQRCodeService.java
@@ -22,6 +22,7 @@ public interface IQRCodeService  extends IService<QRCode> {
     public IPage<QRCode> selectQRCodeList(Page page, QRCode qrCode);
 
     String createStoreQrCode(String type, HttpServletRequest request) throws Exception;
+    String createStoreQrCodeByPos(String type, HttpServletRequest request) throws Exception;
 
     /**
      * 根据店铺id查询二维码信息
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/impl/QRCodeServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/impl/QRCodeServiceImpl.java
index 5020212ea..83fd3a449 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/impl/QRCodeServiceImpl.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/service/impl/QRCodeServiceImpl.java
@@ -90,6 +90,45 @@ public class QRCodeServiceImpl extends ServiceImpl<QRCodeMapper, QRCode> impleme
         String saveFile = backendFileController.saveFile(resFile);
         return saveFile;
     }
+    @Override
+    public String createStoreQrCodeByPos(String type, HttpServletRequest request) throws Exception {
+        AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
+        Integer storeId = nowAccountInfo.getStoreId();
+        QRCode qrCode = selectQRCodeByStoreId(storeId);
+        //        根据id查询员工信息和店铺信息
+        LJStore store = storeService.selectStoreByStoreId(storeId);
+        //在图片上生成二维码
+        String backgroundImage = "";
+//        if (type.equals("0")){
+//            backgroundImage = "static/qrCodeImg/laigeyouhui_bg.jpg";
+//        }else {
+//            backgroundImage = "static/qrCodeImg/laigeyouhui_bg1.png";
+//        }
+
+        String logoImage = "static/qrCodeImg/logo.png";
+//        if (StringUtils.isNotEmpty(store.getLogo())){
+//            logoImage = store.getLogo();
+//        }
+        String url = qrCode.getCollection();
+        String area = store.getName();
+        String finalPath="/temp/qrCode/" + area + ".jpg";
+        InputStream backgroundStream = this.getClass().getClassLoader().getResourceAsStream(backgroundImage);
+        InputStream logoStream = this.getClass().getClassLoader().getResourceAsStream(logoImage);
+        //背景图片路径 loge图片 二维码 输出地址
+        qrCodeUtils.createLogoCodePictureByPos(backgroundStream, logoStream, url, finalPath, null,store.getId(),null);
+        File file1 = new File("/temp/qrCode/");
+        // 判断目录是否存在
+        if (!file1.exists()) {
+            file1.mkdirs();
+        }
+
+        File file =new File(finalPath);
+        FileInputStream fileInputStream =new FileInputStream(file);
+        MultipartFile resFile = new MockMultipartFile("file", file.getName(), null, fileInputStream);
+//        返回图片路径
+        String saveFile = backendFileController.saveFile(resFile);
+        return saveFile;
+    }
 
     @Override
     public QRCode selectQRCode() {
diff --git a/pos-uni/pagesHome/AddVip/AddCode.vue b/pos-uni/pagesHome/AddVip/AddCode.vue
index 9bd90397e..21dfc46cf 100644
--- a/pos-uni/pagesHome/AddVip/AddCode.vue
+++ b/pos-uni/pagesHome/AddVip/AddCode.vue
@@ -7,11 +7,14 @@
 				<view class="title_">扫码成为京博加油站会员</view>
 				<view
 					style="background: #fff;width: 215px; height: 220px; border-radius: 8px ; margin: 15px auto; box-sizing: border-box; padding-top: 10px;  ">
-					<canvas id="qrcode" canvas-id="qrcode"
-						style="width: 200px;height: 200px;  margin: 0px auto;  "></canvas>
+					<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;  margin: 0px auto;  ">
+						<!-- <image url="https://cdn.uviewui.com/uview/resources/18496183264.png"></image> -->
+
+					</canvas>
+
 				</view>
 
-				<view class="title_">长按识别领取会员卡</view>
+				<view class="title_">扫码识别领取会员卡</view>
 			</view>
 
 			<view class="p-bottom">
@@ -26,6 +29,7 @@
 
 <script>
 	import request from "../../utils/request";
+	import config from '@/config'
 
 	import headers from '../../components/header/headers.vue'
 	import UQRCode from '../../uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
@@ -33,6 +37,9 @@
 		data() {
 			return {
 				titles: "新增会员",
+				storeId: '',
+				collectionImg: '',
+				baseUrl: config.baseUrl,
 
 			}
 		},
@@ -40,7 +47,10 @@
 
 			// this.actList = ["1", "1", "1", "1", "1", ]
 			// this.status = "nomore" 底部刷新结束
-			this.onReady()
+			// this.getStore()
+			this.getQRCodeInfoByStoreId()
+			// this.onReady2()
+			// await this.onReady()
 		},
 		onPullDownRefresh() {
 			console.log("刷新");
@@ -56,7 +66,47 @@
 			headers
 		},
 		methods: {
-			onReady() {
+			// async getStore() {
+			// 	await request({
+			// 		url: 'business/storeInformation/store',
+			// 		method: 'get',
+			// 		params: this.form
+			// 	}).then((res) => {
+			// 		if (res.code == 200) {
+			// 			this.storeId = res.data.id
+
+			// 		} else {
+			// 			uni.showToast({
+			// 				title: res.data,
+			// 				icon: "none"
+			// 			})
+			// 		}
+			// 	})
+			// },
+			getQRCodeInfoByStoreId() {
+				request({
+					url: 'business/storeInformation/qrCode/createStoreQrCodeByPos',
+					method: 'post',
+					data: {
+						type: 0
+					}
+				}).then((res) => {
+
+					if (res.code == 200) {
+						this.collectionImg = res.data;
+						console.log("res", res)
+						this.onReady2()
+					} else {
+						uni.showToast({
+							title: res.data,
+							icon: "none"
+						})
+					}
+
+				})
+			},
+			onReady2() {
+
 				// 获取uQRCode实例
 				var qr = new UQRCode();
 				// 设置二维码内容
@@ -66,11 +116,18 @@
 				// 调用制作二维码方法
 				qr.make();
 				// 获取canvas上下文
-				var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
-				// 设置uQRCode实例的canvas上下文
-				qr.canvasContext = canvasContext;
-				// 调用绘制方法将二维码图案绘制到canvas上
-				qr.drawCanvas();
+				// var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
+				// // 设置uQRCode实例的canvas上下文
+				// qr.canvasContext = canvasContext;
+				// // 调用绘制方法将二维码图案绘制到canvas上
+				// qr.drawCanvas();
+				const url = this.baseUrl + this.collectionImg
+				// const url = ""
+				console.log("this.collectionImg()", url)
+
+				const ctx = uni.createCanvasContext('qrcode', this);
+				ctx.drawImage(url, 0, 0, 200, 200);
+				ctx.draw(true, () => {})
 			},
 			goback() {
 				uni.navigateTo({