From 9a842beed09c11e597c6aca2ff489651715a62fc Mon Sep 17 00:00:00 2001 From: louyao <1147756136@qq.com> Date: Thu, 11 Jun 2020 16:53:57 +0800 Subject: [PATCH] 微信分享accesstoken做缓存处理 --- src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- src/main/java/com/sincere/wechatbusiness/logs/LogName.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/logs/LoggerUtils.java | 27 +++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java | 32 ++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/mapper/CatalogContentMapper.java | 2 +- src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java | 24 ++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/AccessToken.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Account.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/DiscountPackage.java | 30 ++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Jsapi.java | 43 +++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Order.java | 20 ++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Statistics.java | 35 +++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Token.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/model/Users.java | 451 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/service/ChannelService.java | 24 ++++++++++++++++++++++++ src/main/java/com/sincere/wechatbusiness/service/impl/CatalogContentServiceImpl.java | 2 +- src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java | 33 +++++++++++++++++++++++++++++++++ src/main/resources/application.yaml | 9 ++++++--- src/main/resources/logback.xml | 4 ++-- src/main/resources/mapper/CatalogContentMapper.xml | 4 ++-- src/main/resources/mapper/ChannelMapper.xml | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 21 files changed, 1337 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/sincere/wechatbusiness/logs/LogName.java create mode 100644 src/main/java/com/sincere/wechatbusiness/logs/LoggerUtils.java create mode 100644 src/main/java/com/sincere/wechatbusiness/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/AccessToken.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/Account.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/Jsapi.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/Statistics.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/Token.java create mode 100644 src/main/java/com/sincere/wechatbusiness/model/Users.java diff --git a/src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java b/src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java index a10a314..d8f5b5d 100644 --- a/src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java +++ b/src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java @@ -3,14 +3,19 @@ package com.sincere.wechatbusiness.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.fasterxml.jackson.databind.ser.Serializers; import com.sincere.wechatbusiness.dto.BaseDto; import com.sincere.wechatbusiness.dto.ChannelDto; +import com.sincere.wechatbusiness.logs.LogName; +import com.sincere.wechatbusiness.logs.LoggerUtils; import com.sincere.wechatbusiness.model.*; import com.sincere.wechatbusiness.service.*; import com.sincere.wechatbusiness.utils.HttpClientUtils; import com.sincere.wechatbusiness.utils.Page; import com.sincere.wechatbusiness.utils.TokenUtils; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -22,8 +27,9 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.util.List; -import java.util.Map; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; @RestController public class ChannelController { @@ -48,8 +54,10 @@ public class ChannelController { @Autowired AgentService agentService; - private String domain="https://mytest.myjxt.com:51314"; -// private String domain="https://proxy.shunzhi.net:51314"; + private static final Logger log_channel = LoggerUtils.Logger(LogName.channel); + +// private String domain="https://mytest.myjxt.com:51314"; + private String domain="https://proxy.shunzhi.net:51314"; @RequestMapping(value = "GetChannelList",method = RequestMethod.POST) @ApiOperation(value = "获取渠道商列表") @@ -318,11 +326,45 @@ public class ChannelController { @ApiOperation(value = "获取微信分享签名") public BaseDto GetWxSign(String url){ BaseDto result=new BaseDto<>(); - String r=Get("http://114.55.30.100:1111/api/UserRegisterApp/GetWxShareSign","url="+url); - JSONObject jsonObject= JSONObject.parseObject(r); - String data = jsonObject.getString("result"); - WxSign wxSign=JSON.parseObject(data,new TypeReference(){}); - result.setData(wxSign); +// String r=Get("http://114.55.30.100:1111/api/UserRegisterApp/GetWxShareSign","url="+url); +// JSONObject jsonObject= JSONObject.parseObject(r); +// String data = jsonObject.getString("result"); +// WxSign wxSign=JSON.parseObject(data,new TypeReference(){}); +// result.setData(wxSign); + + WxSign wxSign1=new WxSign(); + wxSign1.setTimestamp(Long.toString(System.currentTimeMillis())); + wxSign1.setNoncestr(UUID.randomUUID().toString()); + AccessToken accessToken=channelService.getAccessToken(); + Token token=new Token(); + if(accessToken!=null) { + Calendar dateOne=Calendar.getInstance(); + Calendar dateTwo=Calendar.getInstance(); + dateOne.setTime(new Date()); + dateTwo.setTime(accessToken.getCreateTime()); + long timeOne=dateOne.getTimeInMillis(); + long timeTwo=dateTwo.getTimeInMillis(); + long minute=(timeOne-timeTwo)/(1000*60); + + if(minute<60) token.setAccess_token(accessToken.getAccessToken()); + else{ + token=getAccessToken("wx6078ff3f67524996","8a0465b8ad0f000f568f48853e2818c8"); + accessToken.setAccessToken(token.getAccess_token()); + channelService.insertAccessToken(accessToken); + } + } + else { + token=getAccessToken("wx6078ff3f67524996","8a0465b8ad0f000f568f48853e2818c8"); + accessToken=new AccessToken(); + accessToken.setAccessToken(token.getAccess_token()); + channelService.insertAccessToken(accessToken); + } + String js=Get("https://api.weixin.qq.com/cgi-bin/ticket/getticket","type=jsapi&access_token="+token.getAccess_token()); + JSONObject jsonObject= JSONObject.parseObject(js); + wxSign1.setJsapi_ticket(jsonObject.getString("ticket")); + String rawstring = "jsapi_ticket=" + wxSign1.getJsapi_ticket() + "&noncestr=" + wxSign1.getNoncestr() + "×tamp=" + wxSign1.getTimestamp() + "&url=" + url + ""; + wxSign1.setSignature(SHA1(rawstring)); + result.setData(wxSign1); return result; } @@ -363,25 +405,44 @@ public class ChannelController { @RequestMapping(value = "IsDianXin",method = RequestMethod.GET) @ApiOperation(value = "判断是否是电信用户") - public BaseDto> IsDianXin(String mobile,int productId){ + public BaseDto> IsDianXin(String mobile,String password,int productId){ BaseDto> result=new BaseDto(); String r=Get(domain+"/admin/Voluntary/GetAccount","mobile="+mobile); JSONObject jsonObject= JSONObject.parseObject(r); String data = jsonObject.getString("data"); + Account account=JSON.parseObject(data,new TypeReference(){}); if(data==null){ result.setSuccess(false); result.setMessage("非VIP邀请号码"); } else { - Get(domain+"/h5/MyVoluntary/AddVerificationCode","code=206&mobile="+mobile+"&type=1"); - String re=Get(domain+"/University/getMyCouponDetail","mobile="+mobile+"&type="+productId); - JSONObject jsonObject1= JSONObject.parseObject(re); - String data1 = jsonObject1.getString("data"); - result.setData(JSON.parseObject(data1,new TypeReference>(){})); +// Get(domain+"/h5/MyVoluntary/AddVerificationCode","code=206&mobile="+mobile+"&type=1"); + if(!account.getPassword().equals(password)){ + result.setSuccess(false); + result.setMessage("密码错误"); + } + else{ + String re=Get(domain+"/University/getMyCouponDetail","mobile="+mobile+"&type="+productId); + JSONObject jsonObject1= JSONObject.parseObject(re); + String data1 = jsonObject1.getString("data"); + result.setData(JSON.parseObject(data1,new TypeReference>(){})); + } } return result; } + @RequestMapping(value = "AddUser",method = RequestMethod.POST) + @ApiOperation(value = "新增用户") + public BaseDto AddUser(@RequestBody Users users){ + JSONObject object = new JSONObject(); + object.put("phone",users.getPhone()); + object.put("channelId",users.getChannelId()); + object.put("agentId",users.getAgentId()); + object.put("userType",1); + JSONObject jsonObject=HttpClientUtils.httpPostJson(domain+"/admin/Voluntary/AddUser",object.toJSONString()); + return new BaseDto(); + } + @RequestMapping(value = "GetAddOrderDetail",method = RequestMethod.POST) @ApiOperation(value = "生成预支付订单并返回详情") public BaseDto> GetAddOrderDetail(@RequestBody Order order) { @@ -398,12 +459,25 @@ public class ChannelController { object.put("user_name",order.getUser_name()); object.put("buycount",0); object.put("score_id",0); + object.put("channelId",order.getChannelId()); + object.put("agentId",order.getAgentId()); JSONObject jsonObject = HttpClientUtils.httpPostJson(domain+"/University/GetAddOrderDetail",object.toJSONString()); String data = jsonObject.getString("data"); result.setData(JSON.parseObject(data,new TypeReference>(){})); return result; } + @RequestMapping(value = "GetToken",method = RequestMethod.GET) + @ApiOperation(value = "获取openid") + public BaseDto GetToken(String code){ + BaseDto result=new BaseDto<>(); + String re=Get("http://campus.myjxt.com/api/EasyMessage/GetTokenYKT","code="+code); + JSONObject jsonObject1= JSONObject.parseObject(re); + String data1 = jsonObject1.getString("data"); + result.setData(JSON.parseObject(data1,new TypeReference(){})); + return result; + } + @RequestMapping(value = "WxPay",method = RequestMethod.POST) @ApiOperation(value = "微信支付") public BaseDto WxPay(@RequestBody WxPay pay){ @@ -418,9 +492,78 @@ public class ChannelController { object.put("subject",pay.getSubject()); object.put("totalFee",pay.getTotalFee()); object.put("coupon_num",pay.getCoupon_num()); + object.put("openid",pay.getOpenid()); JSONObject jsonObject = HttpClientUtils.httpPostJson(domain+"/Payment/WxPay",object.toJSONString()); - String data = jsonObject.getString("data"); - result.setData(JSON.parseObject(data,new TypeReference(){})); + if(jsonObject!=null) { + String data = jsonObject.getString("data"); + result.setData(JSON.parseObject(data,new TypeReference(){})); + } + return result; + } + + @RequestMapping(value = "GetStatistics",method = RequestMethod.GET) + @ApiOperation(value = "获取渠道商统计,type:1-今日;2-本月;3-累计") + public BaseDto> GetStatistics(int channelId,int agentId,int type){ + BaseDto> result=new BaseDto(); + List list=new ArrayList<>(); + Statistics register=new Statistics(); + register.setCount(channelService.getRegisterCount(channelId,agentId,type)); + List registerList=new ArrayList<>(); + Users channelRegister=new Users(); + channelRegister=channelService.getChannelRegister(channelId,type); + if(channelRegister!=null) registerList.add(channelRegister); + registerList.addAll(channelService.getAgentRegisterList(channelId,type)); + register.setUsersList(registerList); + list.add(register); + Statistics order=new Statistics(); + order.setCount(channelService.getOrderCount(channelId,agentId,type)); + List orderList=new ArrayList<>(); + Users channelOrder=new Users(); + channelOrder=channelService.getChannelOrder(channelId,type); + if(channelOrder!=null) orderList.add(channelOrder); + orderList.addAll(channelService.getAgentOrderList(channelId,type)); + order.setUsersList(orderList); + list.add(order); + Statistics statistics=new Statistics(); + statistics.setDiscountPackageList(channelService.getOrderList(channelId,type)); + list.add(statistics); + result.setData(list); + return result; + } + + @RequestMapping(value = "GetStatisticsRegisterDetailList",method = RequestMethod.GET) + @ApiOperation(value = "获取注册详情") + public BaseDto> GetStatisticsRegisterDetailList(int channelId,int agentId,int type){ + BaseDto> result=new BaseDto<>(); + result.setData(channelService.getRegisterDetailList(channelId,agentId,type)); + return result; + } + + @RequestMapping(value = "GetStatisticsOrderDetailList",method = RequestMethod.GET) + @ApiOperation(value = "获取订购详情") + public BaseDto> GetStatisticsOrderDetailList(int channelId,int agentId,int type,int productId){ + BaseDto> result=new BaseDto<>(); + result.setData(channelService.getOrderDetailList(channelId,agentId,type,productId)); + return result; + } + + @RequestMapping(value = "GetAgentStatistics",method = RequestMethod.GET) + @ApiOperation(value = "获取推广统计,type:1-今日;2-本月;3-累计") + public BaseDto> GetAgentStatistics(int channelId,int agentId,int type){ + BaseDto> result=new BaseDto<>(); + List list=new ArrayList<>(); + Statistics register=new Statistics(); + register.setCount(channelService.getRegisterCount(channelId,agentId,type)); + register.setUsersList(channelService.getRegisterDetailList(channelId,agentId,type)); + list.add(register); + Statistics order=new Statistics(); + order.setCount(channelService.getOrderCount(channelId,agentId,type)); + order.setDiscountPackageList(channelService.getOrderDetailList(channelId,agentId,type,0)); + list.add(order); + Statistics statistics=new Statistics(); + statistics.setDiscountPackageList(channelService.getOrderList(channelId,type)); + list.add(statistics); + result.setData(list); return result; } @@ -550,4 +693,60 @@ public class ChannelController { return result; } + public Token getAccessToken(String appID, String appScret) { + Token token = new Token(); + String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appID + "&secret=" + + appScret; + try { + URL getUrl=new URL(url); + HttpURLConnection http=(HttpURLConnection)getUrl.openConnection(); + http.setRequestMethod("GET"); + http.setRequestProperty("Content-Type", + "application/x-www-form-urlencoded"); + http.setDoOutput(true); + http.setDoInput(true); + + + http.connect(); + InputStream is = http.getInputStream(); + int size = is.available(); + byte[] b = new byte[size]; + is.read(b); + + String message = new String(b, "UTF-8"); + JSONObject json = JSONObject.parseObject(message); + + + token.setAccess_token(json.getString("access_token")); + token.setExpires_in(new Integer(json.getString("expires_in"))); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return token; + } + + public static String SHA1(String str) { + try { + MessageDigest digest = java.security.MessageDigest.getInstance("SHA-1"); //如果是SHA加密只需要将"SHA-1"改成"SHA"即可 + digest.update(str.getBytes()); + byte messageDigest[] = digest.digest(); + // Create Hex String + StringBuffer hexStr = new StringBuffer(); + // 字节数组转换为 十六进制 数 + for (int i = 0; i < messageDigest.length; i++) { + String shaHex = Integer.toHexString(messageDigest[i] & 0xFF); + if (shaHex.length() < 2) { + hexStr.append(0); + } + hexStr.append(shaHex); + } + return hexStr.toString(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return null; + } } diff --git a/src/main/java/com/sincere/wechatbusiness/logs/LogName.java b/src/main/java/com/sincere/wechatbusiness/logs/LogName.java new file mode 100644 index 0000000..c8a1a9d --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/logs/LogName.java @@ -0,0 +1,35 @@ +package com.sincere.wechatbusiness.logs; + +/** + * @author chen + * @version 1.0 + * @date 2019/10/12 0012 16:18 + */ +public enum LogName { + channel("channel"); + + private String logFileName; + + LogName(String fileName) { + this.logFileName = fileName; + } + + public String getLogFileName() { + return logFileName; + } + + public void setLogFileName(String logFileName) { + this.logFileName = logFileName; + } + + public static com.sincere.wechatbusiness.logs.LogName getAwardTypeEnum(String value) { + com.sincere.wechatbusiness.logs.LogName[] arr = values(); + for (com.sincere.wechatbusiness.logs.LogName item : arr) { + if (null != item && !item.logFileName.equals("")) { + return item; + } + } + return null; + } +} + diff --git a/src/main/java/com/sincere/wechatbusiness/logs/LoggerUtils.java b/src/main/java/com/sincere/wechatbusiness/logs/LoggerUtils.java new file mode 100644 index 0000000..4f9a191 --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/logs/LoggerUtils.java @@ -0,0 +1,27 @@ +package com.sincere.wechatbusiness.logs; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author chen + * @version 1.0 + * @date 2019/10/12 0012 16:19 + */ +public class LoggerUtils { + + public static Logger Logger(Class clazz) { + return LoggerFactory.getLogger(clazz); + } + + /** + * 打印到指定的文件下 + * + * @param desc 日志文件名称 + * @return + */ + public static Logger Logger(LogName desc) { + return LoggerFactory.getLogger(desc.getLogFileName()); + } + +} diff --git a/src/main/java/com/sincere/wechatbusiness/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java b/src/main/java/com/sincere/wechatbusiness/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java new file mode 100644 index 0000000..c9cfc6d --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java @@ -0,0 +1,32 @@ +package com.sincere.wechatbusiness.logs; + +import ch.qos.logback.core.joran.spi.NoAutoStart; +import ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy; + +/** + * @author chen + * @version 1.0 + * @date 2019/10/31 0031 13:42 + */ +@NoAutoStart +public class MyTimeBasedFileNamingAndTriggeringPolicy extends DefaultTimeBasedFileNamingAndTriggeringPolicy { + + //这个用来指定时间间隔 + private Integer multiple = 1; + + @Override + protected void computeNextCheck() { + nextCheck = rc.getEndOfNextNthPeriod(dateInCurrentPeriod, multiple).getTime(); + } + + public Integer getMultiple() { + return multiple; + } + + public void setMultiple(Integer multiple) { + if (multiple > 1) { + this.multiple = multiple; + } + } + +} diff --git a/src/main/java/com/sincere/wechatbusiness/mapper/CatalogContentMapper.java b/src/main/java/com/sincere/wechatbusiness/mapper/CatalogContentMapper.java index 2bf56aa..c9ac554 100644 --- a/src/main/java/com/sincere/wechatbusiness/mapper/CatalogContentMapper.java +++ b/src/main/java/com/sincere/wechatbusiness/mapper/CatalogContentMapper.java @@ -14,5 +14,5 @@ public interface CatalogContentMapper { int deleteCatalogContent(int id); - List getListByDate(@Param("catalogId") int catalogId,@Param("date") String date,@Param("state") int state); + List getListByDate(@Param("catalogId") int catalogId,@Param("date1") String date1,@Param("date2") String date2,@Param("state") int state); } diff --git a/src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java b/src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java index cdba067..a48dac1 100644 --- a/src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java +++ b/src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java @@ -1,6 +1,8 @@ package com.sincere.wechatbusiness.mapper; import com.sincere.wechatbusiness.model.*; +import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -28,4 +30,26 @@ public interface ChannelMapper { Manager getManagerDetail(String mobile); int insertLog(Log log); + + int getRegisterCount(@Param("channelId") int channelId, @Param("agentId") int agentId, @Param("type") int type); + + int getOrderCount(@Param("channelId") int channelId, @Param("agentId") int agentId, @Param("type") int type,@Param("state") int state); + + List getAgentRegisterList(@Param("channelId") int channelId,@Param("type") int type,@Param("state") int state); + + List getAgentOrderList(@Param("channelId") int channelId,@Param("type") int type,@Param("state") int state); + + Users getChannelRegister(@Param("channelId") int channelId,@Param("type") int type,@Param("state") int state); + + Users getChannelOrder(@Param("channelId") int channelId,@Param("type") int type,@Param("state") int state); + + List getOrderList(@Param("channelId") int channelId,@Param("type") int type,@Param("state") int state); + + List getRegisterDetailList(@Param("channelId") int channelId,@Param("agentId") int agentId,@Param("type") int type); + + List getOrderDetailList(@Param("channelId") int channelId,@Param("agentId") int agentId,@Param("type") int type,@Param("productId") int productId); + + int insertAccessToken(AccessToken accessToken); + + AccessToken getAccessToken(); } diff --git a/src/main/java/com/sincere/wechatbusiness/model/AccessToken.java b/src/main/java/com/sincere/wechatbusiness/model/AccessToken.java new file mode 100644 index 0000000..f724b5f --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/AccessToken.java @@ -0,0 +1,35 @@ +package com.sincere.wechatbusiness.model; + +import java.util.Date; + +public class AccessToken { + private Integer id; + + private String accessToken; + + private Date createTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/sincere/wechatbusiness/model/Account.java b/src/main/java/com/sincere/wechatbusiness/model/Account.java new file mode 100644 index 0000000..048e5c1 --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/Account.java @@ -0,0 +1,58 @@ +package com.sincere.wechatbusiness.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; + +@ApiModel +public class Account { + private Integer id; + + private Integer projectId; + + private String phone; + + private String password; + + @ApiModelProperty(value = "0-删除;1-正常;2-停用") + private Integer state; + + private Integer isLogin; + + private Integer isOrder; + + private Date createTime; + + public Integer getId(){return id;} + + public void setId(Integer id){this.id=id;} + + public Integer getProjectId(){return projectId;} + + public void setProjectId(Integer projectId){this.projectId=projectId;} + + public String getPhone(){return phone;} + + public void setPhone(String phone){this.phone=phone;} + + public String getPassword(){return password;} + + public void setPassword(String password){this.password=password;} + + public Integer getState(){return state;} + + public void setState(Integer state){this.state=state;} + + public Integer getIsLogin(){return isLogin;} + + public void setIsLogin(Integer isLogin){this.isLogin=isLogin;} + + public Integer getIsOrder(){return isOrder;} + + public void setIsOrder(Integer isOrder){this.isOrder=isOrder;} + + public Date getCreateTime(){return createTime;} + + public void setCreateTime(Date createTime){this.createTime=createTime;} +} diff --git a/src/main/java/com/sincere/wechatbusiness/model/DiscountPackage.java b/src/main/java/com/sincere/wechatbusiness/model/DiscountPackage.java index b78f1e6..b628f40 100644 --- a/src/main/java/com/sincere/wechatbusiness/model/DiscountPackage.java +++ b/src/main/java/com/sincere/wechatbusiness/model/DiscountPackage.java @@ -14,6 +14,12 @@ public class DiscountPackage { private String isSelect; + private Integer count; + + private String account; + + private Date intime; + public Integer getId() { return id; } @@ -85,4 +91,28 @@ public class DiscountPackage { public void setIsSelect(String isSelect) { this.isSelect = isSelect; } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public Date getIntime() { + return intime; + } + + public void setIntime(Date intime) { + this.intime = intime; + } } diff --git a/src/main/java/com/sincere/wechatbusiness/model/Jsapi.java b/src/main/java/com/sincere/wechatbusiness/model/Jsapi.java new file mode 100644 index 0000000..a889c16 --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/Jsapi.java @@ -0,0 +1,43 @@ +package com.sincere.wechatbusiness.model; + +public class Jsapi { + public Integer errcode; + + public String errmsg; + + public String ticket; + + public Integer expires_in; + + public Integer getErrcode() { + return errcode; + } + + public void setErrcode(Integer errcode) { + this.errcode = errcode; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } + + public String getTicket() { + return ticket; + } + + public void setTicket(String ticket) { + this.ticket = ticket; + } + + public Integer getExpires_in() { + return expires_in; + } + + public void setExpires_in(Integer expires_in) { + this.expires_in = expires_in; + } +} diff --git a/src/main/java/com/sincere/wechatbusiness/model/Order.java b/src/main/java/com/sincere/wechatbusiness/model/Order.java index bbf1575..73931ab 100644 --- a/src/main/java/com/sincere/wechatbusiness/model/Order.java +++ b/src/main/java/com/sincere/wechatbusiness/model/Order.java @@ -50,6 +50,10 @@ public class Order { private String discount; + private Integer channelId; + + private Integer agentId; + public Integer getId() { return id; @@ -214,4 +218,20 @@ public class Order { public void setDiscount(String discount) { this.discount = discount; } + + public Integer getChannelId() { + return channelId; + } + + public void setChannelId(Integer channelId) { + this.channelId = channelId; + } + + public Integer getAgentId() { + return agentId; + } + + public void setAgentId(Integer agentId) { + this.agentId = agentId; + } } diff --git a/src/main/java/com/sincere/wechatbusiness/model/Statistics.java b/src/main/java/com/sincere/wechatbusiness/model/Statistics.java new file mode 100644 index 0000000..2998334 --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/Statistics.java @@ -0,0 +1,35 @@ +package com.sincere.wechatbusiness.model; + +import java.util.List; + +public class Statistics { + private Integer Count; + + private List usersList; + + private List discountPackageList; + + public Integer getCount() { + return Count; + } + + public void setCount(Integer count) { + Count = count; + } + + public List getUsersList() { + return usersList; + } + + public void setUsersList(List usersList) { + this.usersList = usersList; + } + + public List getDiscountPackageList() { + return discountPackageList; + } + + public void setDiscountPackageList(List discountPackageList) { + this.discountPackageList = discountPackageList; + } +} diff --git a/src/main/java/com/sincere/wechatbusiness/model/Token.java b/src/main/java/com/sincere/wechatbusiness/model/Token.java new file mode 100644 index 0000000..4df095c --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/Token.java @@ -0,0 +1,53 @@ +package com.sincere.wechatbusiness.model; + +public class Token { + public String access_token; + + public Integer expires_in; + + public String refresh_token; + + public String openid; + + public String scope; + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(String access_token) { + this.access_token = access_token; + } + + public Integer getExpires_in() { + return expires_in; + } + + public void setExpires_in(Integer expires_in) { + this.expires_in = expires_in; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(String refresh_token) { + this.refresh_token = refresh_token; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} diff --git a/src/main/java/com/sincere/wechatbusiness/model/Users.java b/src/main/java/com/sincere/wechatbusiness/model/Users.java new file mode 100644 index 0000000..3695d8e --- /dev/null +++ b/src/main/java/com/sincere/wechatbusiness/model/Users.java @@ -0,0 +1,451 @@ +package com.sincere.wechatbusiness.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; +import java.util.List; + +@ApiModel +public class Users { + private Integer id; + + private String userName; + + @ApiModelProperty(value = "1-用户;2-专家") + private Integer userType; + + private String password; + + private String sex; + + private String phone; + + private String weChat; + + private String face; + + private Integer age; + + private String province; + + private String city; + + private String graduateSchool; + + private String expertIntroduction; + + @ApiModelProperty(value = "0-未激活;1-已激活") + private Integer isActive; + + @ApiModelProperty(value="1-普通志愿;2-三位一体志愿;用,分割") + private String service; + + private Integer sort; + + @ApiModelProperty(value = "1-启用;2-停用") + private Integer state; + + private Date createTime; + + private String beginTime; + + private String endTime; + + private String para; + + private String provinceCode; + + private String cityCode; + + @ApiModelProperty(value = "报名人数") + private Integer applyCount; + + @ApiModelProperty(value = "未报名人数") + private Integer noCount; + + @ApiModelProperty(value = "报名百分比") + private Integer percentage; + + @ApiModelProperty(value = "1-普通志愿;2-三位一体") + private Integer type; + + private Integer firstCount; + + private Integer secondCount; + + private Integer overCount; + + @ApiModelProperty(value = "是否电信用户,1-是") + private Integer isDianXin; + + private Double price; + + @ApiModelProperty(value = "收货人") + private String consignee; + + @ApiModelProperty(value = "收货手机号") + private String receivePhone; + + @ApiModelProperty(value = "收货地区code") + private String areaCode; + + @ApiModelProperty(value = "收货地区") + private String areaName; + + @ApiModelProperty(value = "详细地址") + private String address; + + @ApiModelProperty(value = "三位一体服务人数") + private Integer trinityServiceNumber; + + @ApiModelProperty(value = "基本信息") + private String trinityIntroduction; + + @ApiModelProperty(value = "专家服务") + private String trinityService; + + @ApiModelProperty(value = "普通志愿服务人数") + private Integer pointServiceNumber; + + @ApiModelProperty(value = "基本信息") + private String pointIntroduction; + + @ApiModelProperty(value = "专家服务") + private String pointService; + + @ApiModelProperty(value = "1-上架;2-下架") + private int putAway; + + private String newMobile; + + private Integer channelId; + + private Integer agentId; + + @ApiModelProperty(value = "统计账号后四位") + private String account; + + @ApiModelProperty(value = "统计人数") + private Integer count; + + public Integer getId(){return id;} + + public void setId(Integer id){this.id=id;} + + public String getUserName(){return userName;} + + public void setUserName(String userName){this.userName=userName;} + + public Integer getUserType(){return userType;} + + public void setUserType(Integer userType){this.userType=userType;} + + public String getPassword(){return password;} + + public void setPassword(String password){this.password=password;} + + public String getSex(){return sex;} + + public void setSex(String sex){this.sex=sex;} + + public String getPhone(){return phone;} + + public void setPhone(String phone){this.phone=phone;} + + public String getWeChat(){return weChat;} + + public void setWeChat(String weChat){this.weChat=weChat;} + + public String getFace(){return face;} + + public void setFace(String face){this.face=face;} + + public Integer getAge(){return age;} + + public void setAge(Integer age){this.age=age;} + + public String getProvince(){return province;} + + public void setProvince(String province){this.province=province;} + + public String getCity(){return city;} + + public void setCity(String city){this.city=city;} + + public String getGraduateSchool(){return graduateSchool;} + + public void setGraduateSchool(String graduateSchool){this.graduateSchool=graduateSchool;} + + public String getExpertIntroduction(){return expertIntroduction;} + + public void setExpertIntroduction(String expertIntroduction){this.expertIntroduction=expertIntroduction;} + + public Integer getState(){return state;} + + public void setState(Integer state){this.state=state;} + + public Date getCreateTime(){return createTime;} + + public void setCreateTime(Date createTime){this.createTime=createTime;} + + public String getBeginTime(){return beginTime;} + + public void setBeginTime(String beginTime){this.beginTime=beginTime;} + + public String getEndTime(){return endTime;} + + public void setEndTime(String endTime){this.endTime=endTime;} + + public String getPara(){return para;} + + public void setPara(String para){this.para=para;} + + public Integer getIsActive() { + return isActive; + } + + public void setIsActive(Integer isActive) { + this.isActive = isActive; + } + + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getProvinceCode() { + return provinceCode; + } + + public void setProvinceCode(String provinceCode) { + this.provinceCode = provinceCode; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public Integer getApplyCount() { + return applyCount; + } + + public void setApplyCount(Integer applyCount) { + this.applyCount = applyCount; + } + + public Integer getNoCount() { + return noCount; + } + + public void setNoCount(Integer noCount) { + this.noCount = noCount; + } + + public Integer getPercentage() { + return percentage; + } + + public void setPercentage(Integer percentage) { + this.percentage = percentage; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getFirstCount() { + return firstCount; + } + + public void setFirstCount(Integer firstCount) { + this.firstCount = firstCount; + } + + public Integer getSecondCount() { + return secondCount; + } + + public void setSecondCount(Integer secondCount) { + this.secondCount = secondCount; + } + + public Integer getOverCount() { + return overCount; + } + + public void setOverCount(Integer overCount) { + this.overCount = overCount; + } + + public Integer getIsDianXin() { + return isDianXin; + } + + public void setIsDianXin(Integer isDianXin) { + this.isDianXin = isDianXin; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getConsignee() { + return consignee; + } + + public void setConsignee(String consignee) { + this.consignee = consignee; + } + + public String getReceivePhone() { + return receivePhone; + } + + public void setReceivePhone(String receivePhone) { + this.receivePhone = receivePhone; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Integer getTrinityServiceNumber() { + return trinityServiceNumber; + } + + public void setTrinityServiceNumber(Integer trinityServiceNumber) { + this.trinityServiceNumber = trinityServiceNumber; + } + + public String getTrinityIntroduction() { + return trinityIntroduction; + } + + public void setTrinityIntroduction(String trinityIntroduction) { + this.trinityIntroduction = trinityIntroduction; + } + + public String getTrinityService() { + return trinityService; + } + + public void setTrinityService(String trinityService) { + this.trinityService = trinityService; + } + + public Integer getPointServiceNumber() { + return pointServiceNumber; + } + + public void setPointServiceNumber(Integer pointServiceNumber) { + this.pointServiceNumber = pointServiceNumber; + } + + public String getPointIntroduction() { + return pointIntroduction; + } + + public void setPointIntroduction(String pointIntroduction) { + this.pointIntroduction = pointIntroduction; + } + + public String getPointService() { + return pointService; + } + + public void setPointService(String pointService) { + this.pointService = pointService; + } + + public int getPutAway() { + return putAway; + } + + public void setPutAway(int putAway) { + this.putAway = putAway; + } + + public String getNewMobile() { + return newMobile; + } + + public void setNewMobile(String newMobile) { + this.newMobile = newMobile; + } + + public Integer getChannelId() { + return channelId; + } + + public void setChannelId(Integer channelId) { + this.channelId = channelId; + } + + public Integer getAgentId() { + return agentId; + } + + public void setAgentId(Integer agentId) { + this.agentId = agentId; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } +} diff --git a/src/main/java/com/sincere/wechatbusiness/service/ChannelService.java b/src/main/java/com/sincere/wechatbusiness/service/ChannelService.java index 60e4cba..a415e4d 100644 --- a/src/main/java/com/sincere/wechatbusiness/service/ChannelService.java +++ b/src/main/java/com/sincere/wechatbusiness/service/ChannelService.java @@ -2,6 +2,8 @@ package com.sincere.wechatbusiness.service; import com.sincere.wechatbusiness.model.*; import com.sincere.wechatbusiness.utils.Page; +import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -23,4 +25,26 @@ public interface ChannelService { Manager getManagerDetail(String mobile); int insertLog(Log log); + + int getRegisterCount(int channelId,int agentId,int type); + + int getOrderCount(int channelId,int agentId,int type); + + List getAgentRegisterList(int channelId,int type); + + List getAgentOrderList(int channelId,int type); + + Users getChannelRegister(int channelId,int type); + + Users getChannelOrder(int channelId,int type); + + List getOrderList(int channelId,int type); + + List getRegisterDetailList(int channelId,int agentId,int type); + + List getOrderDetailList(int channelId,int agentId,int type,int productId); + + int insertAccessToken(AccessToken accessToken); + + AccessToken getAccessToken(); } diff --git a/src/main/java/com/sincere/wechatbusiness/service/impl/CatalogContentServiceImpl.java b/src/main/java/com/sincere/wechatbusiness/service/impl/CatalogContentServiceImpl.java index 8939313..96700e2 100644 --- a/src/main/java/com/sincere/wechatbusiness/service/impl/CatalogContentServiceImpl.java +++ b/src/main/java/com/sincere/wechatbusiness/service/impl/CatalogContentServiceImpl.java @@ -27,5 +27,5 @@ public class CatalogContentServiceImpl implements CatalogContentService { public int deleteCatalogContent(int id){return catalogContentMapper.deleteCatalogContent(id);} @Override - public List getListByDate(int catalogId,String date){return catalogContentMapper.getListByDate(catalogId,date,1);} + public List getListByDate(int catalogId,String date){return catalogContentMapper.getListByDate(catalogId,date+" 23:59:59",date+" 00:00:00",1);} } diff --git a/src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java b/src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java index 7d1b5ac..5f57998 100644 --- a/src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java +++ b/src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java @@ -63,5 +63,38 @@ public class ChannelServiceImpl implements ChannelService { @Override public int insertLog(Log log){return channelMapper.insertLog(log);} + + @Override + public int getRegisterCount(int channelId,int agentId,int type){return channelMapper.getRegisterCount(channelId,agentId,type);} + + @Override + public int getOrderCount(int channelId,int agentId,int type){return channelMapper.getOrderCount(channelId,agentId,type,1);} + + @Override + public List getAgentRegisterList(int channelId,int type){return channelMapper.getAgentRegisterList(channelId,type,1);} + + @Override + public List getAgentOrderList(int channelId,int type){return channelMapper.getAgentOrderList(channelId,type,1);} + + @Override + public Users getChannelRegister(int channelId,int type){return channelMapper.getChannelRegister(channelId,type,1);} + + @Override + public Users getChannelOrder(int channelId,int type){return channelMapper.getChannelOrder(channelId,type,1);} + + @Override + public List getOrderList(int channelId,int type){return channelMapper.getOrderList(channelId,type,1);} + + @Override + public List getRegisterDetailList(int channelId,int agentId,int type){return channelMapper.getRegisterDetailList(channelId,agentId,type);} + + @Override + public List getOrderDetailList(int channelId,int agentId,int type,int productId){return channelMapper.getOrderDetailList(channelId,agentId,type,productId);} + + @Override + public int insertAccessToken(AccessToken accessToken){return channelMapper.insertAccessToken(accessToken);} + + @Override + public AccessToken getAccessToken(){return channelMapper.getAccessToken();} } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 48b37ad..d1a6229 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -4,9 +4,12 @@ spring: application: name: wechatBusiness datasource: - username: SZJXTUSER - password: xst200919 - url: jdbc:sqlserver://60.190.202.57:14333;database=wechatbusiness +# username: SZJXTUSER +# password: xst200919 +# url: jdbc:sqlserver://60.190.202.57:14333;database=wechatbusiness + username: report + password: QWer123$%^ + url: jdbc:sqlserver://116.62.241.27:33419;database=wechatbusiness driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver jackson: diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 67a3cc4..bd76cd2 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -19,11 +19,11 @@ %d{yyyy-MM-dd HH:mm:ss} -%msg%n - + 1 - ${logPath}/channel/%d{yyyy-MM-dd}.log + ${logPath}/%d{yyyy-MM-dd}.log ${maxHistory} diff --git a/src/main/resources/mapper/CatalogContentMapper.xml b/src/main/resources/mapper/CatalogContentMapper.xml index 613da13..80a3ed2 100644 --- a/src/main/resources/mapper/CatalogContentMapper.xml +++ b/src/main/resources/mapper/CatalogContentMapper.xml @@ -28,8 +28,8 @@ and catalogId=#{catalogId} - - and start_time #{date} and end_time =]]>#{date} + + and start_time #{date1} and end_time =]]>#{date2} order by create_time diff --git a/src/main/resources/mapper/ChannelMapper.xml b/src/main/resources/mapper/ChannelMapper.xml index 50f9aa0..a45db17 100644 --- a/src/main/resources/mapper/ChannelMapper.xml +++ b/src/main/resources/mapper/ChannelMapper.xml @@ -43,6 +43,28 @@ + + + + + + + + + + + + + + + + + + + + + + + select count(0) from report_voluntary.dbo.users + + + and channelId=#{channelId} + + + and agentId=#{agentId} + + + and DateDiff(dd,create_time,getdate())=0 + + + and DateDiff(mm,create_time,getdate())=0 + + + + + + + + + + + + + + + + + + + + + + insert into access_token (access_token) + values (#{accessToken,jdbcType=VARCHAR} + ) + + + \ No newline at end of file -- libgit2 0.21.0