提交 4daf6959 authored 作者: 林海冰's avatar 林海冰

增加logo二维码工具,店铺信息相关注册接口

上级 f8a3c8ff
......@@ -752,6 +752,17 @@
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<!-- 二维码生成工具 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
......
package com.mall.controller.api;
import javax.annotation.Resource;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.mall.service.mengbeng.api.ValidateManager;
import com.mall.service.mengbeng.store.StoreManager;
import com.mall.util.DateHelper;
import com.mall.util.DateUtil;
import com.mall.util.PageData;
import com.mall.util.ResultOutDto;
import com.mall.util.SMSUtil;
import com.mall.util.UuidUtil;
/**
* ClassName:BannerApiController <br/>
* Function: TODO ADD FUNCTION. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2018年12月14日 上午10:09:38 <br/>
*
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see
*/
@RestController
@RequestMapping(value="/api/store",produces="application/json;charset=UTF-8")
@RequestMapping(value = "/api/store", produces = "application/json;charset=UTF-8")
public class StoreApiController {
@Resource(name="storeService")
@Resource(name = "storeService")
private StoreManager storeService;
@RequestMapping(value="/registerStore")
public ResultOutDto registerStore(String name,String telephone,String phone,String storeName ,Integer storeType,
String type, String address,String nickname,String wxNumber ,String qqNumber,String icomUrl,String payType ){
if(StringUtils.isEmpty(name)||StringUtils.isEmpty(telephone)||StringUtils.isEmpty(storeType)||StringUtils.isEmpty(storeName)||StringUtils.isEmpty(storeType)||StringUtils.isEmpty(type)||StringUtils.isEmpty(icomUrl)){
return ResultOutDto.err(null, "注册失败!参数缺失!");
@Resource(name = "validateService")
private ValidateManager validateService;
/**
* 注册接口
*
* @author LHB
* @since JDK 1.8
*/
@RequestMapping(value = "/registerStore")
public ResultOutDto registerStore(String name, String telephone, String phone, String storeName, Integer storeType,
String type, String address, String nickname, String wxNumber, String qqNumber, String icomUrl,
String payType) {
if (StringUtils.isEmpty(name) || StringUtils.isEmpty(telephone) || StringUtils.isEmpty(storeType)
|| StringUtils.isEmpty(storeName) || StringUtils.isEmpty(storeType) || StringUtils.isEmpty(type)
|| StringUtils.isEmpty(icomUrl)) {
return ResultOutDto.err(null, "注册失败!参数有误!");
}
try {
//检验店铺名称是否唯一
PageData storePd=storeService.findByStore(storeName);
if(storePd!=null){
return ResultOutDto.err(null, "店铺名已被注册!");
}
//检验店铺名称是否唯一
PageData _storePd=storeService.findByPhone(phone);
if(_storePd!=null){
return ResultOutDto.err(null, "手机号已被注册!");
}
PageData pd = new PageData();
pd.put("store_id", UuidUtil.get32UUID());
pd.put("real_name", name);
......@@ -46,16 +70,16 @@ public class StoreApiController {
pd.put("mobile", phone);
pd.put("store_name", storeName);
pd.put("one_classfy_id", storeType);
// pd.put("type", type);
// pd.put("type", type);
pd.put("store_address", address);
pd.put("nickname", nickname);
pd.put("wx_muner", wxNumber);
pd.put("qq_munber", qqNumber);
pd.put("store_logo", icomUrl);
pd.put("gender", 0);//性别
pd.put("create_time", DateUtil.getDay()); //创建时间
pd.put("end_valid_time", 0); //到期时间
//pd.put("payType", payType);
pd.put("gender", 0);// 性别
pd.put("create_time", DateUtil.getDay()); // 创建时间
pd.put("end_valid_time", 0); // 到期时间
// pd.put("payType", payType);
storeService.save(pd);
return ResultOutDto.ok();
} catch (Exception e) {
......@@ -63,14 +87,158 @@ public class StoreApiController {
return ResultOutDto.err("注册异常!");
}
}
// @RequestMapping(value = "/loginStore")
// @ResponseBody
//
// PageData byPhone = storeService.findByPhone(phone);
// if (byPhone==null){
// return ResultOutDto.err(null, "您未注册,请先注册!");
// }
// PageData pageData = validateService.findByPhone(phone,"registerStore");
// if (pageData != null) {
// String create_time = pageData.getString("create_time");
//// 短信验证码的时效性为1分钟
// long minuteDifference = DateUtil.minuteDifference(create_time);
// if (minuteDifference <= 1) {
// return ResultOutDto.err(null, "验证码尚未过期,请填入原来的验证码");
// }
//// 临界值,或者1.5分钟
// if(minuteDifference >1){
// validateService.deleteByPhone(phone);
// return ResultOutDto.err(null,"验证码已经过期,请重新获取");
// }
// }
//// 是快递员,且pageDate为null 则为他新建一个
// SMSUtil smsUtil = new SMSUtil();
// String authcode = smsUtil.yzCode(phone,"快递柜");
// PageData pd = new PageData();
// pd.put("id", this.get32UUID());
// pd.put("phone", phone);
// pd.put("create_time", DateUtil.getTime());
// pd.put("authcode", authcode);
// pd.put("code_from","loginMessageGet");
// validateService.save(pd);
// return ResultOutDto.ok("获取登录短信成功!");
// }
/**
* 登录接口
*/
@RequestMapping(value = "/loginStore")
@ResponseBody
public ResultOutDto loginStore(String phone, String code) throws Exception {
if (StringUtils.isEmpty(phone)) {
return ResultOutDto.err(null, "请输入手机不能为空!");
}
if (StringUtils.isEmpty(code)) {
return ResultOutDto.err(null, "验证码不能为空!");
}
PageData storePd = storeService.findByPhone(phone);
if (storePd == null) {
return ResultOutDto.err(null, "您未注册,请先注册!");
}
// 1.查看验证码是否过期 2.查看是否存在
PageData ssoCodeData = validateService.findByPhone(phone, "longStore");
if (ssoCodeData != null) {
String create_time = ssoCodeData.getString("create_time");
// 短信验证码的时效性为1分钟验证码尚未过期,请填入原来的验证码
long minuteDifference = DateUtil.minuteDifference(create_time);
if (minuteDifference > 1) {
validateService.delete(ssoCodeData);
return ResultOutDto.err(null, "验证码已经过期,请重新获取");
}
if (code.equals(ssoCodeData.getString("authcode"))) {
PageData data = new PageData();
data.put("phone", phone);
validateService.delete(ssoCodeData);
return ResultOutDto.ok(data);
}
return ResultOutDto.err(null, "验证失败,请确认所填验证码");
}
return ResultOutDto.err("请获取验证码之后再填写验证码");
}
/**
* 获取登录短信验证码
*/
@RequestMapping(value = "/getCode")
@ResponseBody
public ResultOutDto getCode(String phone) throws Exception {
if(StringUtils.isEmpty(phone)){
return ResultOutDto.err(null, "请输入手机不能为空!");
}
// 如果手机号码已发送短信验证,并且短信验证时间还未过期,就提示输入原来的短信验证
PageData pageData = validateService.findByPhone(phone, "longStore");
if (pageData != null) {
String create_time = (String) pageData.get("create_time");
long minuteDifference = DateUtil.minuteDifference(create_time);
if (minuteDifference < 1) {
return ResultOutDto.ok( "您登录该验证码尚未过期,请填入原来的验证码");
} else if (minuteDifference >= 1) {
validateService.deleteByPhone(phone);
}
}
// 1.手机尚未注册 2.数据库中没有该手机号码的元组 3.需要插入数据库 4.短信平台发送短信
SMSUtil smsUtil = new SMSUtil();
String authcode = smsUtil.yzCode(phone, "桐盟商城");
PageData pd = new PageData();
pd.put("id", UuidUtil.get32UUID());
pd.put("phone", phone);
pd.put("create_time", DateUtil.getTime());
pd.put("authcode", authcode);
pd.put("code_from", "longStore");
validateService.save(pd);
return ResultOutDto.ok("获取验证码成功,请在1分钟内填入并校验");
}
/**
* 获取注册短信验证码
*/
@RequestMapping(value = "/registerStoreCode")
@ResponseBody
public ResultOutDto registerMessageValidate(String phone) throws Exception {
if(StringUtils.isEmpty(phone)){
return ResultOutDto.err(null, "请输入手机不能为空!");
}
PageData pageData = validateService.findByPhone(phone,"registerStoreCode");
if (pageData != null) {
String create_time = (String) pageData.get("create_time");
// 拿出create_time与current_time进行比较,如果大于2,就请重新获取验证码
// 将两个时间相减,获取分钟数,如果不大于1分钟,则返回true
long minuteDifference = DateUtil.minuteDifference(create_time);
if (minuteDifference <= 1) {
// 如果没有过期,就进行验证,验证成功的话 返回成功
String authcode = (String) pageData.get("authcode");
validateService.delete(pageData);
return ResultOutDto.ok( "您登录该验证码尚未过期,请填入原来的验证码");
}else{
validateService.delete(pageData);
}
}
// 短信平台发送短信
SMSUtil smsUtil = new SMSUtil();
String authcode = smsUtil.yzCode(phone, "桐盟商城");
PageData pd = new PageData();
pd.put("id", UuidUtil.get32UUID());
pd.put("phone", phone);
pd.put("create_time", DateUtil.getTime());
pd.put("authcode", authcode);
pd.put("code_from", "registerStoreCode");
validateService.save(pd);
return ResultOutDto.ok("获取验证码成功,请在1分钟内填入并校验");
}
/**
* 访问店铺
*
* @author LHB
* @since JDK 1.8
*/
@RequestMapping(value="/viewedStore")
public ResultOutDto viewedStore(String view_store_id,String viewed_store_id){
if(StringUtils.isEmpty(view_store_id)||StringUtils.isEmpty(viewed_store_id)){
@RequestMapping(value = "/viewedStore")
public ResultOutDto viewedStore(String view_store_id, String viewed_store_id) {
if (StringUtils.isEmpty(view_store_id) || StringUtils.isEmpty(viewed_store_id)) {
return ResultOutDto.err(null, "参数缺失!");
}
try {
......@@ -84,10 +252,6 @@ public class StoreApiController {
return ResultOutDto.err("访问异常!");
}
}
}
package com.mall.service.mengbeng.api;
import java.util.List;
import com.mall.entity.Page;
import com.mall.util.PageData;
/**
* 说明: 快递员注册验证码存储表接口
* 创建时间:2018-10-09
* @version
*/
public interface ValidateManager{
/**新增
* @param pd
* @throws Exception
*/
public void save(PageData pd)throws Exception;
/**删除
* @param pd
* @throws Exception
*/
public void delete(PageData pd)throws Exception;
/**修改
* @param pd
* @throws Exception
*/
public void edit(PageData pd)throws Exception;
/**列表
* @param page
* @throws Exception
*/
public List<PageData> list(Page page)throws Exception;
/**列表(全部)
* @param pd
* @throws Exception
*/
public List<PageData> listAll(PageData pd)throws Exception;
/**通过id获取数据
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd)throws Exception;
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
public void deleteAll(String[] ArrayDATA_IDS)throws Exception;
/**
* 通过手机号查找对象
* @param phone
* @return
* @throws Exception
*/
public PageData findByPhone(String phone,String code_from)throws Exception;
/**
* 通过手机号删除元组
*/
public Object deleteByPhone(String phone)throws Exception;
}
package com.mall.service.mengbeng.api.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.mall.dao.DaoSupport;
import com.mall.entity.Page;
import com.mall.service.mengbeng.api.ValidateManager;
import com.mall.util.PageData;
/**
* 说明: 快递员注册验证码存储表
* 创建时间:2018-10-09
* @version
*/
@Service("validateService")
public class ValidateService implements ValidateManager {
@Resource(name = "daoSupport")
private DaoSupport dao;
/**新增
* @param pd
* @throws Exception
*/
public void save(PageData pd)throws Exception{
dao.save("ValidateMapper.save", pd);
}
/**删除
* @param pd
* @throws Exception
*/
public void delete(PageData pd)throws Exception{
dao.delete("ValidateMapper.delete", pd);
}
/**修改
* @param pd
* @throws Exception
*/
public void edit(PageData pd)throws Exception{
dao.update("ValidateMapper.edit", pd);
}
/**列表
* @param page
* @throws Exception
*/
@SuppressWarnings("unchecked")
public List<PageData> list(Page page)throws Exception{
return (List<PageData>)dao.findForList("ValidateMapper.datalistPage", page);
}
/**列表(全部)
* @param pd
* @throws Exception
*/
@SuppressWarnings("unchecked")
public List<PageData> listAll(PageData pd)throws Exception{
return (List<PageData>)dao.findForList("ValidateMapper.listAll", pd);
}
/**通过id获取数据
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd)throws Exception{
return (PageData)dao.findForObject("ValidateMapper.findById", pd);
}
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
dao.delete("ValidateMapper.deleteAll", ArrayDATA_IDS);
}
@Override
public PageData findByPhone(String phone,String code_from) throws Exception {
PageData pd = new PageData();
pd.put("phone", phone);
pd.put("code_from", code_from);
return (PageData) dao.findForObject("ValidateMapper.findByPhone",pd);
}
@Override
public Object deleteByPhone(String phone) throws Exception {
return dao.findForObject("ValidateMapper.deleteByPhone",phone);
}
}
......@@ -59,10 +59,15 @@ public interface StoreManager{
* @param pd
* @return
*/
public int findByPhone(PageData pd)throws Exception;
public PageData findByPhone(String phone)throws Exception;
public void viewStore(PageData pd)throws Exception;
public PageData findByStore(String storeName) throws Exception;
}
......@@ -92,8 +92,8 @@ public class StoreService implements StoreManager{
* @return
*/
@Override
public int findByPhone(PageData pd) throws Exception {
return (int) dao.findForObject("StoreManager.findByPhone", pd);
public PageData findByPhone(String phone) throws Exception {
return (PageData) dao.findForObject("StoreManager.findByPhone", phone);
}
@Override
......@@ -115,5 +115,10 @@ public class StoreService implements StoreManager{
viewedStore.put("store_view_number",store_view_number);
}
@Override
public PageData findByStore(String storeName) throws Exception {
return (PageData) dao.findForObject("StoreManager.findByStore", storeName);
}
}
......@@ -179,11 +179,11 @@ public class DateUtil {
String dateStr = sdf.format(date);
return dateStr;
}
public static void main(String[] args) {
System.out.println(getTime());
System.out.println(getAfterDayWeek("3"));
}
//
// public static void main(String[] args) {
// System.out.println(getTime());
// System.out.println(getAfterDayWeek("3"));
// }
/**
......@@ -266,4 +266,110 @@ public class DateUtil {
return simpleDateFormat.format(dates);
}
}
/**
* 对时间进行操作分钟数加减 ysl
* @throws ParseException
*/
public static String timeplus(int num) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar afterTime = Calendar.getInstance();
afterTime.add(Calendar.MINUTE, num); // 当前分钟+5 负号为剪
Date afterDate = (Date) afterTime.getTime();
String time = dateFormat.format(afterDate);
System.out.println("修改后的 时间" + time);
return time;
}
/**
* 对传入的时间分钟数加减
* ysl
*/
public static String timeplus(int num,Date date) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar afterTime = Calendar.getInstance();
afterTime.setTime(date);
afterTime.add(Calendar.MINUTE, num); // 当前分钟+5 负号为剪
Date afterDate = (Date) afterTime.getTime();
String time = dateFormat.format(afterDate);
System.out.println("修改后的 时间" + time);
return time;
}
/**
* 传入的时间与系统当前时间相减,得到天数差,小时差,分钟差
* @param
* @throws ParseException
* wuyulun
*/
public static long minuteDifference(String createTime) throws ParseException {
Date date3 = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date2 = df.parse(createTime);
long diff = date3.getTime() - date2.getTime();// 这样得到的差值是微秒级别
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60);
return minutes;
}
/**
* 传入的时间与系统当前时间相减,得到天数差,小时差,分钟差
* @param
* @throws ParseException
* wuyulun
*/
public static long hourDifference(String createTime) {
Date date3 = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date2 = null;
try {
date2 = df.parse(createTime);
} catch (ParseException e) {
e.printStackTrace();
}
long diff = date3.getTime() - date2.getTime();// 这样得到的差值是微秒级别
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
return hours;
}
public static void main(String[] args) throws ParseException {
/*System.out.println(getTime());
System.out.println(getAfterDayWeek("3"));*/
// String time = timeplus(5,new Date());
String time = DateUtil.getTime();
System.out.println(time);
String setTime="2018-10-18 1:00:00";
long hourDifference = DateUtil.hourDifference(setTime);
System.out.println(hourDifference);
}
/**
* 通过时间秒毫秒数判断两个时间的间隔
* @param date1 时间小
* @param date2 时间大
* @return
*/
public static int differentDaysByMillisecond(Date date1,Date date2)
{
int days = (int) ((date2.getTime() - date1.getTime()) / (1000*3600*24));
return days;
}
/**
*
* @param time yyyy-MM-dd
* @return String yyyy
*/
public static String getYearByStringTime(String time) {
try {
Date date = sdfDay.parse(time);
String year = sdfYear.format(date);
return year;
}catch (ParseException e){
e.getErrorOffset();
}
return null;
}
}
......@@ -95,7 +95,7 @@ public class SMSUtil {
* @return
* @throws IOException
*/
public String yzCode(String phone) throws IOException{
public String yzCode(String phone,String name) throws IOException{
if(phone.equals(null)){
return "error";
......@@ -108,7 +108,8 @@ public class SMSUtil {
String tpl_value = URLEncoder.encode("#code#",ENCODING) +"="
+ URLEncoder.encode(code, ENCODING) + "&"
+ URLEncoder.encode("#company#",ENCODING) + "="
+ URLEncoder.encode("正品2020",ENCODING);
// + URLEncoder.encode("正品2020",ENCODING);
+ URLEncoder.encode(name,ENCODING);
System.out.println(tpl_value);
System.out.println(SMSUtil.tplSendSms(apikey, tpl_id, tpl_value, phone));
return code;
......@@ -135,7 +136,7 @@ public class SMSUtil {
public static void main(String[] args) throws IOException {
SMSUtil smsUtil = new SMSUtil();
smsUtil.yzCode("15913115046");
smsUtil.yzCode("15913115046","ok");
}
}
package com.mall.util.tongmeng;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.EnumMap;
import javax.imageio.ImageIO;
import com.google.zxing.Binarizer;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
/**
* @ClassName DecodeImgZxing
* @Description 通过google的zxing解析二维码 注:此代码,不能解析:L纠错级别带logo和H级别的解析
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 二维码解析
*/
public class DecodeImgZxing {
//二维码格式参数
private static final EnumMap<DecodeHintType, Object> hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
static{
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
}
/**
* 解析二维码,使用google的zxing
* @param imgPath 二维码路径
* @return content 二维码内容
* */
public static String decodeImg(File imgFile){
String content = null;
if(!imgFile.isFile()){
System.out.println("输入非文件");
return null;
}
try {
BufferedImage image = ImageIO.read(imgFile);
LuminanceSource source = new BufferedImageLuminanceSource(image);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
MultiFormatReader reader = new MultiFormatReader();
Result result = reader.decode(binaryBitmap, hints);
content = result.getText();
// System.out.println("二维码结果:"+":"+result.toString()+","+result.getBarcodeFormat()+","+result.getText());
} catch (NotFoundException e) {
System.out.println("二维码解析NotFoundException");
e.printStackTrace();
} catch (IOException e) {
System.out.println("二维码解析IOException");
e.printStackTrace();
}
return content;
}
}
package com.mall.util.tongmeng;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
/**
* ClassName:EncodeImgZingLogo <br/>
* Function: TODO ADD FUNCTION. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2019年1月17日 上午11:56:13 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 带logo的二维码生成代码
*/
import javax.imageio.ImageIO;
public class EncodeImgZingLogo {
/**
* 二维码绘制logo
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* */
public static BufferedImage encodeImgLogo(File twodimensioncodeImg, File logoImg){
BufferedImage twodimensioncode = null;
try{
if(!twodimensioncodeImg.isFile() || !logoImg.isFile()){
System.out.println("输入非图片");
return null;
}
//读取二维码图片
twodimensioncode = ImageIO.read(twodimensioncodeImg);
//获取画笔
Graphics2D g = twodimensioncode.createGraphics();
//读取logo图片
BufferedImage logo = ImageIO.read(logoImg);
//设置二维码大小,太大,会覆盖二维码,此处20%
int logoWidth = logo.getWidth(null) > twodimensioncode.getWidth()*2 /10 ? (twodimensioncode.getWidth()*2 /10) : logo.getWidth(null);
int logoHeight = logo.getHeight(null) > twodimensioncode.getHeight()*2 /10 ? (twodimensioncode.getHeight()*2 /10) : logo.getHeight(null);
//设置logo图片放置位置
//中心
int x = (twodimensioncode.getWidth() - logoWidth) / 2;
int y = (twodimensioncode.getHeight() - logoHeight) / 2;
//右下角,15为调整值
// int x = twodimensioncode.getWidth() - logoWidth-15;
// int y = twodimensioncode.getHeight() - logoHeight-15;
//开始合并绘制图片
g.drawImage(logo, x, y, logoWidth, logoHeight, null);
g.drawRoundRect(x, y, logoWidth, logoHeight, 15 ,15);
//logo边框大小
g.setStroke(new BasicStroke(2));
//logo边框颜色
g.setColor(Color.WHITE);
g.drawRect(x, y, logoWidth, logoHeight);
g.dispose();
logo.flush();
twodimensioncode.flush();
}catch(Exception e){
System.out.println("二维码绘制logo失败");
}
return twodimensioncode;
}
/**
* 二维码输出到文件
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* @param format 图片格式
* @param file 输出文件
* */
public static void writeToFile(File twodimensioncodeImg,File logoImg,String format,File file) throws IOException {
BufferedImage image = encodeImgLogo(twodimensioncodeImg, logoImg);
try {
ImageIO.write(image, format, file);
} catch (IOException e) {
System.out.println("二维码写入文件失败"+e.getMessage());
}
}
/**
* 二维码流式输出
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* @param format 图片格式
* @param stream 输出流
* */
public static void writeToStream(File twodimensioncodeImg,File logoImg,String format,OutputStream stream){
BufferedImage image = encodeImgLogo(twodimensioncodeImg, logoImg);
try {
ImageIO.write(image, format, stream);
} catch (IOException e) {
System.out.println("二维码写入流失败"+e.getMessage());
}
}
}
package com.mall.util.tongmeng;
import java.io.File;
import java.io.IOException;
/**
* ClassName:EncodeImgZingLogoTest <br/>
* Date: 2019年1月17日 下午12:10:14 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 二维码生成器工具测试类
*/
public class EncodeImgZingLogoTest {
public static void main(String[] args) throws IOException {
String contents = "https://blog.csdn.net/shasiqq/article/details/80307846";
String format = "jpg"; //***此处如果格式为"gif",则logo图片为黑色,其他格式ok
//生成二维码
File img = new File("D:"+File.separator+"csdn.jpg");
EncodeImgZxing.writeToFile(contents, format, img);
//生成带有logo图片的二维码
File logoImg = new File("D:"+File.separator+"logo.jpg");
File img1 = new File("D:"+File.separator+"csdnAndLogo.jpg");
EncodeImgZingLogo.writeToFile(img, logoImg, format, img1);
//解析二维码内容
String content = DecodeImgZxing.decodeImg(img);
System.out.println("1:"+content);
//解析二维码带logo内容
String content1 = DecodeImgZxing.decodeImg(img1);
System.out.println("2:"+content1);
}
}
package com.mall.util.tongmeng;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.EnumMap;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
/**
* ClassName:EncodeImgZxing <br/>
* Function: TODO ADD FUNCTION. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2019年1月17日 上午11:55:40 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 生成二维码准备文件
*/
public class EncodeImgZxing {
//二维码颜色
private static final int BLACK = 0xFF000000;//0xFFFF0000,红色
//二维码背景色
private static final int WHITE = 0xFFFFFFFF;//0xFF0000FF,蓝色
//注:二维码颜色色差大,扫描快,但如果"BLACK'设置为黑色外其他颜色,可能无法扫描
//二维码图片宽度
private static final int width = 300;
//二维码图片高度
private static final int height = 300;
//二维码格式参数
private static final EnumMap<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
static{
/*二维码的纠错级别(排错率),4个级别:
L (7%)、
M (15%)、
Q (25%)、
H (30%)(最高H)
纠错信息同样存储在二维码中,纠错级别越高,纠错信息占用的空间越多,那么能存储的有用讯息就越少;共有四级;
选择M,扫描速度快。
*/
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
// 二维码边界空白大小 1,2,3,4 (4为默认,最大)
hints.put(EncodeHintType.MARGIN, 1);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MAX_SIZE, 350);
hints.put(EncodeHintType.MIN_SIZE, 150);
}
/**
* 绘制二维码
* @param contents 二维码内容
* @return image 二维码图片
* */
public static BufferedImage encodeImg(String contents){
BufferedImage image = null;
try{
BitMatrix matrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height, hints);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
int width = matrix.getWidth();
int height = matrix.getHeight();
for(int x = 0; x < width; x++){
for(int y =0;y < height; y++){
image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
}
}
}catch(Exception e){
System.out.println("生成二维码失败"+e.getMessage());
}
return image;
}
/**
* 二维码输出到文件
* @param contents 二维码内容
* @param format 图片格式
* @param file 输出文件
* */
public static void writeToFile(String contents,String format,File file){
BufferedImage image = encodeImg(contents);
try {
ImageIO.write(image, format, file);
} catch (IOException e) {
System.out.println("二维码写入文件失败"+e.getMessage());
}
}
/**
* 二维码流式输出
* @param contents 二维码内容
* @param format 图片格式
* @param stream 输出流
* */
public static void writeToStream(String contents,String format,OutputStream stream){
BufferedImage image = encodeImg(contents);
try {
ImageIO.write(image, format, stream);
} catch (IOException e) {
System.out.println("二维码写入流失败"+e.getMessage());
}
}
}
......@@ -182,6 +182,15 @@
#{item}
</foreach>
</delete>
<select id="findByPhone" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where mobile = #{phone}
</select>
<!-- 添加访问量 -->
<update id="addStoreViewNumber" parameterType="pd" >
update
<include refid="tableName"></include>
......@@ -189,6 +198,7 @@
store_view_number = #{store_view_number}
where store_id = #{store_id}
</update>
<!-- 添加被访问量 -->
<update id="addViewNumber" parameterType="pd" >
update
<include refid="tableName"></include>
......@@ -196,6 +206,7 @@
view_number = #{view_number}
where store_id = #{store_id}
</update>
<!-- 改变店铺状态 -->
<update id="updateIsValid" parameterType="pd" >
update
<include refid="tableName"></include>
......@@ -203,6 +214,13 @@
is_valid_store = #{is_valid_store}
where store_id = #{store_id}
</update>
<!-- 通过店铺名称获取数据 -->
<select id="findByStore" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where store_name = #{store_name}
</select>
</mapper>
\ No newline at end of file
<?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="ValidateMapper">
<!--表名 -->
<sql id="tableName">
t_validate_code
</sql>
<!-- 字段 -->
<sql id="Field">
id,
phone,
create_time,
authcode,
code_from
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{id},
#{phone},
#{create_time},
#{authcode},
#{code_from}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
delete from
<include refid="tableName"></include>
where
id = #{id}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
id = #{id},
phone = #{phone},
create_time = #{create_time},
authcode = #{authcode},
code_from =#{code_from}
where
id = #{id}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where
id = #{id}
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where 1=1
<if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件
字段1 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
or
字段2 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
-->
)
</if>
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
</select>
<!-- 通过手机号查找对象 -->
<select id="findByPhone" parameterType="String" resultType="pd">
select
*
from
<include refid="tableName"></include>
where
phone=#{phone}
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
delete from
<include refid="tableName"></include>
where
id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!--通过手机号删除元组-->
<!-- 删除-->
<delete id="deleteByPhone" parameterType="String">
delete from
<include refid="tableName"></include>
where
phone = #{phone}
</delete>
</mapper>
\ No newline at end of file
......@@ -90,7 +90,7 @@
<c:forEach items="${varList}" var="var" varStatus="vs">
<tr>
<td class='center'>
<label class="pos-rel"><input type='checkbox' name='ids' value="${var.openid}" class="ace" /><span class="lbl"></span></label>
<label class="pos-rel"><input type='checkbox' name='ids' value="${var.store_id}" class="ace" /><span class="lbl"></span></label>
</td>
<td class='center' style="width: 30px;">${vs.index+1}</td>
<td class='center'><img src="${var.store_logo}" style="height:50px"></td>
......@@ -131,39 +131,12 @@
</a>
</c:if> --%>
<c:if test="${QX.del == 1 }">
<a class="btn btn-xs btn-danger" onclick="del('${var.openid}');">
<a class="btn btn-xs btn-danger" onclick="del('${var.store_id}');">
<i class="ace-icon fa fa-trash-o bigger-120" title="删除"></i>
</a>
</c:if>
</div>
<div class="hidden-md hidden-lg">
<div class="inline pos-rel">
<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
</button>
<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
<c:if test="${QX.edit == 1 }">
<li>
<a style="cursor:pointer;" onclick="edit('${var.openid}');" class="tooltip-success" data-rel="tooltip" title="修改">
<span class="green">
<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
</span>
</a>
</li>
</c:if>
<c:if test="${QX.del == 1 }">
<li>
<a style="cursor:pointer;" onclick="del('${var.openid}');" class="tooltip-error" data-rel="tooltip" title="删除">
<span class="red">
<i class="ace-icon fa fa-trash-o bigger-120"></i>
</span>
</a>
</li>
</c:if>
</ul>
</div>
</div>
</td>
</tr>
</c:forEach>
......@@ -291,7 +264,7 @@
var diag = new top.Dialog();
diag.Drag=true;
diag.Title ="新增";
diag.URL = '${pageContext.request.contextPath}/vehicleUser/goAdd.do';
diag.URL = '${pageContext.request.contextPath}/store/goAdd.do';
diag.Width = 900;
diag.Height = 710;
diag.Modal = true; //有无遮罩窗口
......@@ -315,7 +288,7 @@
bootbox.confirm("确定要删除吗?", function(result) {
if(result) {
top.jzts();
var url = "${pageContext.request.contextPath}/vehicleUser/delete.do?openid="+Id+"&tm="+new Date().getTime();
var url = "${pageContext.request.contextPath}/store/delete.do?store_id="+Id+"&tm="+new Date().getTime();
$.get(url,function(data){
nextPage(${page.currentPage});
});
......@@ -329,7 +302,7 @@
var diag = new top.Dialog();
diag.Drag=true;
diag.Title ="编辑";
diag.URL = '${pageContext.request.contextPath}/vehicleUser/goEdit.do?openid='+Id;
diag.URL = '${pageContext.request.contextPath}/store/goEdit.do?openid='+Id;
diag.Width = 900;
diag.Height = 710;
diag.Modal = true; //有无遮罩窗口
......@@ -373,7 +346,7 @@
top.jzts();
$.ajax({
type: "POST",
url: '${pageContext.request.contextPath}/vehicleUser/deleteAll.do?tm='+new Date().getTime(),
url: '${pageContext.request.contextPath}/store/deleteAll.do?tm='+new Date().getTime(),
data: {DATA_IDS:str},
dataType:'json',
//beforeSend: validateData,
......@@ -392,23 +365,9 @@
//导出excel
function toExcel(){
window.location.href='${pageContext.request.contextPath}/vehicleUser/excel.do';
};
//导出省
function provinceExcel(){
var excelType=$("#excelType option:selected").val();
var excelTime = $("#excelTime option:selected").val();
// alert(excelType+" " +excelTime);
window.location.href='${pageContext.request.contextPath}/vehicleUser/visit_uv_new_excel.do?excelType='+excelType+'&excelTime='+excelTime+'&tm='+new Date().getTime();
};
//导出市
function cityExcel(){
var excelType=$("#excelType option:selected").val();
var excelTime = $("#excelTime option:selected").val();
var excelCity=$("#excelCity option:selected").val();
$("#province")
window.location.href='${pageContext.request.contextPath}/vehicleUser/visit_uv_excel.do?excelType='+excelType+'&excelCityID='+excelCity+'&tm='+new Date().getTime()+'&excelTime='+excelTime;
};
window.location.href='${pageContext.request.contextPath}/store/excel.do';
}
</script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论