Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
fd710d15
Commit
fd710d15
authored
Aug 07, 2018
by
Menethil
Browse files
添加团购
parent
6f8bedd4
Changes
10
Hide whitespace changes
Inline
Side-by-side
litemall-admin/config/dep.env.js
View file @
fd710d15
module
.
exports
=
{
NODE_ENV
:
'
"production"
'
,
ENV_CONFIG
:
'
"dep"
'
,
BASE_API
:
'
"http://
localhost:8080
/admin"
'
BASE_API
:
'
"http
s
://
www.menethil.com.cn
/admin"
'
}
litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeService.java
View file @
fd710d15
...
...
@@ -30,7 +30,7 @@ public class QCodeService {
File
file
=
wxMaService
.
getQrcodeService
().
createWxaCodeUnlimit
(
"groupon,"
+
groupon
.
getId
(),
"pages/index/index"
);
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
//将商品图片,商品名字,商城名字画到模版图中
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
,
SystemConfig
.
getMallName
()
);
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
);
ByteArrayInputStream
inputStream2
=
new
ByteArrayInputStream
(
imageData
);
//存储分享图
String
url
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
groupon
.
getId
().
toString
()));
...
...
@@ -42,8 +42,6 @@ public class QCodeService {
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
FontFormatException
e
)
{
e
.
printStackTrace
();
}
return
""
;
...
...
@@ -66,7 +64,7 @@ public class QCodeService {
File
file
=
wxMaService
.
getQrcodeService
().
createWxaCodeUnlimit
(
"goods,"
+
goodId
,
"pages/index/index"
);
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
//将商品图片,商品名字,商城名字画到模版图中
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
,
SystemConfig
.
getMallName
()
);
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
);
ByteArrayInputStream
inputStream2
=
new
ByteArrayInputStream
(
imageData
);
//存储分享图
String
url
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
goodId
));
...
...
@@ -78,8 +76,6 @@ public class QCodeService {
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
FontFormatException
e
)
{
e
.
printStackTrace
();
}
return
""
;
...
...
@@ -98,9 +94,9 @@ public class QCodeService {
* @return
* @throws IOException
*/
private
byte
[]
drawPicture
(
InputStream
qrCodeImg
,
String
goodPicUrl
,
String
goodName
,
String
shopName
)
throws
IOException
,
FontFormat
Exception
{
private
byte
[]
drawPicture
(
InputStream
qrCodeImg
,
String
goodPicUrl
,
String
goodName
)
throws
IO
Exception
{
//底图
ClassPathResource
redResource
=
new
ClassPathResource
(
"back.
j
pg"
);
ClassPathResource
redResource
=
new
ClassPathResource
(
"back.p
n
g"
);
BufferedImage
red
=
ImageIO
.
read
(
redResource
.
getInputStream
());
...
...
@@ -120,16 +116,16 @@ public class QCodeService {
drawImgInImg
(
baseImage
,
red
,
0
,
0
,
red
.
getWidth
(),
red
.
getHeight
());
//画上商品图片
drawImgInImg
(
baseImage
,
goodImage
,
56
,
135
,
72
0
,
72
0
);
drawImgInImg
(
baseImage
,
goodImage
,
71
,
69
,
66
0
,
66
0
);
//画上小程序二维码
drawImgInImg
(
baseImage
,
qrCodeImage
,
44
2
,
1006
,
3
4
0
,
3
4
0
);
drawImgInImg
(
baseImage
,
qrCodeImage
,
44
8
,
767
,
3
0
0
,
3
0
0
);
//写上商品名称
drawTextInImg
(
baseImage
,
goodName
,
112
,
955
);
drawTextInImg
(
baseImage
,
goodName
,
65
,
867
);
//写上商城名称
drawTextInImgCenter
(
baseImage
,
shopName
,
98
);
//
drawTextInImgCenter(baseImage, shopName, 98);
//转jpg
...
...
@@ -149,7 +145,7 @@ public class QCodeService {
String
fontName
=
"Microsoft YaHei"
;
Font
f
=
new
Font
(
fontName
,
Font
.
PLAIN
,
4
2
);
Font
f
=
new
Font
(
fontName
,
Font
.
PLAIN
,
2
8
);
g2D
.
setFont
(
f
);
g2D
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
...
...
@@ -169,7 +165,7 @@ public class QCodeService {
g2D
.
setColor
(
new
Color
(
167
,
136
,
69
));
//TODO 注意,这里的字体必须安装在服务器上
g2D
.
setFont
(
new
Font
(
"Microsoft YaHei"
,
Font
.
PLAIN
,
4
2
));
g2D
.
setFont
(
new
Font
(
"Microsoft YaHei"
,
Font
.
PLAIN
,
2
8
));
g2D
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g2D
.
drawString
(
textToWrite
,
x
,
y
);
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java
View file @
fd710d15
...
...
@@ -22,7 +22,11 @@ class SystemInistService {
private
void
inist
()
{
systemInistService
=
this
;
SystemInfoPrinter
.
printInfo
(
"Litemall 初始化信息"
,
getSystemInfo
());
try
{
SystemInfoPrinter
.
printInfo
(
"Litemall 初始化信息"
,
getSystemInfo
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
Map
<
String
,
String
>
getSystemInfo
()
{
...
...
litemall-core/src/main/resources/back.jpg
deleted
100644 → 0
View file @
6f8bedd4
72.8 KB
litemall-core/src/main/resources/back.png
0 → 100644
View file @
fd710d15
39.8 KB
litemall-core/src/main/resources/back_groupon.png
0 → 100644
View file @
fd710d15
43.6 KB
litemall-db/sql/litemall_groupon.sql
0 → 100644
View file @
fd710d15
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Type : MySQL
Source Server Version : 80011
Source Host : localhost:3306
Source Schema : litemall2
Target Server Type : MySQL
Target Server Version : 80011
File Encoding : 65001
Date: 06/08/2018 20:16:26
*/
SET
NAMES
utf8mb4
;
SET
FOREIGN_KEY_CHECKS
=
0
;
-- ----------------------------
-- Table structure for litemall_groupon
-- ----------------------------
DROP
TABLE
IF
EXISTS
`litemall_groupon`
;
CREATE
TABLE
`litemall_groupon`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`order_id`
int
(
11
)
NOT
NULL
COMMENT
'关联的订单ID'
,
`groupon_id`
int
(
11
)
NULL
DEFAULT
0
COMMENT
'参与的团购ID,仅当user_type不是1'
,
`rules_id`
int
(
11
)
NOT
NULL
COMMENT
'团购规则ID,关联litemall_groupon_rules表ID字段'
,
`user_id`
int
(
11
)
NOT
NULL
COMMENT
'用户ID'
,
`creator_user_id`
int
(
11
)
NOT
NULL
COMMENT
'创建者ID'
,
`add_time`
datetime
(
0
)
NOT
NULL
COMMENT
'创建时间'
,
`share_url`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'团购分享图片地址'
,
`payed`
tinyint
(
1
)
NOT
NULL
COMMENT
'是否已经支付'
,
`deleted`
tinyint
(
1
)
NULL
DEFAULT
0
COMMENT
'逻辑删除'
,
`version`
int
(
11
)
NULL
DEFAULT
0
COMMENT
'乐观锁字段'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
44
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
SET
FOREIGN_KEY_CHECKS
=
1
;
litemall-db/sql/litemall_groupon_rules.sql
0 → 100644
View file @
fd710d15
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Type : MySQL
Source Server Version : 80011
Source Host : localhost:3306
Source Schema : litemall2
Target Server Type : MySQL
Target Server Version : 80011
File Encoding : 65001
Date: 06/08/2018 20:16:37
*/
SET
NAMES
utf8mb4
;
SET
FOREIGN_KEY_CHECKS
=
0
;
-- ----------------------------
-- Table structure for litemall_groupon_rules
-- ----------------------------
DROP
TABLE
IF
EXISTS
`litemall_groupon_rules`
;
CREATE
TABLE
`litemall_groupon_rules`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`goods_id`
int
(
11
)
NOT
NULL
COMMENT
'商品表的商品ID'
,
`goods_name`
varchar
(
127
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NOT
NULL
COMMENT
'商品名称'
,
`pic_url`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'商品图片或者商品货品图片'
,
`discount`
decimal
(
63
,
0
)
NOT
NULL
COMMENT
'优惠金额'
,
`discount_member`
int
(
11
)
NOT
NULL
COMMENT
'达到优惠条件的人数'
,
`add_time`
datetime
(
0
)
NOT
NULL
COMMENT
'创建时间'
,
`expire_time`
datetime
(
0
)
NULL
DEFAULT
NULL
COMMENT
'团购过期时间'
,
`deleted`
tinyint
(
1
)
NULL
DEFAULT
NULL
COMMENT
'逻辑删除'
,
`version`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'乐观锁字段'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
3
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
SET
FOREIGN_KEY_CHECKS
=
1
;
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponRulesService.java
View file @
fd710d15
package
org.linlinjava.litemall.db.service
;
import
com.github.pagehelper.PageHelper
;
import
org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper
;
import
org.linlinjava.litemall.db.domain.LitemallGrouponRules
;
import
org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample
;
...
...
@@ -32,4 +33,12 @@ public class LitemallGrouponRulesService {
example
.
or
().
andGoodsIdEqualTo
(
goodsId
).
andDeletedEqualTo
(
false
);
return
mapper
.
selectByExample
(
example
);
}
public
List
<
LitemallGrouponRules
>
queryByIndex
(
int
offset
,
int
limit
)
{
LitemallGrouponRulesExample
example
=
new
LitemallGrouponRulesExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"add_time desc"
);
PageHelper
.
startPage
(
offset
,
limit
);
return
mapper
.
selectByExample
(
example
);
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java
View file @
fd710d15
...
...
@@ -29,6 +29,8 @@ public class WxHomeController {
private
LitemallTopicService
topicService
;
@Autowired
private
LitemallCategoryService
categoryService
;
@Autowired
private
LitemallGrouponRulesService
grouponRulesService
;
/**
* app首页
...
...
@@ -72,6 +74,17 @@ public class WxHomeController {
List
<
LitemallTopic
>
topicList
=
topicService
.
queryList
(
0
,
SystemConfig
.
getTopicLimit
());
data
.
put
(
"topicList"
,
topicList
);
//优惠专区
List
<
LitemallGrouponRules
>
grouponRules
=
grouponRulesService
.
queryByIndex
(
0
,
4
);
List
<
LitemallGoods
>
grouponGoods
=
new
ArrayList
<>();
for
(
LitemallGrouponRules
rule
:
grouponRules
)
{
LitemallGoods
goods
=
goodsService
.
findById
(
rule
.
getGoodsId
());
if
(!
grouponGoods
.
contains
(
goods
))
{
grouponGoods
.
add
(
goods
);
}
}
data
.
put
(
"grouponList"
,
grouponGoods
);
List
<
Map
>
categoryList
=
new
ArrayList
<>();
List
<
LitemallCategory
>
catL1List
=
categoryService
.
queryL1WithoutRecommend
(
0
,
SystemConfig
.
getCatlogListLimit
());
for
(
LitemallCategory
catL1
:
catL1List
)
{
...
...
Write
Preview
Supports
Markdown
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