Commit c480e78e authored by Menethil's avatar Menethil
Browse files

添加团购

parent 58fc87d2
......@@ -5,7 +5,7 @@ spring:
encoding: UTF-8
server:
port: 8080
port: 8082
logging:
level:
......
package org.linlinjava.litemall.core.qcode;
import cn.binarywang.wx.miniapp.api.WxMaService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.linlinjava.litemall.core.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public abstract class QCodeBase {
@Autowired
protected WxMaService wxMaService;
@Autowired
protected StorageService storageService;
protected abstract String getKeyName(String id);
/**
* 获取图片地址
*
* @param id
* @return
*/
public String getShareImageUrl(String id) {
return storageService.generateUrl(getKeyName(id));
}
protected BufferedImage getQCode(String scene, String page) {
//创建该商品的二维码
File file = null;
try {
file = wxMaService.getQrcodeService().createWxaCodeUnlimit(scene, page);
FileInputStream inputStream = new FileInputStream(file);
BufferedImage qrCodeImage = ImageIO.read(inputStream);
return qrCodeImage;
} catch (WxErrorException | IOException e) {
e.printStackTrace();
}
return null;
}
protected void saveImage(String id, byte[] imageData) {
MultipartFile multipartFile = new MockMultipartFile(getKeyName(id), getKeyName(id), "image/jpeg", imageData);
//存储分享图
storageService.store(multipartFile, getKeyName(id));
}
/**
* 居中写文字
*
* @param baseImage
* @param textToWrite
* @param font
* @param color
* @param y
*/
protected void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, Font font, Color color, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(color);
g2D.setFont(font);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// 计算文字长度,计算居中的x点坐标
FontMetrics fm = g2D.getFontMetrics(font);
int textWidth = fm.stringWidth(textToWrite);
int widthX = (baseImage.getWidth() - textWidth) / 2;
// 表示这段文字在图片上的位置(x,y) .第一个是你设置的内容。
g2D.drawString(textToWrite, widthX, y);
// 释放对象
g2D.dispose();
}
/**
* 写上文字
*
* @param baseImage
* @param textToWrite
* @param font
* @param color
* @param x
* @param y
*/
protected void drawTextInImg(BufferedImage baseImage, String textToWrite, Font font, Color color, int x, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(color);
g2D.setFont(font);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.drawString(textToWrite, x, y);
g2D.dispose();
}
/**
* 画中画
*
* @param baseImage
* @param imageToWrite
* @param x
* @param y
* @param width
* @param height
*/
protected void drawImgInImg(BufferedImage baseImage, BufferedImage imageToWrite, int x, int y, int width, int height) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.drawImage(imageToWrite, x, y, width, height, null);
g2D.dispose();
}
}
package org.linlinjava.litemall.core.qcode;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.springframework.core.io.ClassPathResource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
public class QCodeGoodShare extends QCodeBase {
@Override
protected String getKeyName(String id) {
return "GOOD_QCODE_" + id + ".jpg";
}
/**
* 创建商品分享图
*
* @param goodId
* @param goodPicUrl
* @param goodName
*/
public void createGoodShareImage(String goodId, String goodPicUrl, String goodName) {
if (!SystemConfig.isAutoCreateShareImage())
return;
BufferedImage qrCodeImage = getQCode("goods," + goodId, "pages/index/index");
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = new byte[0];
try {
imageData = drawPicture(qrCodeImage, goodPicUrl, goodName, SystemConfig.getMallName());
} catch (IOException e) {
e.printStackTrace();
}
saveImage(goodId, imageData);
}
/**
* 将商品图片,商品名字画到模版图中
*
* @param qrCodeImage 二维码图片
* @param goodPicUrl 商品图片地址
* @param goodName 商品名称
* @return
* @throws IOException
*/
private byte[] drawPicture(BufferedImage qrCodeImage, String goodPicUrl, String goodName, String shopName) throws IOException {
//底图
ClassPathResource redResource = new ClassPathResource("back.jpg");
BufferedImage red = ImageIO.read(redResource.getInputStream());
//商品图片
URL goodPic = new URL(goodPicUrl);
BufferedImage goodImage = ImageIO.read(goodPic);
// --- 画图 ---
//底层空白 bufferedImage
BufferedImage baseImage = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_4BYTE_ABGR_PRE);
//画上图片
drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight());
//画上商品图片
drawImgInImg(baseImage, goodImage, 56, 135, 720, 720);
//画上小程序二维码
drawImgInImg(baseImage, qrCodeImage, 442, 1006, 340, 340);
Font font = new Font("Microsoft YaHei", Font.PLAIN, 42);
Color color = new Color(167, 136, 69);
//写上商品名称
drawTextInImg(baseImage, goodName, font, color, 112, 955);
//写上商城名称
drawTextInImgCenter(baseImage, shopName, font, color, 98);
//转jpg
BufferedImage result = new BufferedImage(baseImage.getWidth(), baseImage
.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
result.getGraphics().drawImage(baseImage, 0, 0, null);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ImageIO.write(result, "jpg", bs);
//最终byte数组
return bs.toByteArray();
}
}
......@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.linlinjava.litemall.core.storage.StorageService;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile;
......@@ -24,6 +25,29 @@ public class QCodeService {
@Autowired
private StorageService storageService;
public void createGrouponShareImage(String goodName, String goodPicUrl, LitemallGroupon groupon) {
try {
//创建该商品的二维码
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("groupon," + groupon.getId(), "pages/index/index");
FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName, SystemConfig.getMallName());
MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(), "image/jpeg", imageData);
//存储分享图
storageService.store(multipartFile, getKeyName(groupon.getId().toString()));
} catch (WxErrorException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (FontFormatException e) {
e.printStackTrace();
}
}
/**
* 创建商品分享图
*
......@@ -37,7 +61,7 @@ public class QCodeService {
try {
//创建该商品的二维码
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit(goodId, "pages/index/index");
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("goods," + goodId, "pages/index/index");
FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName, SystemConfig.getMallName());
......@@ -103,7 +127,7 @@ public class QCodeService {
drawTextInImg(baseImage, goodName, 112, 955);
//写上商城名称
drawTextInImgCenter(baseImage, shopName, 112, 98);
drawTextInImgCenter(baseImage, shopName, 98);
//转jpg
......@@ -117,7 +141,7 @@ public class QCodeService {
return bs.toByteArray();
}
private void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, int x, int y) {
private void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(new Color(167, 136, 69));
......@@ -133,12 +157,12 @@ public class QCodeService {
int widthX = (baseImage.getWidth() - textWidth) / 2;
// 表示这段文字在图片上的位置(x,y) .第一个是你设置的内容。
g2D.drawString(textToWrite, widthX, 100);
g2D.drawString(textToWrite, widthX, y);
// 释放对象
g2D.dispose();
}
private void drawTextInImg(BufferedImage baseImage, String textToWrite, int x, int y) throws IOException, FontFormatException {
private void drawTextInImg(BufferedImage baseImage, String textToWrite, int x, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(new Color(167, 136, 69));
......
......@@ -45,9 +45,9 @@
<!--数据库连接信息-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/litemall?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
userId="litemall"
password="litemall123456"/>
connectionURL="jdbc:mysql://127.0.0.1:3306/litemall2?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
userId="root"
password="Menethil.2822"/>
<javaModelGenerator targetPackage="org.linlinjava.litemall.db.domain" targetProject="src/main/java"/>
......@@ -172,5 +172,15 @@
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="expire_time"/>
</table>
<table tableName="litemall_groupon_rules">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
</table>
<table tableName="litemall_groupon">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
<columnOverride javaType="java.time.LocalDateTime" column="expire_time"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.linlinjava.litemall.db.domain.LitemallGrouponExample;
public interface LitemallGrouponMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
long countByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int deleteByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int insert(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int insertSelective(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectOneByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectOneByExampleSelective(@Param("example") LitemallGrouponExample example, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallGroupon> selectByExampleSelective(@Param("example") LitemallGrouponExample example, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
List<LitemallGroupon> selectByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
LitemallGroupon selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallGroupon record, @Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallGroupon record, @Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
public interface LitemallGrouponRulesMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
long countByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int deleteByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int insert(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int insertSelective(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectOneByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectOneByExampleSelective(@Param("example") LitemallGrouponRulesExample example, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallGrouponRules> selectByExampleSelective(@Param("example") LitemallGrouponRulesExample example, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
List<LitemallGrouponRules> selectByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
LitemallGrouponRules selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallGrouponRules record, @Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallGrouponRules record, @Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
package org.linlinjava.litemall.db.domain;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
public class LitemallGrouponRules {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean NOT_DELETED = false;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean IS_DELETED = true;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
private Integer goodsId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
private String goodsName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
private String picUrl;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.discount
*
* @mbg.generated
*/
private BigDecimal discount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
private Integer discountMember;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.add_time
*
* @mbg.generated
*/
private LocalDateTime addTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.deleted
*
* @mbg.generated
*/
private Boolean deleted;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.version
*
* @mbg.generated
*/
private Integer version;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.id
*
* @return the value of litemall_groupon_rules.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.id
*
* @param id the value for litemall_groupon_rules.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.goods_id
*
* @return the value of litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
public Integer getGoodsId() {
return goodsId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.goods_id
*
* @param goodsId the value for litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.goods_name
*
* @return the value of litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
public String getGoodsName() {
return goodsName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.goods_name
*
* @param goodsName the value for litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.pic_url
*
* @return the value of litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
public String getPicUrl() {
return picUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.pic_url
*
* @param picUrl the value for litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.discount
*
* @return the value of litemall_groupon_rules.discount
*
* @mbg.generated
*/
public BigDecimal getDiscount() {
return discount;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.discount
*
* @param discount the value for litemall_groupon_rules.discount
*
* @mbg.generated
*/
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.discount_member
*
* @return the value of litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
public Integer getDiscountMember() {
return discountMember;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.discount_member
*
* @param discountMember the value for litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
public void setDiscountMember(Integer discountMember) {
this.discountMember = discountMember;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.add_time
*
* @return the value of litemall_groupon_rules.add_time
*
* @mbg.generated
*/
public LocalDateTime getAddTime() {
return addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.add_time
*
* @param addTime the value for litemall_groupon_rules.add_time
*
* @mbg.generated
*/
public void setAddTime(LocalDateTime addTime) {
this.addTime = addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.deleted
*
* @return the value of litemall_groupon_rules.deleted
*
* @mbg.generated
*/
public Boolean getDeleted() {
return deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.deleted
*
* @param deleted the value for litemall_groupon_rules.deleted
*
* @mbg.generated
*/
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.version
*
* @return the value of litemall_groupon_rules.version
*
* @mbg.generated
*/
public Integer getVersion() {
return version;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.version
*
* @param version the value for litemall_groupon_rules.version
*
* @mbg.generated
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", goodsId=").append(goodsId);
sb.append(", goodsName=").append(goodsName);
sb.append(", picUrl=").append(picUrl);
sb.append(", discount=").append(discount);
sb.append(", discountMember=").append(discountMember);
sb.append(", addTime=").append(addTime);
sb.append(", deleted=").append(deleted);
sb.append(", version=").append(version);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
LitemallGrouponRules other = (LitemallGrouponRules) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
&& (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
&& (this.getPicUrl() == null ? other.getPicUrl() == null : this.getPicUrl().equals(other.getPicUrl()))
&& (this.getDiscount() == null ? other.getDiscount() == null : this.getDiscount().equals(other.getDiscount()))
&& (this.getDiscountMember() == null ? other.getDiscountMember() == null : this.getDiscountMember().equals(other.getDiscountMember()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
result = prime * result + ((getPicUrl() == null) ? 0 : getPicUrl().hashCode());
result = prime * result + ((getDiscount() == null) ? 0 : getDiscount().hashCode());
result = prime * result + ((getDiscountMember() == null) ? 0 : getDiscountMember().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
return result;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public void andLogicalDeleted(boolean deleted) {
setDeleted(deleted ? IS_DELETED : NOT_DELETED);
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER"),
goodsId("goods_id", "goodsId", "INTEGER"),
goodsName("goods_name", "goodsName", "VARCHAR"),
picUrl("pic_url", "picUrl", "VARCHAR"),
discount("discount", "discount", "DECIMAL"),
discountMember("discount_member", "discountMember", "INTEGER"),
addTime("add_time", "addTime", "TIMESTAMP"),
deleted("deleted", "deleted", "BIT"),
version("version", "version", "INTEGER");
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.column + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.column + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
}
}
\ No newline at end of file
......@@ -123,6 +123,15 @@ public class LitemallOrder {
*/
private BigDecimal integralPrice;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_order.groupon_price
*
* @mbg.generated
*/
private BigDecimal grouponPrice;
/**
*
* This field was generated by MyBatis Generator.
......@@ -495,6 +504,30 @@ public class LitemallOrder {
this.integralPrice = integralPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.groupon_price
*
* @return the value of litemall_order.groupon_price
*
* @mbg.generated
*/
public BigDecimal getGrouponPrice() {
return grouponPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_order.groupon_price
*
* @param grouponPrice the value for litemall_order.groupon_price
*
* @mbg.generated
*/
public void setGrouponPrice(BigDecimal grouponPrice) {
this.grouponPrice = grouponPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.order_price
......@@ -806,6 +839,7 @@ public class LitemallOrder {
sb.append(", freightPrice=").append(freightPrice);
sb.append(", couponPrice=").append(couponPrice);
sb.append(", integralPrice=").append(integralPrice);
sb.append(", grouponPrice=").append(grouponPrice);
sb.append(", orderPrice=").append(orderPrice);
sb.append(", actualPrice=").append(actualPrice);
sb.append(", payId=").append(payId);
......@@ -851,6 +885,7 @@ public class LitemallOrder {
&& (this.getFreightPrice() == null ? other.getFreightPrice() == null : this.getFreightPrice().equals(other.getFreightPrice()))
&& (this.getCouponPrice() == null ? other.getCouponPrice() == null : this.getCouponPrice().equals(other.getCouponPrice()))
&& (this.getIntegralPrice() == null ? other.getIntegralPrice() == null : this.getIntegralPrice().equals(other.getIntegralPrice()))
&& (this.getGrouponPrice() == null ? other.getGrouponPrice() == null : this.getGrouponPrice().equals(other.getGrouponPrice()))
&& (this.getOrderPrice() == null ? other.getOrderPrice() == null : this.getOrderPrice().equals(other.getOrderPrice()))
&& (this.getActualPrice() == null ? other.getActualPrice() == null : this.getActualPrice().equals(other.getActualPrice()))
&& (this.getPayId() == null ? other.getPayId() == null : this.getPayId().equals(other.getPayId()))
......@@ -886,6 +921,7 @@ public class LitemallOrder {
result = prime * result + ((getFreightPrice() == null) ? 0 : getFreightPrice().hashCode());
result = prime * result + ((getCouponPrice() == null) ? 0 : getCouponPrice().hashCode());
result = prime * result + ((getIntegralPrice() == null) ? 0 : getIntegralPrice().hashCode());
result = prime * result + ((getGrouponPrice() == null) ? 0 : getGrouponPrice().hashCode());
result = prime * result + ((getOrderPrice() == null) ? 0 : getOrderPrice().hashCode());
result = prime * result + ((getActualPrice() == null) ? 0 : getActualPrice().hashCode());
result = prime * result + ((getPayId() == null) ? 0 : getPayId().hashCode());
......@@ -931,6 +967,7 @@ public class LitemallOrder {
freightPrice("freight_price", "freightPrice", "DECIMAL"),
couponPrice("coupon_price", "couponPrice", "DECIMAL"),
integralPrice("integral_price", "integralPrice", "DECIMAL"),
grouponPrice("groupon_price", "grouponPrice", "DECIMAL"),
orderPrice("order_price", "orderPrice", "DECIMAL"),
actualPrice("actual_price", "actualPrice", "DECIMAL"),
payId("pay_id", "payId", "VARCHAR"),
......
......@@ -927,6 +927,66 @@ public class LitemallOrderExample {
return (Criteria) this;
}
public Criteria andGrouponPriceIsNull() {
addCriterion("groupon_price is null");
return (Criteria) this;
}
public Criteria andGrouponPriceIsNotNull() {
addCriterion("groupon_price is not null");
return (Criteria) this;
}
public Criteria andGrouponPriceEqualTo(BigDecimal value) {
addCriterion("groupon_price =", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotEqualTo(BigDecimal value) {
addCriterion("groupon_price <>", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceGreaterThan(BigDecimal value) {
addCriterion("groupon_price >", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("groupon_price >=", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceLessThan(BigDecimal value) {
addCriterion("groupon_price <", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("groupon_price <=", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceIn(List<BigDecimal> values) {
addCriterion("groupon_price in", values, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotIn(List<BigDecimal> values) {
addCriterion("groupon_price not in", values, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("groupon_price between", value1, value2, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("groupon_price not between", value1, value2, "grouponPrice");
return (Criteria) this;
}
public Criteria andOrderPriceIsNull() {
addCriterion("order_price is null");
return (Criteria) this;
......
package org.linlinjava.litemall.db.service;
import org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class LitemallGrouponRulesService {
@Resource
LitemallGrouponRulesMapper mapper;
public int createRules(LitemallGrouponRules rules) {
return mapper.insertSelective(rules);
}
public LitemallGrouponRules queryById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
/**
* 查询某个商品关联的团购规则
*
* @param goodsId
* @return
*/
public List<LitemallGrouponRules> queryByGoodsId(Integer goodsId) {
LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return mapper.selectByExample(example);
}
}
package org.linlinjava.litemall.db.service;
import org.linlinjava.litemall.db.dao.LitemallGrouponMapper;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.linlinjava.litemall.db.domain.LitemallGrouponExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class LitemallGrouponService {
@Resource
LitemallGrouponMapper mapper;
/**
* 查询用户所有参与的团购
*
* @param userId
* @return
*/
public List<LitemallGroupon> queryByUserId(Integer userId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andUserIdEqualTo(userId).andDeletedEqualTo(false);
return mapper.selectByExample(example);
}
public LitemallGroupon queryByOrderId(Integer orderId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
return mapper.selectOneByExample(example);
}
/**
* 根据ID查询记录
*
* @param id
* @return
*/
public LitemallGroupon queryById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
/**
* 返回某个发起的团购参与人数
*
* @param grouponId
* @return
*/
public int countGroupon(Integer grouponId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andGrouponIdEqualTo(grouponId).andDeletedEqualTo(false);
return (int) mapper.countByExample(example);
}
/**
* 返回某个团购活动参与人数
*
* @param rulesId
* @return
*/
public int countRules(Integer rulesId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andRulesIdEqualTo(rulesId).andDeletedEqualTo(false);
return (int) mapper.countByExample(example);
}
public void update(LitemallGroupon groupon) {
mapper.updateByPrimaryKey(groupon);
}
/**
* 创建或参与一个团购
*
* @param groupon
* @return
*/
public int createGroupon(LitemallGroupon groupon) {
return mapper.insertSelective(groupon);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.linlinjava.litemall.db.dao.LitemallGrouponMapper">
<resultMap id="BaseResultMap" type="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="groupon_id" jdbcType="INTEGER" property="grouponId" />
<result column="rules_id" jdbcType="INTEGER" property="rulesId" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="user_type" jdbcType="BIT" property="userType" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="share_url" jdbcType="VARCHAR" property="shareUrl" />
<result column="payed" jdbcType="BIT" property="payed" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="version" jdbcType="INTEGER" property="version" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, order_id, groupon_id, rules_id, user_id, user_type, add_time, expire_time, share_url,
payed, deleted, version
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, user_type, add_time, expire_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKeyWithLogicalDelete" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
and deleted =
<choose>
<when test="andLogicalDeleted">
'1'
</when>
<otherwise>
'0'
</otherwise>
</choose>
</select>
<select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, user_type, add_time, expire_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon (order_id, groupon_id, rules_id,
user_id, user_type, add_time,
expire_time, share_url, payed,
deleted, version)
values (#{orderId,jdbcType=INTEGER}, #{grouponId,jdbcType=INTEGER}, #{rulesId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, #{userType,jdbcType=BIT}, #{addTime,jdbcType=TIMESTAMP},
#{expireTime,jdbcType=TIMESTAMP}, #{shareUrl,jdbcType=VARCHAR}, #{payed,jdbcType=BIT},
#{deleted,jdbcType=BIT}, #{version,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">
order_id,
</if>
<if test="grouponId != null">
groupon_id,
</if>
<if test="rulesId != null">
rules_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="userType != null">
user_type,
</if>
<if test="addTime != null">
add_time,
</if>
<if test="expireTime != null">
expire_time,
</if>
<if test="shareUrl != null">
share_url,
</if>
<if test="payed != null">
payed,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="version != null">
version,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">
#{orderId,jdbcType=INTEGER},
</if>
<if test="grouponId != null">
#{grouponId,jdbcType=INTEGER},
</if>
<if test="rulesId != null">
#{rulesId,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="userType != null">
#{userType,jdbcType=BIT},
</if>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
#{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="shareUrl != null">
#{shareUrl,jdbcType=VARCHAR},
</if>
<if test="payed != null">
#{payed,jdbcType=BIT},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
<if test="version != null">
#{version,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.orderId != null">
order_id = #{record.orderId,jdbcType=INTEGER},
</if>
<if test="record.grouponId != null">
groupon_id = #{record.grouponId,jdbcType=INTEGER},
</if>
<if test="record.rulesId != null">
rules_id = #{record.rulesId,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.userType != null">
user_type = #{record.userType,jdbcType=BIT},
</if>
<if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
<if test="record.expireTime != null">
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
</if>
<if test="record.shareUrl != null">
share_url = #{record.shareUrl,jdbcType=VARCHAR},
</if>
<if test="record.payed != null">
payed = #{record.payed,jdbcType=BIT},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</if>
<if test="record.version != null">
version = #{record.version,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
set id = #{record.id,jdbcType=INTEGER},
order_id = #{record.orderId,jdbcType=INTEGER},
groupon_id = #{record.grouponId,jdbcType=INTEGER},
rules_id = #{record.rulesId,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=INTEGER},
user_type = #{record.userType,jdbcType=BIT},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
share_url = #{record.shareUrl,jdbcType=VARCHAR},
payed = #{record.payed,jdbcType=BIT},
deleted = #{record.deleted,jdbcType=BIT},
version = #{record.version,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
<set>
<if test="orderId != null">
order_id = #{orderId,jdbcType=INTEGER},
</if>
<if test="grouponId != null">
groupon_id = #{grouponId,jdbcType=INTEGER},
</if>
<if test="rulesId != null">
rules_id = #{rulesId,jdbcType=INTEGER},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="userType != null">
user_type = #{userType,jdbcType=BIT},
</if>
<if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="shareUrl != null">
share_url = #{shareUrl,jdbcType=VARCHAR},
</if>
<if test="payed != null">
payed = #{payed,jdbcType=BIT},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
<if test="version != null">
version = #{version,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
set order_id = #{orderId,jdbcType=INTEGER},
groupon_id = #{grouponId,jdbcType=INTEGER},
rules_id = #{rulesId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
user_type = #{userType,jdbcType=BIT},
add_time = #{addTime,jdbcType=TIMESTAMP},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
share_url = #{shareUrl,jdbcType=VARCHAR},
payed = #{payed,jdbcType=BIT},
deleted = #{deleted,jdbcType=BIT},
version = #{version,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectOneByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
limit 1
</select>
<select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, user_type, add_time, expire_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
limit 1
</select>
<update id="logicalDeleteByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon set deleted = 1
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="logicalDeleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon set deleted = 1
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -17,6 +17,7 @@
<result column="freight_price" jdbcType="DECIMAL" property="freightPrice" />
<result column="coupon_price" jdbcType="DECIMAL" property="couponPrice" />
<result column="integral_price" jdbcType="DECIMAL" property="integralPrice" />
<result column="groupon_price" jdbcType="DECIMAL" property="grouponPrice" />
<result column="order_price" jdbcType="DECIMAL" property="orderPrice" />
<result column="actual_price" jdbcType="DECIMAL" property="actualPrice" />
<result column="pay_id" jdbcType="VARCHAR" property="payId" />
......@@ -102,8 +103,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id, pay_time,
ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallOrderExample" resultMap="BaseResultMap">
<!--
......@@ -141,8 +142,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order
......@@ -202,8 +204,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order
......@@ -238,19 +241,19 @@
insert into litemall_order (user_id, order_sn, order_status,
consignee, mobile, address,
goods_price, freight_price, coupon_price,
integral_price, order_price, actual_price,
pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time,
end_time, add_time, deleted,
version)
integral_price, groupon_price, order_price,
actual_price, pay_id, pay_time,
ship_sn, ship_channel, ship_time,
confirm_time, end_time, add_time,
deleted, version)
values (#{userId,jdbcType=INTEGER}, #{orderSn,jdbcType=VARCHAR}, #{orderStatus,jdbcType=SMALLINT},
#{consignee,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{goodsPrice,jdbcType=DECIMAL}, #{freightPrice,jdbcType=DECIMAL}, #{couponPrice,jdbcType=DECIMAL},
#{integralPrice,jdbcType=DECIMAL}, #{orderPrice,jdbcType=DECIMAL}, #{actualPrice,jdbcType=DECIMAL},
#{payId,jdbcType=VARCHAR}, #{payTime,jdbcType=TIMESTAMP}, #{shipSn,jdbcType=VARCHAR},
#{shipChannel,jdbcType=VARCHAR}, #{shipTime,jdbcType=TIMESTAMP}, #{confirmTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{version,jdbcType=INTEGER})
#{integralPrice,jdbcType=DECIMAL}, #{grouponPrice,jdbcType=DECIMAL}, #{orderPrice,jdbcType=DECIMAL},
#{actualPrice,jdbcType=DECIMAL}, #{payId,jdbcType=VARCHAR}, #{payTime,jdbcType=TIMESTAMP},
#{shipSn,jdbcType=VARCHAR}, #{shipChannel,jdbcType=VARCHAR}, #{shipTime,jdbcType=TIMESTAMP},
#{confirmTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT}, #{version,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallOrder">
<!--
......@@ -292,6 +295,9 @@
<if test="integralPrice != null">
integral_price,
</if>
<if test="grouponPrice != null">
groupon_price,
</if>
<if test="orderPrice != null">
order_price,
</if>
......@@ -360,6 +366,9 @@
<if test="integralPrice != null">
#{integralPrice,jdbcType=DECIMAL},
</if>
<if test="grouponPrice != null">
#{grouponPrice,jdbcType=DECIMAL},
</if>
<if test="orderPrice != null">
#{orderPrice,jdbcType=DECIMAL},
</if>
......@@ -448,6 +457,9 @@
<if test="record.integralPrice != null">
integral_price = #{record.integralPrice,jdbcType=DECIMAL},
</if>
<if test="record.grouponPrice != null">
groupon_price = #{record.grouponPrice,jdbcType=DECIMAL},
</if>
<if test="record.orderPrice != null">
order_price = #{record.orderPrice,jdbcType=DECIMAL},
</if>
......@@ -506,6 +518,7 @@
freight_price = #{record.freightPrice,jdbcType=DECIMAL},
coupon_price = #{record.couponPrice,jdbcType=DECIMAL},
integral_price = #{record.integralPrice,jdbcType=DECIMAL},
groupon_price = #{record.grouponPrice,jdbcType=DECIMAL},
order_price = #{record.orderPrice,jdbcType=DECIMAL},
actual_price = #{record.actualPrice,jdbcType=DECIMAL},
pay_id = #{record.payId,jdbcType=VARCHAR},
......@@ -559,6 +572,9 @@
<if test="integralPrice != null">
integral_price = #{integralPrice,jdbcType=DECIMAL},
</if>
<if test="grouponPrice != null">
groupon_price = #{grouponPrice,jdbcType=DECIMAL},
</if>
<if test="orderPrice != null">
order_price = #{orderPrice,jdbcType=DECIMAL},
</if>
......@@ -614,6 +630,7 @@
freight_price = #{freightPrice,jdbcType=DECIMAL},
coupon_price = #{couponPrice,jdbcType=DECIMAL},
integral_price = #{integralPrice,jdbcType=DECIMAL},
groupon_price = #{grouponPrice,jdbcType=DECIMAL},
order_price = #{orderPrice,jdbcType=DECIMAL},
actual_price = #{actualPrice,jdbcType=DECIMAL},
pay_id = #{payId,jdbcType=VARCHAR},
......@@ -660,8 +677,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order
......
......@@ -54,6 +54,8 @@ public class WxGoodsController {
private LitemallSearchHistoryService searchHistoryService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallGrouponRulesService rulesService;
/**
......@@ -123,6 +125,9 @@ public class WxGoodsController {
commentList.put("count", commentCount);
commentList.put("data", commentsVo);
//团购信息
List<LitemallGrouponRules> rules = rulesService.queryByGoodsId(id);
// 用户收藏
int userHasCollect = 0;
if (userId != null) {
......@@ -147,6 +152,7 @@ public class WxGoodsController {
data.put("productList", productList);
data.put("attribute", goodsAttributeList);
data.put("brand", brand);
data.put("groupon", rules);
//商品分享图片地址
data.put("shareImage", info.getShareUrl());
......@@ -231,7 +237,7 @@ public class WxGoodsController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
@Order @RequestParam(defaultValue = "desc") String order) {
//添加到搜索历史
if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {
......
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