Commit fd710d15 authored by Menethil's avatar Menethil
Browse files

添加团购

parent 6f8bedd4
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
ENV_CONFIG: '"dep"', ENV_CONFIG: '"dep"',
BASE_API: '"http://localhost:8080/admin"' BASE_API: '"https://www.menethil.com.cn/admin"'
} }
...@@ -30,7 +30,7 @@ public class QCodeService { ...@@ -30,7 +30,7 @@ public class QCodeService {
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("groupon," + groupon.getId(), "pages/index/index"); File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("groupon," + groupon.getId(), "pages/index/index");
FileInputStream inputStream = new FileInputStream(file); FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中 //将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName, SystemConfig.getMallName()); byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData); ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData);
//存储分享图 //存储分享图
String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(groupon.getId().toString())); String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(groupon.getId().toString()));
...@@ -42,8 +42,6 @@ public class QCodeService { ...@@ -42,8 +42,6 @@ public class QCodeService {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (FontFormatException e) {
e.printStackTrace();
} }
return ""; return "";
...@@ -66,7 +64,7 @@ public class QCodeService { ...@@ -66,7 +64,7 @@ public class QCodeService {
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("goods," + goodId, "pages/index/index"); File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("goods," + goodId, "pages/index/index");
FileInputStream inputStream = new FileInputStream(file); FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中 //将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName, SystemConfig.getMallName()); byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData); ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData);
//存储分享图 //存储分享图
String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(goodId)); String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(goodId));
...@@ -78,8 +76,6 @@ public class QCodeService { ...@@ -78,8 +76,6 @@ public class QCodeService {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (FontFormatException e) {
e.printStackTrace();
} }
return ""; return "";
...@@ -98,9 +94,9 @@ public class QCodeService { ...@@ -98,9 +94,9 @@ public class QCodeService {
* @return * @return
* @throws IOException * @throws IOException
*/ */
private byte[] drawPicture(InputStream qrCodeImg, String goodPicUrl, String goodName, String shopName) throws IOException, FontFormatException { private byte[] drawPicture(InputStream qrCodeImg, String goodPicUrl, String goodName) throws IOException {
//底图 //底图
ClassPathResource redResource = new ClassPathResource("back.jpg"); ClassPathResource redResource = new ClassPathResource("back.png");
BufferedImage red = ImageIO.read(redResource.getInputStream()); BufferedImage red = ImageIO.read(redResource.getInputStream());
...@@ -120,16 +116,16 @@ public class QCodeService { ...@@ -120,16 +116,16 @@ public class QCodeService {
drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight()); drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight());
//画上商品图片 //画上商品图片
drawImgInImg(baseImage, goodImage, 56, 135, 720, 720); drawImgInImg(baseImage, goodImage, 71, 69, 660, 660);
//画上小程序二维码 //画上小程序二维码
drawImgInImg(baseImage, qrCodeImage, 442, 1006, 340, 340); drawImgInImg(baseImage, qrCodeImage, 448, 767, 300, 300);
//写上商品名称 //写上商品名称
drawTextInImg(baseImage, goodName, 112, 955); drawTextInImg(baseImage, goodName, 65, 867);
//写上商城名称 //写上商城名称
drawTextInImgCenter(baseImage, shopName, 98); // drawTextInImgCenter(baseImage, shopName, 98);
//转jpg //转jpg
...@@ -149,7 +145,7 @@ public class QCodeService { ...@@ -149,7 +145,7 @@ public class QCodeService {
String fontName = "Microsoft YaHei"; String fontName = "Microsoft YaHei";
Font f = new Font(fontName, Font.PLAIN, 42); Font f = new Font(fontName, Font.PLAIN, 28);
g2D.setFont(f); g2D.setFont(f);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
...@@ -169,7 +165,7 @@ public class QCodeService { ...@@ -169,7 +165,7 @@ public class QCodeService {
g2D.setColor(new Color(167, 136, 69)); g2D.setColor(new Color(167, 136, 69));
//TODO 注意,这里的字体必须安装在服务器上 //TODO 注意,这里的字体必须安装在服务器上
g2D.setFont(new Font("Microsoft YaHei", Font.PLAIN, 42)); g2D.setFont(new Font("Microsoft YaHei", Font.PLAIN, 28));
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.drawString(textToWrite, x, y); g2D.drawString(textToWrite, x, y);
......
...@@ -22,7 +22,11 @@ class SystemInistService { ...@@ -22,7 +22,11 @@ class SystemInistService {
private void inist() { private void inist() {
systemInistService = this; systemInistService = this;
SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo()); try {
SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo());
} catch (Exception e) {
e.printStackTrace();
}
} }
private Map<String, String> getSystemInfo() { private Map<String, String> getSystemInfo() {
......
/*
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;
/*
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;
package org.linlinjava.litemall.db.service; package org.linlinjava.litemall.db.service;
import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper; import org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules; import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample; import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
...@@ -32,4 +33,12 @@ public class LitemallGrouponRulesService { ...@@ -32,4 +33,12 @@ public class LitemallGrouponRulesService {
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false); example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return mapper.selectByExample(example); 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);
}
} }
...@@ -29,6 +29,8 @@ public class WxHomeController { ...@@ -29,6 +29,8 @@ public class WxHomeController {
private LitemallTopicService topicService; private LitemallTopicService topicService;
@Autowired @Autowired
private LitemallCategoryService categoryService; private LitemallCategoryService categoryService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
/** /**
* app首页 * app首页
...@@ -72,6 +74,17 @@ public class WxHomeController { ...@@ -72,6 +74,17 @@ public class WxHomeController {
List<LitemallTopic> topicList = topicService.queryList(0, SystemConfig.getTopicLimit()); List<LitemallTopic> topicList = topicService.queryList(0, SystemConfig.getTopicLimit());
data.put("topicList", topicList); 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<Map> categoryList = new ArrayList<>();
List<LitemallCategory> catL1List = categoryService.queryL1WithoutRecommend(0, SystemConfig.getCatlogListLimit()); List<LitemallCategory> catL1List = categoryService.queryL1WithoutRecommend(0, SystemConfig.getCatlogListLimit());
for (LitemallCategory catL1 : catL1List) { for (LitemallCategory catL1 : catL1List) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment