提交 e60c245d authored 作者: zgy's avatar zgy

修改bug

上级 2318bb9c
......@@ -36,4 +36,6 @@ public class KeyConstant {
public final static String SHOPIFY_ITEM = "shopify_item";
//商品类型
public final static String SHOPIFY_TYPE = "shopify_item";
//所有商品
public final static String SHOPIFY_ITEMS_ALL = "shopify_item_all";
}
......@@ -45,15 +45,15 @@ public class LoginController extends BaseController {
@ApiOperation(value = "注册并登录")
@PostMapping(value = "/registerByPhone")
public Result<TbCfUserInfoVo> registerByPhone(@ApiParam("用户信息") @RequestBody TbCfUserInfoVo tbCfUserInfoVo,@ApiParam(value = "验证码") @RequestParam("code") String code) throws ParseException{
return tbCfUserInfoService.registerByPhone(tbCfUserInfoVo,code);
public Result<TbCfUserInfoVo> registerByPhone(@ApiParam("用户信息") @RequestBody TbCfUserInfoVo tbCfUserInfoVo, @ApiParam(value = "验证码") @RequestParam("code") String code) throws ParseException {
return tbCfUserInfoService.registerByPhone(tbCfUserInfoVo, code);
}
@ApiOperation("登录")
@PostMapping
public Result<TbCfUserInfoVo> login(@ApiParam(value = "登录名")String account,
@ApiParam(value = "密码") String password) {
return tbCfUserInfoService.login(getIpAddr(request), account,password);
public Result<TbCfUserInfoVo> login(@ApiParam(value = "登录名") @ValidateParam({Validator.NOT_BLANK}) String account,
@ApiParam(value = "密码") @ValidateParam({Validator.NOT_BLANK}) String password) {
return tbCfUserInfoService.login(getIpAddr(request), account, password);
}
@ApiOperation("使用token登录")
......@@ -65,12 +65,12 @@ public class LoginController extends BaseController {
@ApiOperation("使用手机号登录")
@GetMapping("/phone")
public Result<TbCfUserInfoVo> loginByPhone(@ApiParam(value = "手机号") @RequestParam("phone") String phone,
@ApiParam(value = "验证码") @RequestParam("code") String code){
return tbCfUserInfoService.loginByPhone(getIpAddr(request),phone,code);
@ApiParam(value = "验证码") @RequestParam("code") String code) {
return tbCfUserInfoService.loginByPhone(getIpAddr(request), phone, code);
}
/**
* 获取短信验证码
*
*/
@ApiOperation(value = "获取短信验证码")
@GetMapping(value = "/register/identifyCode/{phone}")
......@@ -86,6 +86,6 @@ public class LoginController extends BaseController {
public Result<TbCfUserInfoVo> loginByThirdParty(@ApiParam("第三方账号") @RequestParam(required = false) String amount,
@ApiParam("用户昵称 url编码") @RequestParam(required = false) String nick,
@ApiParam("账号类型") @RequestParam(required = false) String userType) throws UnsupportedEncodingException {
return tbCfUserInfoService.loginByThirdParty(getIpAddr(request),amount,nick,userType);
return tbCfUserInfoService.loginByThirdParty(getIpAddr(request), amount, nick, userType);
}
}
......@@ -69,6 +69,19 @@ public class ShopifyController {
return shopifyService.queryProductsDetails(product_id);
}
/**
* 查询所有商品
*
* @param product_id 商品ID
* @return
*/
@ApiOperation(value = "查询所有商品")
@GetMapping("/queryallproducts")
public Result queryAllProducts(@ApiParam("商品ID") @RequestParam(value = "product_id", required = false) String product_id) {
return shopifyService.queryAllProducts(product_id);
}
/**
* 查询商品最新一条评论
*
......
......@@ -31,15 +31,15 @@ public class TbCfOrderController {
@ApiOperation("用户结算,返回订单")
@GetMapping("/settle")
public Result<TbCfOrderVo> settleAccount(@ApiParam("发放ID") @RequestParam(value = "iss_coupon_id",required = false) String iss_coupon_id) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
public Result<TbCfOrderVo> settleAccount(@ApiParam("发放ID") @RequestParam(value = "iss_coupon_id", required = false) String iss_coupon_id) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
return tbCfOrderService.settleAccount(iss_coupon_id);
}
@ApiOperation("用户确定下单")
@PostMapping("/place")
public Result placeOrder(@ApiParam("订单详情") @RequestBody TbCfOrderVo tbCfOrderVo,@ApiParam("发放ID") @RequestParam(value = "iss_coupon_id",required = false) String iss_coupon_id) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
System.out.println("发放Id"+iss_coupon_id);
return tbCfOrderService.placeOrder(tbCfOrderVo,iss_coupon_id);
public Result placeOrder(@ApiParam("订单详情") @RequestBody TbCfOrderVo tbCfOrderVo, @ApiParam("发放ID") @RequestParam(value = "iss_coupon_id", required = false) String iss_coupon_id) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
System.out.println("发放Id" + iss_coupon_id);
return tbCfOrderService.placeOrder(tbCfOrderVo, iss_coupon_id);
}
/**
......@@ -48,16 +48,17 @@ public class TbCfOrderController {
*/
@ApiOperation("获取用户订单 默认10条")
@GetMapping
public Result<PageInfo> getUserOrderList(@ApiParam(value = "页数") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小") @RequestParam(required = false) Integer pageSize,
@ApiParam(value = "订单状态") @RequestParam(required = false)Integer orderStatus) {
public Result<PageInfo> getUserOrderList(@ApiParam(value = "页数") @RequestParam(value = "pageNum", required = false) Integer pageNum,
@ApiParam(value = "每页大小") @RequestParam(value = "pageSize", required = false) Integer pageSize,
@ApiParam(value = "订单状态") @RequestParam(value = "orderStatus", required = false) Integer orderStatus,
@ApiParam(value = "订单状态") @RequestParam(value = "userId") String userId) {
if (pageNum == null) {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 10;
}
return tbCfOrderService.getUserOrderList(pageNum, pageSize,orderStatus);
return tbCfOrderService.getUserOrderList(pageNum, pageSize, orderStatus, userId);
}
@ApiOperation("获取stripe公钥")
......@@ -68,13 +69,13 @@ public class TbCfOrderController {
@ApiOperation("发起订单支付")
@PostMapping("/pay/{orderId}/{token}")
public Result payForOrder(@ApiParam("订单id")@PathVariable("orderId")String orderId,@ApiParam("支付token")@PathVariable("token")String token) {
return tbCfOrderService.payForOrder(orderId,token);
public Result payForOrder(@ApiParam("订单id") @PathVariable("orderId") String orderId, @ApiParam("支付token") @PathVariable("token") String token) {
return tbCfOrderService.payForOrder(orderId, token);
}
@ApiOperation("根据订单id,查询物流详情")
@GetMapping("/express/{orderId}")
public Result queryOrderExpressInfo(@ApiParam("订单id")@PathVariable String orderId) throws IOException {
public Result queryOrderExpressInfo(@ApiParam("订单id") @PathVariable String orderId) throws IOException {
return tbCfOrderService.queryOrderExpressInfo(orderId);
}
......@@ -88,8 +89,8 @@ public class TbCfOrderController {
* 根据订单号获取详细订单数据
*/
@ApiOperation(value = "根据订单号获取详细订单数据")
@GetMapping(value ="/detail/{orderId}")
public Result getOrderDetail(@PathVariable("orderId")String orderId) {
@GetMapping(value = "/detail/{orderId}")
public Result getOrderDetail(@PathVariable("orderId") String orderId) {
return tbCfOrderService.getOrderDetail(orderId);
}
}
......@@ -14,4 +14,5 @@ public interface ShopifyService {
public Result queryShopifyProducts();
public Result queryProductsByType(String product_type,String product_id);
public Result queryProductsDetails(String product_id);
public Result queryAllProducts(String product_id);
}
......@@ -95,7 +95,7 @@ public interface TbCfOrderService {
* @param orderStatus 订单状态 OrderStatusEnum
* @return
*/
Result getUserOrderList(Integer pageNum, Integer pageSize,Integer orderStatus);
Result getUserOrderList(Integer pageNum, Integer pageSize,Integer orderStatus,String userId);
/**
* 取消订单
......
......@@ -15,10 +15,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
......@@ -29,6 +26,7 @@ import java.util.Map;
@Service("shopifyService")
public class ShopifyServiceImpl implements ShopifyService {
private static Logger logger = LoggerFactory.getLogger(ShopifyServiceImpl.class);
@Resource
private RedisCache<Object> redisCache;
......@@ -39,26 +37,28 @@ public class ShopifyServiceImpl implements ShopifyService {
*/
@Override
public Result queryShopifyProducts() {
List type = Arrays.asList("Christmas", "Men", "Women", "Face", "virgin hair", "Afri Home", "Children");
Result result = new Result();
Map<String, Object> params = new HashMap<>();
List<String> list = new ArrayList();
try {
List products = (List) redisCache.get(KeyConstant.SHOPIFY_ITEMS);
if (products != null) {
if (products != null && products.size() == type.size()) {
JSONArray jsonArray = JSONArray.fromObject(products);
result.setData(jsonArray);
return result;
}
List type = (List) redisCache.get(KeyConstant.SHOPIFY_TYPE);
if (type == null) {
type = getProductType();
}
// List type = (List) redisCache.get(KeyConstant.SHOPIFY_TYPE);
// if (type == null) {
// type = getProductType();
// }
for (int i = 0; i < type.size(); i++) {
params.put("product_type", type.get(i));
params.put("limit", ShopifyConstant.SHOPIFY_LIMIT);
String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
list.add(data);
redisCache.set(KeyConstant.SHOPIFY_ITEMS, list);
redisCache.set(KeyConstant.SHOPIFY_ITEMS, list, 86400);
}
System.out.println(list);
JSONArray jsonArr = JSONArray.fromObject(list);
......@@ -80,7 +80,7 @@ public class ShopifyServiceImpl implements ShopifyService {
@Override
public Result queryProductsByType(String product_type, String product_id) {
Result result = new Result();
String typeProducts = (String) redisCache.get(KeyConstant.SHOPIFY_TYPE_ITEMS + product_id);
String typeProducts = (String) redisCache.get(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id);
if (typeProducts != null) {
JSONObject object = JSONObject.fromObject(typeProducts);
result.setData(object);
......@@ -88,13 +88,13 @@ public class ShopifyServiceImpl implements ShopifyService {
}
Map<String, Object> params = new HashMap<>();
params.put("product_type", product_type);
params.put("limit", ShopifyConstant.SHOPIFY_PAGE_SIZE);
params.put("limit", /*ShopifyConstant.SHOPIFY_PAGE_SIZE*/ "250");
params.put("since_id", product_id);
try {
String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
JSONObject jsonObject = JSONObject.fromObject(data);
result.setData(jsonObject);
redisCache.set(KeyConstant.SHOPIFY_TYPE_ITEMS + product_id, data);
//redisCache.set(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id, data, 86400);
} catch (IOException e) {
result.setCode(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage(e.getMessage());
logger.error(e.getMessage(), e);
......@@ -122,7 +122,7 @@ public class ShopifyServiceImpl implements ShopifyService {
params.put("ids", product_id);
String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
jsonProduct = JSONObject.fromObject(data);
redisCache.set(KeyConstant.SHOPIFY_ITEM + product_id, data);
redisCache.set(KeyConstant.SHOPIFY_ITEM + product_id, data, 86400);
}
result.setData(jsonProduct);
} catch (IOException e) {
......@@ -133,6 +133,38 @@ public class ShopifyServiceImpl implements ShopifyService {
return result;
}
/**
* 查询所有商品
*
* @param product_id
* @return
*/
public Result queryAllProducts(String product_id) {
Result result = new Result();
try {
JSONObject jsonObject = null;
String allProducts = (String) redisCache.get(KeyConstant.SHOPIFY_ITEMS_ALL + product_id);
if (allProducts != null) {
jsonObject = JSONObject.fromObject(allProducts);
result.setData(jsonObject);
return result;
}
Map<String, Object> params = new HashMap<>();
params.put("limit", ShopifyConstant.SHOPIFY_PAGE_SIZE);
params.put("since_id", product_id);
String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
redisCache.set(KeyConstant.SHOPIFY_ITEMS_ALL + product_id, data);
jsonObject = JSONObject.fromObject(data);
result.setData(jsonObject);
} catch (Exception e) {
result.setCode(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage(e.getMessage());
logger.error(e.getMessage(), e);
return result;
}
return result;
}
/**
* 查询所有商品分类
*
......@@ -155,4 +187,6 @@ public class ShopifyServiceImpl implements ShopifyService {
redisCache.set(KeyConstant.SHOPIFY_TYPE, list);
return list;
}
}
......@@ -81,13 +81,13 @@ public class JwtTokenProvider {
public boolean validateToken(String token) {
try {
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
TbCfUserInfoVo loginUser=tokenManager.validate(token);
if(loginUser==null) {
throw new ApplicationException(ResultCodeEnum.NEED_LOGIN.getCode(),"Expired or invalid JWT token");
TbCfUserInfoVo loginUser = tokenManager.validate(token);
if (loginUser == null) {
throw new ApplicationException(ResultCodeEnum.NEED_LOGIN.getCode(), "Expired or invalid JWT token");
}
return true;
} catch (JwtException | IllegalArgumentException e) {
throw new ApplicationException(ResultCodeEnum.NEED_LOGIN.getCode(),"Expired or invalid JWT token");
throw new ApplicationException(ResultCodeEnum.NEED_LOGIN.getCode(), "Expired or invalid JWT token");
}
}
......
......@@ -42,6 +42,7 @@ public class PayTest {
}
}
System.out.println(list);
}
@Test
......@@ -84,9 +85,9 @@ public class PayTest {
}
@Test
public void test3(){
Integer count=0;
while (count<4){
public void test3() {
Integer count = 0;
while (count < 4) {
System.out.println("helloworld!");
count++;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论