Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eMall_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨硕
eMall_api
Commits
ca63cdaf
Commit
ca63cdaf
authored
Jul 19, 2023
by
高宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员码接口
parent
864c7391
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
721 additions
and
0 deletions
+721
-0
CyQrCodeUtil.java
...ore/src/main/java/com/emall/flash/utils/CyQrCodeUtil.java
+47
-0
Qrcode.java
emall-core/src/main/java/com/emall/flash/utils/Qrcode.java
+635
-0
pom.xml
emall-mobile-api/pom.xml
+6
-0
UserController.java
...ava/com/emall/flash/mobile/controller/UserController.java
+33
-0
No files found.
emall-core/src/main/java/com/emall/flash/utils/CyQrCodeUtil.java
0 → 100644
View file @
ca63cdaf
package
com
.
emall
.
flash
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.UnsupportedEncodingException
;
public
class
CyQrCodeUtil
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
CyQrCodeUtil
.
class
);
private
static
final
Integer
QC_CODE_WIDTH
=
235
;
private
static
final
Integer
QC_CODE_HEIGHT
=
235
;
public
CyQrCodeUtil
()
{
}
public
static
BufferedImage
qRCodeCommon
(
String
content
)
throws
UnsupportedEncodingException
{
Qrcode
qrcode
=
new
Qrcode
();
qrcode
.
setQrcodeEncodeMode
(
'B'
);
qrcode
.
setQrcodeVersion
(
15
);
qrcode
.
setQrcodeErrorCorrect
(
'M'
);
BufferedImage
image
=
new
BufferedImage
(
QC_CODE_WIDTH
,
QC_CODE_HEIGHT
,
1
);
Graphics2D
gs
=
image
.
createGraphics
();
gs
.
setBackground
(
Color
.
white
);
gs
.
setColor
(
Color
.
black
);
gs
.
clearRect
(
0
,
0
,
QC_CODE_WIDTH
,
QC_CODE_HEIGHT
);
Object
var4
=
null
;
try
{
byte
[]
codeOut
=
content
.
getBytes
(
"utf-8"
);
boolean
[][]
code
=
qrcode
.
calQrcode
(
codeOut
);
for
(
int
i
=
0
;
i
<
code
.
length
;
++
i
)
{
for
(
int
j
=
0
;
j
<
code
.
length
;
++
j
)
{
if
(
code
[
j
][
i
])
{
gs
.
fillRect
(
j
*
3
+
2
,
i
*
3
+
2
,
3
,
3
);
}
}
}
return
image
;
}
catch
(
Exception
var8
)
{
log
.
error
(
var8
.
getMessage
());
throw
var8
;
}
}
}
emall-core/src/main/java/com/emall/flash/utils/Qrcode.java
0 → 100644
View file @
ca63cdaf
This diff is collapsed.
Click to expand it.
emall-mobile-api/pom.xml
View file @
ca63cdaf
...
@@ -57,6 +57,12 @@
...
@@ -57,6 +57,12 @@
<artifactId>
geodesy
</artifactId>
<artifactId>
geodesy
</artifactId>
<version>
1.1.3
</version>
<version>
1.1.3
</version>
</dependency>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.3.8
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
emall-mobile-api/src/main/java/com/emall/flash/mobile/controller/UserController.java
View file @
ca63cdaf
package
com
.
emall
.
flash
.
mobile
.
controller
;
package
com
.
emall
.
flash
.
mobile
.
controller
;
import
cn.hutool.core.codec.Base64Encoder
;
import
com.emall.flash.bean.entity.shop.ShopUser
;
import
com.emall.flash.bean.entity.shop.ShopUser
;
import
com.emall.flash.bean.entity.system.FileInfo
;
import
com.emall.flash.bean.entity.system.FileInfo
;
import
com.emall.flash.bean.vo.UserInfo
;
import
com.emall.flash.bean.vo.UserInfo
;
...
@@ -10,15 +11,21 @@ import com.emall.flash.security.JwtUtil;
...
@@ -10,15 +11,21 @@ import com.emall.flash.security.JwtUtil;
import
com.emall.flash.service.api.WeixinService
;
import
com.emall.flash.service.api.WeixinService
;
import
com.emall.flash.service.shop.ShopUserService
;
import
com.emall.flash.service.shop.ShopUserService
;
import
com.emall.flash.service.system.FileService
;
import
com.emall.flash.service.system.FileService
;
import
com.emall.flash.utils.CyQrCodeUtil
;
import
com.emall.flash.utils.MD5
;
import
com.emall.flash.utils.MD5
;
import
com.emall.flash.utils.StringUtil
;
import
com.emall.flash.utils.StringUtil
;
import
com.emall.flash.web.controller.BaseController
;
import
com.emall.flash.web.controller.BaseController
;
import
com.google.protobuf.ServiceException
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -49,6 +56,11 @@ public class UserController extends BaseController {
...
@@ -49,6 +56,11 @@ public class UserController extends BaseController {
}
}
return
Rets
.
success
(
userInfo
);
return
Rets
.
success
(
userInfo
);
}
}
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
public
Object
update
(
ShopUser
shopUser
){
shopUserService
.
update
(
shopUser
);
return
Rets
.
success
(
shopUser
);
}
@RequestMapping
(
value
=
"/updateUserName/{userName}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/updateUserName/{userName}"
,
method
=
RequestMethod
.
POST
)
public
Object
updateUserName
(
@PathVariable
(
"userName"
)
String
userName
){
public
Object
updateUserName
(
@PathVariable
(
"userName"
)
String
userName
){
ShopUser
user
=
shopUserService
.
getCurrentUser
();
ShopUser
user
=
shopUserService
.
getCurrentUser
();
...
@@ -138,4 +150,25 @@ public class UserController extends BaseController {
...
@@ -138,4 +150,25 @@ public class UserController extends BaseController {
shopUserService
.
update
(
shopUser
);
shopUserService
.
update
(
shopUser
);
return
Rets
.
success
(
shopUser
);
return
Rets
.
success
(
shopUser
);
}
}
// 生成会员二维码
@RequestMapping
(
value
=
"/setTenantId"
,
method
=
RequestMethod
.
GET
)
public
Object
getTradeScan
(
String
id
)
throws
ServiceException
{
String
png_base64
=
null
;
//返回二维码 并且构造支付包web支付对象
ByteArrayOutputStream
baOp
=
new
ByteArrayOutputStream
();
try
{
BufferedImage
bufImg
=
CyQrCodeUtil
.
qRCodeCommon
(
id
);
// 生成二维码QRCode图片
ImageIO
.
write
(
bufImg
,
"png"
,
baOp
);
byte
[]
bytes
=
baOp
.
toByteArray
();
//转换成字节
/**
* jdk 17 替代方案
*/
png_base64
=
Base64Encoder
.
encode
(
bytes
).
trim
();
png_base64
=
png_base64
.
replaceAll
(
"\n"
,
""
).
replaceAll
(
"\r"
,
""
);
//删除 \r\n
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"系统错误"
);
}
return
Rets
.
success
(
png_base64
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment