parent
c00b1d5803
commit
53b18f956e
|
@ -74,9 +74,9 @@ document.addEventListener("mouseup", function(e) {
|
|||
xhr.send(JSON.stringify(sendData))
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
// if (xhr.responseText === 'true') {
|
||||
if (xhr.responseText === 'true') {
|
||||
alert('当前授权完成,请直接关闭当前浏览器!')
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(phone !== null && phone !== 'null' ){
|
||||
|
@ -91,9 +91,9 @@ document.addEventListener("mouseup", function(e) {
|
|||
xhr.send(JSON.stringify(sendData))
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
// if (xhr.responseText === 'true') {
|
||||
if (xhr.responseText === 'true') {
|
||||
alert('当前授权完成,请直接关闭当前浏览器!')
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ import com.ruoyi.business.domain.SysCookie;
|
|||
import com.ruoyi.business.mapper.BusOrderInfoMapper;
|
||||
import com.ruoyi.business.service.IBusOrderInfoService;
|
||||
import com.ruoyi.business.service.IMeituanService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -29,20 +31,29 @@ public class MeituanController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/cookies")
|
||||
public R cookie(@RequestBody SysCookie cookie)
|
||||
public String cookie(@RequestBody SysCookie cookie)
|
||||
{
|
||||
R r = iMeituanService.cookieInfo(cookie);
|
||||
iMeituanService.getYestodayCount();
|
||||
return r;
|
||||
return iMeituanService.cookieInfo(cookie);
|
||||
}
|
||||
|
||||
@GetMapping("/refresh")
|
||||
public R refresh(){
|
||||
iMeituanService.getScore();
|
||||
iMeituanService.getComments();
|
||||
iMeituanService.getYestodayCount();
|
||||
iMeituanService.getComments(SecurityUtils.getUsername());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/getComment")
|
||||
public R getComment(Long id){
|
||||
iMeituanService.getComment(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/getReturnInfo")
|
||||
public R getReturnInfo(){
|
||||
iMeituanService.getReturnInfo();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取订单
|
||||
* @return
|
||||
|
@ -77,26 +88,6 @@ public class MeituanController {
|
|||
iMeituanService.priPhoneInfo(list, cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单数和好评(4,5星)数
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getComments")
|
||||
public R comments() {
|
||||
String result = iMeituanService.getComments();
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评分
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getScore")
|
||||
public R score() {
|
||||
String result = iMeituanService.getScore();
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@GetMapping("/getMtgsig")
|
||||
public String mtgsig(String orderId,String regionId,String regionVersion) {
|
||||
return iMeituanService.mtgsigInfo(orderId,regionId,regionVersion);
|
||||
|
|
|
@ -134,8 +134,9 @@ public class SecurityConfig
|
|||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
.antMatchers("/mt/cookies").permitAll()
|
||||
.antMatchers("/test/**").permitAll()
|
||||
.antMatchers(HttpMethod.POST,"/mt/cookies").permitAll()
|
||||
.antMatchers("/test/**").permitAll()
|
||||
// .antMatchers("/mt/**").permitAll()
|
||||
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.business.service;
|
|||
|
||||
import com.ruoyi.business.domain.BusOrderInfo;
|
||||
import com.ruoyi.business.domain.SysCookie;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,7 +13,7 @@ public interface IMeituanService {
|
|||
* @param cookie
|
||||
* @return
|
||||
*/
|
||||
R cookieInfo(SysCookie cookie);
|
||||
String cookieInfo(SysCookie cookie);
|
||||
|
||||
/**
|
||||
* 获取好评及五星
|
||||
|
@ -21,17 +22,10 @@ public interface IMeituanService {
|
|||
String orderInfoList();
|
||||
|
||||
/**
|
||||
* 获取好评及五星
|
||||
* 获取好评及五星 /评分 /昨日单量
|
||||
* @return
|
||||
*/
|
||||
String getComments();
|
||||
String getYestodayCount();
|
||||
|
||||
/**
|
||||
* 获取评分
|
||||
* @return
|
||||
*/
|
||||
String getScore();
|
||||
String getComments(String accountName);
|
||||
|
||||
/**
|
||||
* 获取订单
|
||||
|
@ -61,4 +55,6 @@ public interface IMeituanService {
|
|||
String getStoreName(String cookie);
|
||||
|
||||
void getReturnInfo();
|
||||
|
||||
String getComment(Long id);
|
||||
}
|
||||
|
|
|
@ -7,11 +7,13 @@ import com.ruoyi.business.domain.*;
|
|||
import com.ruoyi.business.mapper.*;
|
||||
import com.ruoyi.business.service.*;
|
||||
import com.ruoyi.common.config.ProxyProperties;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import jdk.nashorn.internal.runtime.logging.Logger;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -41,6 +43,7 @@ import java.io.IOException;
|
|||
import java.net.URLEncoder;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
@ -90,8 +93,11 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R cookieInfo(SysCookie cookie) {
|
||||
public String cookieInfo(SysCookie cookie) {
|
||||
BusStoreInfo storeInfo = new BusStoreInfo();
|
||||
if("".equals(valueFromCookie("wmPoiId", cookie.getCookie()))){
|
||||
return "false";
|
||||
}
|
||||
storeInfo.setStoreCode(valueFromCookie("wmPoiId", cookie.getCookie()));
|
||||
List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(storeInfo);
|
||||
BusAgentInfo busAgentInfo = new BusAgentInfo();
|
||||
|
@ -119,16 +125,6 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
busStoreConfigInfo.setStoreCode(valueFromCookie("wmPoiId", cookie.getCookie()));
|
||||
busStoreConfigInfoMapper.insertBusStoreConfigInfo(busStoreConfigInfo);
|
||||
|
||||
// try {
|
||||
// Thread.sleep(3000);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// getCommentsOne(storeInfo);
|
||||
// getScoreOne(storeInfo);
|
||||
// yesterdayCountOne(storeInfo);
|
||||
|
||||
return R.ok();
|
||||
} else if (list.size() == 1) {
|
||||
// 不同代理人绑定
|
||||
if (!cookie.getUserName().equals(list.get(0).getBindUser())) {
|
||||
|
@ -164,44 +160,42 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
storeInfo.setStoreCookie(cookie.getCookie());
|
||||
storeInfo.setGrantStatus("1");//授权登录状态
|
||||
}
|
||||
return R.ok(busStoreInfoService.updateBusStoreInfo(storeInfo));
|
||||
busStoreInfoService.updateBusStoreInfo(storeInfo);
|
||||
} else {
|
||||
throw new ServiceException("授权失败,请重试!");
|
||||
}
|
||||
// 触发爬取店铺信息
|
||||
getCommentsOne(storeInfo);
|
||||
getScoreOne(storeInfo);
|
||||
yesterdayCountOne(storeInfo);
|
||||
return "true";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取好评批量
|
||||
* 批量 获取昨日评分、好评、有效单量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String getComments() {
|
||||
public String getComments(String accountName) {
|
||||
BusStoreInfo busStoreInfo = new BusStoreInfo();
|
||||
busStoreInfo.setReturnVisitStatus("1");
|
||||
busStoreInfo.setBindUser(SecurityUtils.getUsername());
|
||||
busStoreInfo.setGrantStatus("1");
|
||||
if(accountName != null){
|
||||
busStoreInfo.setBindUser(SecurityUtils.getUsername());
|
||||
}
|
||||
List<BusStoreInfo> busStoreInfoList = busStoreInfoMapper.selectBusStoreInfoList(busStoreInfo);
|
||||
for (BusStoreInfo store : busStoreInfoList) {
|
||||
Boolean flag = getCommentsOne(store);
|
||||
if (!flag) {
|
||||
Boolean flag1 = getScoreOne(store);
|
||||
if (!flag1) {
|
||||
System.out.println("获取评分信息返回错误...");
|
||||
}
|
||||
Boolean flag2 = getCommentsOne(store);
|
||||
if (!flag2) {
|
||||
System.out.println("获取好评信息返回错误...");
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String getYestodayCount() {
|
||||
BusStoreInfo busStoreInfo = new BusStoreInfo();
|
||||
busStoreInfo.setReturnVisitStatus("1");
|
||||
busStoreInfo.setBindUser(SecurityUtils.getUsername());
|
||||
List<BusStoreInfo> busStoreInfoList = busStoreInfoMapper.selectBusStoreInfoList(busStoreInfo);
|
||||
for (BusStoreInfo store : busStoreInfoList) {
|
||||
Boolean flag = yesterdayCountOne(store);
|
||||
if (!flag) {
|
||||
Boolean flag3 = yesterdayCountOne(store);
|
||||
if (!flag3) {
|
||||
System.out.println("获取昨日统计信息返回错误...");
|
||||
}
|
||||
}
|
||||
|
@ -209,26 +203,28 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取评分批量
|
||||
* 获取昨日评分、好评、有效单量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String getScore() {
|
||||
BusStoreInfo busStoreInfo = new BusStoreInfo();
|
||||
busStoreInfo.setReturnVisitStatus("1");
|
||||
busStoreInfo.setBindUser(SecurityUtils.getUsername());
|
||||
List<BusStoreInfo> busStoreInfoList = busStoreInfoMapper.selectBusStoreInfoList(busStoreInfo);
|
||||
for (BusStoreInfo store : busStoreInfoList) {
|
||||
Boolean flag = getScoreOne(store);
|
||||
if (!flag) {
|
||||
System.out.println("获取评分信息返回错误...");
|
||||
}
|
||||
public String getComment(Long id) {
|
||||
BusStoreInfo store = busStoreInfoMapper.selectBusStoreInfoById(id);
|
||||
Boolean flag1 = getScoreOne(store);
|
||||
if (!flag1) {
|
||||
System.out.println("获取评分信息返回错误...");
|
||||
}
|
||||
Boolean flag2 = getCommentsOne(store);
|
||||
if (!flag2) {
|
||||
System.out.println("获取好评信息返回错误...");
|
||||
}
|
||||
Boolean flag3 = yesterdayCountOne(store);
|
||||
if (!flag3) {
|
||||
System.out.println("获取昨日统计信息返回错误...");
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单批量
|
||||
*
|
||||
|
@ -256,49 +252,57 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
* @return
|
||||
*/
|
||||
public boolean yesterdayCountOne(BusStoreInfo storeInfo){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
CloseableHttpClient httpClient = proxyHttpClient();
|
||||
String wmPoiId = valueFromCookie("wmPoiId", storeInfo.getStoreCookie());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH,-1);
|
||||
Date minusDay = calendar.getTime();
|
||||
String date = sdf.format(minusDay);
|
||||
JSONObject jsonObject = merchantOrders(1, date, storeInfo.getStoreCookie());
|
||||
String code = jsonObject.getString("code");
|
||||
if ("0".equals(code)) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String total = data.getString("totalCount");
|
||||
|
||||
// JSONArray array = jsonObject.getJSONObject("data").getJSONArray("wmOrderList");
|
||||
// Object o = array.get(0);
|
||||
// JSONObject oj = JSONObject.parseObject(JSON.toJSONString(o));
|
||||
// JSONObject order0 = oj.getJSONObject("orderInfo");
|
||||
// JSONObject order1 = order0.getJSONObject("orderInfo");
|
||||
//// JSONObject tipInfoVo = order1.getJSONObject("tipInfoVo");
|
||||
// String poiName = order1.getString("poiName");
|
||||
// if (storeInfo.getStoreName() == null) {
|
||||
// storeInfo.setStoreName(poiName);
|
||||
// busStoreInfoService.updateBusStoreInfo(storeInfo);
|
||||
// }
|
||||
|
||||
BusStoreInfo store = new BusStoreInfo();
|
||||
store.setStoreCode(wmPoiId);
|
||||
List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(store);
|
||||
if (list.size() > 0) {
|
||||
BusStoreDayInfo dayInfo = new BusStoreDayInfo();
|
||||
dayInfo.setStoreId(list.get(0).getId());
|
||||
List<BusStoreDayInfo> list1 = busStoreDayInfoService.selectBusStoreDayInfoList(dayInfo);
|
||||
if (list1.size() > 0) {
|
||||
BusStoreDayInfo temp = list1.get(0);
|
||||
temp.setLastOrderNum(Integer.valueOf(total));
|
||||
busStoreDayInfoService.updateBusStoreDayInfo(temp);
|
||||
} else {
|
||||
dayInfo.setLastOrderNum(Integer.valueOf(total));
|
||||
busStoreDayInfoService.insertBusStoreDayInfo(dayInfo);
|
||||
String url = "https://waimaieapp.meituan.com/gw/bizdata/marketing/single/analysis";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
// params.put("ignoreSetRouterProxy", true);
|
||||
// params.put("acctId", valueFromCookie("acctId", storeInfo.getStoreCookie()));
|
||||
params.put("wmPoiId", wmPoiId);
|
||||
params.put("token", valueFromCookie("token", storeInfo.getStoreCookie()));
|
||||
params.put("appType", 3);
|
||||
String date = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
params.put("beginDate", date);
|
||||
params.put("endDate", date);
|
||||
url = appendParams(url, params);
|
||||
HttpGet request = new HttpGet(url);
|
||||
request.setHeader("Cookie",storeInfo.getStoreCookie());
|
||||
String result = null;
|
||||
try {
|
||||
result = EntityUtils.toString(httpClient.execute(request).getEntity());
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
if (result != null) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String code = jsonObject.getString("code");
|
||||
if ("0".equals(code)) {
|
||||
JSONArray array = jsonObject.getJSONArray("data");
|
||||
JSONObject one = array.getJSONObject(0);
|
||||
String total = one.getString("base");
|
||||
System.out.println(total);
|
||||
BusStoreInfo store = new BusStoreInfo();
|
||||
store.setStoreCode(wmPoiId);
|
||||
List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(store);
|
||||
if (list.size() > 0) {
|
||||
BusStoreDayInfo dayInfo = new BusStoreDayInfo();
|
||||
dayInfo.setStoreId(list.get(0).getId());
|
||||
List<BusStoreDayInfo> list1 = busStoreDayInfoService.selectBusStoreDayInfoList(dayInfo);
|
||||
if (list1.size() > 0) {
|
||||
BusStoreDayInfo temp = list1.get(0);
|
||||
temp.setLastOrderNum(Integer.valueOf(total));
|
||||
busStoreDayInfoService.updateBusStoreDayInfo(temp);
|
||||
} else {
|
||||
dayInfo.setLastOrderNum(Integer.valueOf(total));
|
||||
busStoreDayInfoService.insertBusStoreDayInfo(dayInfo);
|
||||
}
|
||||
}
|
||||
} else if ("1001".equals(code)) {
|
||||
storeInfo.setGrantStatus("2");
|
||||
busStoreInfoService.updateBusStoreInfo(storeInfo);
|
||||
}
|
||||
} else if ("1001".equals(code)) {
|
||||
storeInfo.setGrantStatus("2");
|
||||
busStoreInfoService.updateBusStoreInfo(storeInfo);
|
||||
}
|
||||
// System.out.println(jsonObject);
|
||||
return true;
|
||||
|
@ -646,9 +650,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
|
||||
@Override
|
||||
public void getReturnInfo() {
|
||||
getScore();
|
||||
getComments();
|
||||
getYestodayCount();
|
||||
getComments(null);
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDateTime date = LocalDateTime.now().minusDays(1);
|
||||
BusStoreInfo storeInfo = new BusStoreInfo();
|
||||
|
|
|
@ -74,13 +74,21 @@ export function updateStoreConfig(data) {
|
|||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 一键更新 - 当前人 在线的店铺
|
||||
export function refresh() {
|
||||
return request({
|
||||
url: '/mt/refresh',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
// 更新一个店铺
|
||||
export function refresh(id) {
|
||||
return request({
|
||||
url: '/mt/getComment/'+id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getStoreStatistics() {
|
||||
return request({
|
||||
url: '/business/store/getStoreStatistics',
|
||||
|
|
Loading…
Reference in New Issue