Commit 8b3b5f3d authored by renjie's avatar renjie

Merge branch 'dev-zrj' into 'staging'

店铺bug

See merge request !78
parents 80bc9bc1 fcabddd9
......@@ -365,7 +365,7 @@ public class PaymentServiceImpl implements PaymentService {
public String alipayPutPayOrder(String username, int amount, String by) {
Account byName = accountService.findByName(username);
if (byName == null)
if (byName == null || byName.getPermission() < 8)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "account does not exist: " + username);
boolean isVpsClient = true;
......@@ -418,7 +418,7 @@ public class PaymentServiceImpl implements PaymentService {
public UserPaymentDto wxPutPayOrder(String username, int amount) {
Account byName = accountService.findByName(username);
if (byName == null)
if (byName == null || byName.getPermission() < 8)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "account does not exist: " + username);
boolean isVpsClient = true;
......
......@@ -100,9 +100,11 @@ public class ShopServiceImpl implements ShopService {
}
userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
UserShop userShop1 = new UserShop();
userShop1.setUsername(account.getParent());
userShop1.setShopId(id);
userShop1.setGroupId("-1");
userShopRepository.save(userShop1);
}
//可以优化
account.setShopCount(account.getShopCount() + 1);
......@@ -161,9 +163,11 @@ public class ShopServiceImpl implements ShopService {
}
userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
UserShop userShop1 = new UserShop();
userShop1.setUsername(account.getParent());
userShop1.setShopId(id);
userShop1.setGroupId("-1");
userShopRepository.save(userShop1);
}
//可以优化
account.setShopCount(account.getShopCount() + 1);
......
package com.edgec.browserbackend.common.utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Trans {
private final Logger logger = LoggerFactory.getLogger(Trans.class);
static int timeout = 10 * 1000;// 以秒为单位
private static String specialHost = "39.108.183.128";//117.177.243.7
private static int specialPort = 20008;
private String host;
private int port;
private String username;
private String password;
public Trans(String host, int port, String username, String password) {
this.host = host;
this.port = port;
this.password = password;
this.username = username;
}
/**
* 主入口方法
* @param args
*/
public static void main(String[] args) {
String url = "http://pv.sohu.com/cityjson";
Trans trans = new Trans("120.76.135.212", 20001, "fangguanlianbrowser", "2rbvtg9GQ1JraA1");
String result = trans.get(url, false);
System.out.println(result);
}
public HttpClient getHttpClient() {
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().setCredentials(
new AuthScope(host, port),
new UsernamePasswordCredentials(username, password));
HttpHost proxy = new HttpHost(host,port);
httpClient.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy);
return httpClient;
}
/**
* 向指定URL发送GET方法的请求
*/
public String get(String url, boolean special) {
StringBuffer sb = new StringBuffer();
//创建HttpClient实例
HttpClient client = this.getHttpClient();
//创建httpGet
HttpGet httpGet = new HttpGet("http://pv.sohu.com/cityjson");
//执行
try {
HttpResponse response = client.execute(httpGet);
HttpEntity entry = response.getEntity();
if(entry != null)
{
InputStreamReader is = new InputStreamReader(entry.getContent());
BufferedReader br = new BufferedReader(is);
String str = null;
while((str = br.readLine()) != null)
{
sb.append(str.trim());
}
br.close();
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
logger.error(e.getMessage(), e);
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error(e.getMessage(), e);
}
System.out.println(sb.toString());
return sb.toString();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment