Browse Source

添加团购

Menethil 7 years ago
parent
commit
fd710d1524

+ 1 - 1
litemall-admin/config/dep.env.js

@@ -1,5 +1,5 @@
 module.exports = {
 	NODE_ENV: '"production"',
   ENV_CONFIG: '"dep"',
-  BASE_API: '"http://localhost:8080/admin"'
+  BASE_API: '"https://www.menethil.com.cn/admin"'
 }

+ 10 - 14
litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeService.java

@@ -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, 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());
 
 
@@ -120,16 +116,16 @@ public class QCodeService {
         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
@@ -149,7 +145,7 @@ public class QCodeService {
 
         String fontName = "Microsoft YaHei";
 
-        Font f = new Font(fontName, Font.PLAIN, 42);
+        Font f = new Font(fontName, Font.PLAIN, 28);
         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, 42));
+        g2D.setFont(new Font("Microsoft YaHei", Font.PLAIN, 28));
         g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
         g2D.drawString(textToWrite, x, y);

+ 5 - 1
litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java

@@ -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() {

BIN
litemall-core/src/main/resources/back.jpg


BIN
litemall-core/src/main/resources/back.png


BIN
litemall-core/src/main/resources/back_groupon.png


+ 39 - 0
litemall-db/sql/litemall_groupon.sql

@@ -0,0 +1,39 @@
+/*
+ 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;

+ 38 - 0
litemall-db/sql/litemall_groupon_rules.sql

@@ -0,0 +1,38 @@
+/*
+ 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;

+ 9 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponRulesService.java

@@ -1,5 +1,6 @@
 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);
+    }
 }

+ 13 - 0
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java

@@ -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) {