Authored by mali

Merge branch 'dev'

package com.yohoufo.common.utils;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public final class UfoStringUtils extends org.apache.commons.lang3.StringUtils{
/**
... ... @@ -145,5 +148,13 @@ public final class UfoStringUtils extends org.apache.commons.lang3.StringUtils{
return password.matches(reg);
}
public static List<Integer> string2IntegerList(String str) {
if (StringUtils.isNotBlank(str)) {
List<Integer> list = Arrays.stream(str.split(",")).map(e -> parseInt(e)).filter(Objects::nonNull).collect(Collectors.toList());
return list;
}
return Collections.emptyList();
}
}
... ...
... ... @@ -13,4 +13,6 @@ public interface BrandSeriesMapper {
List<BrandSeries> selectAll();
int updateByPrimaryKey(BrandSeries record);
List<BrandSeries> selectByIds(List<Integer> ids);
}
\ No newline at end of file
... ...
... ... @@ -15,4 +15,6 @@ public interface GoodsMapper {
int updateByPrimaryKey(Goods record);
List<Goods> selectByProductId(Integer productId);
List<Goods> selectByProductIds(List<Integer> productIds);
}
\ No newline at end of file
... ...
... ... @@ -13,4 +13,6 @@ public interface ProductMapper {
List<Product> selectAll();
int updateByPrimaryKey(Product record);
List<Product> selectByIds(List<Integer> ids);
}
\ No newline at end of file
... ...
... ... @@ -41,4 +41,13 @@
select id, series_name, series_search, status, create_time, update_time, brand_id
from brand_series
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select id, series_name
from brand_series
where status = 1 and id IN
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -45,4 +45,12 @@
select id, product_id, color_name, goods_name
from goods where product_id = #{productId,jdbcType=INTEGER}
</select>
<select id="selectByProductIds" resultType="com.yohoufo.dal.product.model.Goods">
select id, product_id, color_image
from goods where product_id IN
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -77,4 +77,11 @@
storage, key_words, del_status
from product
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select id, series_id from product where id in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -70,7 +70,7 @@
where skup = #{skup,jdbcType=INTEGER} and status = 2
</update>
<select id="selectLeastPrice" resultMap="BaseResultMap">
select MIN(price) price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1
select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 order by price limit 1
</select>
<select id="selectByStorageIds" resultMap="BaseResultMap">
select id, skup, storage_id, price, status
... ...
... ... @@ -9,6 +9,10 @@ public enum ButtonShow {
BUY_AGAIN("buy_again", "再次购买"),
DEL_ORDER("del_order", "删除"),
SHOW_EXPRESS("show_express", "查看物流"),
/*卖家相关*/
PAY_EARNESTMONEY("pay_earnestMoney","支付保证金"),
NOT_SOLD("not_sold","不卖了"),
DELIVER_GOODS("deliver_goods","我要发货")
;
String code;
... ...
... ... @@ -4,24 +4,27 @@ package com.yohoufo.order.common;
public enum SellerOrderStatus {
WAITING_PAY(0, "待付保证金"),
SELLER_CANCEL_PAY(1, "上架关闭(卖家取消支付)"),
SELLER_CANCEL_TIMEOUT(2, "上架关闭(卖家支付超时)"),
HAS_PAYED(3, "已支付"),
SELLER_CANCEL_SELL(4, "上架关闭(卖家取消出售)"),
BACKGROUNP_CANCEL_SELL(5, "上架关闭(平台取消出售)"),
HAS_SELLED(6, "已售出");
WAITING_PAY(0, "待付保证金", new ButtonShow[]{ButtonShow.PAY_EARNESTMONEY,ButtonShow.NOT_SOLD}),
SELLER_CANCEL_PAY(1, "上架关闭(卖家取消支付)", new ButtonShow[]{ButtonShow.SHOW_DETAIL}),
SELLER_CANCEL_TIMEOUT(2, "上架关闭(卖家支付超时)", new ButtonShow[]{ButtonShow.SHOW_DETAIL}),
HAS_PAYED(3, "已支付", new ButtonShow[]{ButtonShow.SHOW_DETAIL, ButtonShow.DELIVER_GOODS, ButtonShow.NOT_SOLD}),
SELLER_CANCEL_SELL(4, "上架关闭(卖家取消出售)", new ButtonShow[]{ButtonShow.SHOW_DETAIL}),
BACKGROUNP_CANCEL_SELL(5, "上架关闭(平台取消出售)", new ButtonShow[]{ButtonShow.SHOW_DETAIL}),
HAS_SELLED(6, "已售出", new ButtonShow[]{ButtonShow.SHOW_DETAIL});
SellerOrderStatus(int code, String desc) {
SellerOrderStatus(int code, String desc, ButtonShow[] buttonShows) {
this.code = code;
this.desc = desc;
this.buttonShows = buttonShows;
}
int code;
String desc;
ButtonShow[] buttonShows;
public String getDesc() {
return desc;
}
... ...
... ... @@ -2,9 +2,11 @@ package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderListReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.response.OrderInfoListRsp;
import com.yohoufo.order.service.SellerOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -51,11 +53,7 @@ public class SellerOrderController {
* @param uid
* @param storage_id
* @param price
* @param consignee
* @param address_id
* @param address
* @param zipCode
* @param phone
* @return
* @throws GatewayException
*/
... ... @@ -75,4 +73,21 @@ public class SellerOrderController {
Long orderCode = sellerOrderService.publishPrd(req);
return new ApiResponse.ApiResponseBuilder().data(orderCode).code(200).message("发布成功").build();
}
@RequestMapping(params = "method=ufo.sellerOrder.publishPrd")
@ResponseBody
public ApiResponse getOrderList(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "status", required = true)int status,
@RequestParam(name = "page", required = true)int page,
@RequestParam(name = "limit", required = true)int limit) throws GatewayException {
SellerOrderListReq req = SellerOrderListReq.builder()
.uid(uid).status(status)
.page(page).limit(limit)
.build();
logger.info("in ufo.sellerOrder.publishPrd, req {}", req);
OrderInfoListRsp resp = sellerOrderService.getOrderList(req);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("查询列表成功").build();
}
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yoho.service.model.response.UserAddressRspBO;
import com.yohobuy.ufo.model.order.bo.PlatformFee;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderListReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.exception.GatewayException;
... ... @@ -17,6 +18,7 @@ import com.yohoufo.order.model.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.response.OrderInfoListRsp;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.proxy.UserProxyService;
... ... @@ -148,6 +150,12 @@ public class SellerOrderService {
return orderCode;
}
public OrderInfoListRsp getOrderList(SellerOrderListReq req){
return null;
}
private GoodsInfo getProductDetail(SellerOrderContext context){
int uid = context.getUid();
int storageId = context.getStorageId();
... ...
... ... @@ -46,10 +46,10 @@ public class ProductController {
@RequestMapping(params = "method=ufo.product.data")
@Cachable(expire=600)
public ApiResponse queryProductDetailById(
@RequestParam(value = "product_id", required = false) Integer productId) {
@RequestParam(value = "product_id", required = true) Integer productId) {
if (null == productId) {
return new ApiResponse(500, "product_id Is Null", null);
return new ApiResponse(400, "product_id Is Null", null);
}
ProductDetailResp resp = productService.queryProductDetailById(productId);
... ...
... ... @@ -6,8 +6,6 @@ import com.alibaba.fastjson.annotation.JSONField;
public class ProductSeriesTemplate {
@JSONField(name = "product_id")
private String productId;
@JSONField(name = "image_url")
private String imageUrl;
@JSONField(name = "series_id")
... ... @@ -15,14 +13,6 @@ public class ProductSeriesTemplate {
@JSONField(name = "series_name")
private String seriesName;
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getImageUrl() {
return imageUrl;
}
... ...
... ... @@ -4,11 +4,10 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import com.yoho.core.common.helpers.ImagesHelper;
import com.yohoufo.common.utils.UfoStringUtils;
import com.yohoufo.dal.product.*;
import com.yohoufo.dal.product.model.*;
import com.yohoufo.product.model.GoodsImageBO;
... ... @@ -143,8 +142,21 @@ public class ProductServiceImpl implements ProductService{
public ProductSeriesTemplateResp querySortTemplateData(String skns) {
ProductSeriesTemplateResp resp = new ProductSeriesTemplateResp();
List<Integer> sknlist = UfoStringUtils.string2IntegerList(skns);
List<String> sknlist = Lists.newArrayList(skns.split(","));
if (!CollectionUtils.isEmpty(sknlist)) {
List<Product> products = productMapper.selectByIds(sknlist);
if (!CollectionUtils.isEmpty(products)) {
List<Integer> seriesIds = products.stream().map(Product::getSeriesId).filter(Objects::nonNull).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(seriesIds)) {
List<BrandSeries> seriesList = brandSeriesMapper.selectByIds(seriesIds);
}
List<Goods> goodsList = goodsMapper.selectByProductIds(sknlist);
}
}
return null;
}
... ... @@ -316,7 +328,7 @@ public class ProductServiceImpl implements ProductService{
List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodId);
List<GoodsImageBO> imageList = new ArrayList<>();
if (!CollectionUtils.isEmpty(goodsImages)) {
List<String> imageUrlList = goodsImages.stream().map(GoodsImages::getImageUrl).filter(StringUtils::isNotBlank).map(this::buildImageFullUrl).collect(Collectors.toList());
List<String> imageUrlList = goodsImages.stream().map(GoodsImages::getImageUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList());
imageUrlList.forEach(e -> imageList.add(GoodsImageBO.create(e)));
}
goodsBO.setImageList(imageList);
... ...
package com.yohoufo.user.cache;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
public class CacheHelper {
/**
* 序列化value值
* @param value
* @return
*/
public static <T> String value2String(T value) {
String v = null;
if (value == null) {
return null;
}
if (value instanceof String) {
v = (String) value;
} else {
v = JSON.toJSONString(value);
}
return v;
}
/**
* 反序列化value值
*
* @param value
* @param clazz
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T string2Value(String value, Class<T> clazz) {
if (StringUtils.isEmpty(value)) {
return null;
}
if (clazz.getName().equalsIgnoreCase("java.lang.String")) {
return (T) value;
}
return (T) JSON.parseObject(value, clazz);
}
}
... ...
... ... @@ -43,10 +43,40 @@ public class RedisValueCache {
}
/**
* 设置值
*
* @param cacheKey
* @param value
* @param timeout
* @param unit
* @param <T>
*/
public <T> void set(RedisKeyBuilder cacheKey, T value, long timeout, TimeUnit unit) {
logger.debug("Enter set valueOperation redis value.key is {},value is {}", cacheKey, value);
try {
String v = CacheHelper.value2String(value);
yhValueOperations.set(cacheKey, v, timeout, unit);
} catch (Exception e) {
logger.warn("Redis exception. value redis set,key {},value is {}, error msg is {}", cacheKey, value, e);
}
}
/**
* 取值
*
* @param cacheKey
* @param clazz
*/
public <T> T get(RedisKeyBuilder cacheKey, Class<T> clazz) {
logger.debug("Enter get valueOperation redis value.key is {}", cacheKey);
try {
String value = yhValueOperations.get(cacheKey);
return CacheHelper.string2Value(value, clazz);
} catch (Exception e) {
logger.warn("Redis exception. value redis get,key {}, error msg is {}", cacheKey, e);
}
return null;
}
}
... ...
... ... @@ -48,6 +48,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
private final static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private final String UFO_USER_AUTHORIZE_FAILED_PREX="ufo:user:authorizeFailed:";
private final String UFO_USER_AUTHORIZE_INFO_PREX="ufo:user:authorizeInfo:";
//请求实名认证银联接口url 测试环境
private final String requestUrl="http://58.247.0.18:29015/v1/datacenter/smartverification/bankcard/verify";
//请求实名认证银联接口url 生产环境
... ... @@ -81,7 +82,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
AuthorizeResultRespVO result=new AuthorizeResultRespVO();
result.setUid(uid);
UserAuthorizeInfo info= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
UserAuthorizeInfo info= getValidAuthorizeInfoFromRedis(uid);
if(null!=info){
result.setAuthorizeFlag(true);
result.setCardNo(info.getCardNo());
... ... @@ -95,6 +96,27 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
return result;
}
private UserAuthorizeInfo getValidAuthorizeInfoFromRedis(int uid){
// 从redis缓存中获取
RedisKeyBuilder key=RedisKeyBuilder.newInstance().appendFixed(UFO_USER_AUTHORIZE_INFO_PREX).appendVar(uid);
UserAuthorizeInfo authorizeInfo = redisValueCache.get(key,UserAuthorizeInfo.class);
if(null != authorizeInfo){
return authorizeInfo;
}
//如果不存在,则从数据库获取
authorizeInfo= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
if(authorizeInfo!=null){
//保存到redis
try{
redisValueCache.set(key, authorizeInfo,60*60*2L,TimeUnit.SECONDS);
}catch(Exception e){
logger.warn("set valid authorize info to redis error. uid={}", uid);
}
}
return authorizeInfo;
}
/**
* 实名身份认证
*/
... ... @@ -105,7 +127,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
String name=reqVO.getName();
//检查是否已经实名认证,如果已经认证直接返回
if(null!=userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid)){
if(null!=getValidAuthorizeInfoFromRedis(uid)){
return new ApiResponse(400,"已实名认证",null);
}
... ...