!250 pref: 优化es生成全部商品索引,减少数据库操作 优化文件

Merge pull request !250 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-11-02 12:02:48 +00:00 committed by Gitee
commit 22c004a892
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
46 changed files with 192 additions and 192124 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
/** 店铺--默认页面是否开启**/
ALTER TABLE li_store ADD page_show bit(1) DEFAULT NULL COMMENT '默认页面是否开启';

View File

@ -46,3 +46,6 @@ CREATE TABLE `li_wholesale`
ALTER TABLE li_wholesale
ADD template_id bigint DEFAULT NULL COMMENT '商品模版id';
/** 店铺--默认页面是否开启**/
ALTER TABLE li_store ADD page_show bit(1) DEFAULT NULL COMMENT '默认页面是否开启';

View File

@ -1,30 +0,0 @@
package cn.lili.common.fulu.core;
/**
* @Auther: chenYing
* @Date: 2019/8/26 0026 15:08
*/
public interface MethodConst {
//卡密下单接口method方法
String OPEN_API_CARD_ORDER_ADD = "fulu.order.card.add";
// 根据话费查询归属地和城市编码面值城市等信息
String OPEN_API_CHECK_PHONE = "fulu.mobile.info.get";
// 直充下单接口method方法
String OPEN_API_DIRECT_ORDER_ADD = "fulu.order.direct.add";
// 获取商品信息接口method方法
String OPEN_API_GOODS_GET = "fulu.goods.info.get";
// 获取商品模板信息接口method方法
String OPEN_API_GOODS_TEMPLATE_GET = "fulu.goods.template.get";
// 查单接口method方法
String OPEN_API_ORDER_GET = "fulu.order.info.get";
// 话费下单接口method方法
String OPEN_API_PHONE_ORDER_ADD = "fulu.order.mobile.add";
// 流量下单接口method方法
String OPEN_API_TRAFFIC_ORDER_ADD = "fulu.order.data.add";
// 获取用户信息接口method方法
String OPEN_API_USER_INFO_GET = "fulu.user.info.get";
//获取商品列表method方法
String OPEN_API_GOODS_LIST = "fulu.goods.list.get";
}

View File

@ -1,58 +0,0 @@
package cn.lili.common.fulu.core.http;
import cn.lili.common.fulu.core.utils.HttpUtil;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:16
*/
public class FuluClient implements IFuluClient {
private static volatile ExecutorService executor;
private String url;
public FuluClient() {
this.url = "http://openapi.fulu.com/api/getway";
}
public FuluClient(String url) {
this.url = url;
}
/**
* 创建线程池
*/
private static void createThreadPool() {
if (executor == null) {
synchronized (FuluClient.class) {
if (executor == null) {
executor = Executors.newCachedThreadPool();
}
}
}
}
@Override
public String send(final String postData) {
String result = HttpUtil.sendPostJson(this.url, postData);
return result;
}
@Override
public Future<String> sendAsync(final String postData) {
createThreadPool();
return executor.submit(new Callable<String>() {
@Override
public String call() throws Exception {
String result = HttpUtil.sendPostJson(url, postData);
return result;
}
});
}
}

View File

@ -1,27 +0,0 @@
package cn.lili.common.fulu.core.http;
import java.util.concurrent.Future;
/**
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:15
*/
public interface IFuluClient {
/**
* 同步请求openapi2.0
*
* @param postData
* @return String
*/
String send(final String postData);
/**
* 异步请求openapi2.0
*
* @param postData
* @return Future<String>
*/
Future<String> sendAsync(final String postData);
}

View File

@ -1,47 +0,0 @@
package cn.lili.common.fulu.core.utils;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.security.Security;
/**
* @Auther: chenYing
* @Date: 2019/8/27 0027 17:38
*/
public class CardUtil {
private static final String ALGORITHM = "AES/ECB/PKCS7Padding";
private CardUtil() {
}
public static String cardDecode(String str, byte[] key) {
byte[] bytes = org.apache.commons.codec.binary.Base64.decodeBase64(str);
String result = null;
try {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec);
byte[] decoded = cipher.doFinal(bytes);
result = new String(decoded, "UTF-8");
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
return result;
}
public static String cardEncode(String str, byte[] key) {
byte[] result = null;
try {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
result = cipher.doFinal(str.getBytes("UTF-8"));
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
return new String(org.apache.commons.codec.binary.Base64.encodeBase64(result));
}
}

View File

@ -1,19 +0,0 @@
package cn.lili.common.fulu.core.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:17
*/
public class DateFormatUtil {
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private DateFormatUtil() {
}
public static String currentDateTime() {
return new SimpleDateFormat(DATE_FORMAT).format(new Date());
}
}

View File

@ -1,206 +0,0 @@
package cn.lili.common.fulu.core.utils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.*;
import java.util.*;
/**
* @author cheny
*/
public class HttpUtil {
private static Logger log = LoggerFactory.getLogger(HttpUtil.class);
public final static int CONNECT_TIMEOUT = 10000;
public final static int READ_TIMEOUT = 10000;
private static final String ENCODING_GBK = "GBK";
/**
* POST请求json字符串形式数据
*
* @param url 请求地址
* @param param 请求的json数据
* @return response body
* @throws Exception
*/
public static String sendPostJson(String url, String param) {
return sendPostWithHeads(url, param, "application/json", null);
}
private static String sendPostWithHeads(String url, String param, String contentType, Map<String, String> heads) {
PrintWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
HttpURLConnection conn = null;
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestMethod("POST");// 提交模式
conn.setConnectTimeout(CONNECT_TIMEOUT);// 连接超时 单位毫秒
conn.setReadTimeout(READ_TIMEOUT);// 读取超时 单位毫秒
if (contentType != null && !contentType.isEmpty()) {
conn.setRequestProperty("Content-Type", contentType);
}
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
// 添加头信息
if (heads != null && !heads.isEmpty()) {
for (String key : heads.keySet()) {
conn.setRequestProperty(key, heads.get(key));
}
}
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("send POST request exception :" + e.getMessage(), e);
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
if (conn != null) {
conn.disconnect();
}
} catch (Exception e2) {
throw new RuntimeException("close Connection exception :" + e2.getMessage(), e2);
}
}
return result.toString();
}
/**
* POST请求String字符串形式数据
*
* @param url
* @param paramXmlStr
* @return
*/
public static String sendPostXmlStr(String url, String paramXmlStr) {
String tmpparamXmlStr = "";
try {
tmpparamXmlStr = URLEncoder.encode(paramXmlStr, ENCODING_GBK);
tmpparamXmlStr = sendPostWithHeads(url, tmpparamXmlStr, "application/xml", null);
tmpparamXmlStr = URLDecoder.decode(tmpparamXmlStr,ENCODING_GBK);
}catch (Exception e){
e.printStackTrace();
log.error("post请求URL数据转码报错{}", e.getMessage());
}
return tmpparamXmlStr;
}
/**
* POST请求String字符串形式数据
*
* @param url
* @param paramXmlStr
* @return
*/
public static String sendPostXmlUrlencode(String url, String paramXmlStr) {
String tmpparamXmlStr = "";
Map<String, String> rspMap = new LinkedHashMap<>();
rspMap.put("req", paramXmlStr);
try {
tmpparamXmlStr = URLEncoder.encode(paramXmlStr, ENCODING_GBK);
tmpparamXmlStr = doPostMapParams(url, rspMap);
tmpparamXmlStr = URLDecoder.decode(tmpparamXmlStr,ENCODING_GBK);
}catch (Exception e){
e.printStackTrace();
log.error("post请求URL数据转码报错{}", e.getMessage());
}
return tmpparamXmlStr;
}
/**
* 发送POST请求
* @param url String对象为 目的地址
* @param parameters 请求参数Map类型
* @return 远程响应结果
*/
public static String doPostMapParams(String url, Map<String, String> parameters) {
BufferedReader in = null;
try {
// 定义HttpClient
HttpClient client = new DefaultHttpClient();
// 实例化HTTP方法
HttpPost request = new HttpPost();
request.setURI(new URI(url));
//设置参数
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
for (Iterator iter = parameters.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String value = String.valueOf(parameters.get(name));
nvps.add(new BasicNameValuePair(name, value));
}
request.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = client.execute(request);
int code = response.getStatusLine().getStatusCode();
if(code == 200){ //请求成功
in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent(),"UTF-8"));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
return sb.toString();
}else{
System.out.println("状态码:" + code);
return null;
}
}
catch(Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -1,41 +0,0 @@
package cn.lili.common.fulu.core.utils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class JSONUtil {
private static Gson gson = new Gson();
/**
* JSON 字符串转为 Java 对象
*/
public static <T> T fromJSON(String json, Class<T> type) {
T obj;
try {
obj = gson.fromJson(json, type);
} catch (Exception e) {
throw new RuntimeException(e);
}
return obj;
}
/**
* json字符串转list或者map
*/
public static <T> T fromJSON(String json, TypeToken<T> typeToken) {
return gson.fromJson(json, typeToken.getType());
}
/**
* Java 对象转为 JSON 字符串
*/
public static <T> String toJSON(T obj) {
String jsonStr;
try {
jsonStr = gson.toJson(obj);
} catch (Exception e) {
throw new RuntimeException(e);
}
return jsonStr;
}
}

View File

@ -1,342 +0,0 @@
package cn.lili.common.fulu.core.utils;
import cn.lili.common.fulu.core.MethodConst;
import cn.lili.common.fulu.model.*;
import cn.lili.common.fulu.sdk.DefaultOpenApiClient;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import com.alibaba.fastjson.JSON;
import com.google.gson.reflect.TypeToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.*;
public class Test {
private final static String APP_KEY = "lzHi7ewuTkplx2ePX0eQzN65TIFRk1zFClcoj1Jim/MHmu0X7ZqxMtSLENhvr1xD";
private final static Logger LOGGER = LoggerFactory.getLogger(Test.class);
private final static String SYS_SECRET = "9da68b0f8bcb470e84c3d30e343727e2";
private final static String URL = "http://openapi.fulu.com/api/getway";
// private final static String APP_KEY = "i4esv1l+76l/7NQCL3QudG90Fq+YgVfFGJAWgT+7qO1Bm9o/adG/1iwO2qXsAXNB";
// private final static Logger LOGGER = LoggerFactory.getLogger(Test.class);
// private final static String SYS_SECRET = "0a091b3aa4324435aab703142518a8f7";
// private final static String URL = "http://pre.openapi.fulu.com/api/getway";
private static String repeat(String ch, int num) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < num; i++) {
str.append(ch);
}
return str.toString();
}
private static void waitFor(Future<String> future) throws Exception {
while (!future.isDone()) {
TimeUnit.MILLISECONDS.sleep(500);
}
LOGGER.info("excuteAsync\n{}", future.get());
}
/**
* 卡密下单
*
* @throws Exception
*/
public static void cardOrderAddTest(FuLuConfigureDTO fuLuConfigureDTO, Integer productId, Integer buyNum,String orderSn) throws Exception {
LOGGER.info("\n卡密下单{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_CARD_ORDER_ADD);
InputCardOrderDto dto = new InputCardOrderDto();
dto.setProductId(productId);
dto.setCustomerOrderNo(orderSn);
dto.setBuyNum(buyNum);
client.setBizObject(dto);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
dto.setCustomerOrderNo(UUID.randomUUID().toString());
waitFor(client.excuteAsync());
}
/**
* 直充下单
*
* @throws Exception
*/
public static void directOrderAddTest(FuLuConfigureDTO fuLuConfigureDTO, Integer productId, Integer buyNum,String qrCode,String orderSn) throws Exception {
LOGGER.info("\n直充下单{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_DIRECT_ORDER_ADD);
InputDirectOrderDto dto = new InputDirectOrderDto();
dto.setProductId(productId);
dto.setBuyNum(buyNum);
client.setBizObject(dto);
int count = 1;
for (String chargeAccount : Arrays.asList(qrCode)) {
dto.setChargeAccount(chargeAccount);
dto.setCustomerOrderNo(orderSn);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
if (count++ >= 3) {
waitFor(client.excuteAsync());
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
}
/**
* 手机号归属地
*
* @throws Exception
*/
public void matchPhoneProducGetTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n手机号归属地{}", repeat("=", 100));
DefaultOpenApiClient client = new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_CHECK_PHONE);
InputMatchPhoneProductListDto dto = new InputMatchPhoneProductListDto();
dto.setFaceValue(50D);
int count = 1;
for (String phone : Arrays.asList("15972368779", "13971553804")) {
dto.setPhone(phone);
client.setBizObject(dto);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
if (count++ >= 2) {
waitFor(client.excuteAsync());
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
}
/**
* 订单查单
*
* @throws Exception
*/
public void orderInfoGetTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n订单查单{}", repeat("=", 100));
DefaultOpenApiClient client = new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_ORDER_GET);
InputOrderGetDto dto = new InputOrderGetDto();
client.setBizObject(dto);
int count = 1;
for (String customerOrderNo : Arrays
.asList("0d19f8e4-5af3-490d-a8d8-47fd457da7de", "31b6b96b-a21e-4bc4-bc0c-6e77a2ffb698")) {
dto.setCustomerOrderNo(customerOrderNo);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
if (count++ >= 2) {
Future<String> future = client.excuteAsync();
waitFor(future);
Map<String, String> result = JSONUtil.fromJSON(future.get(), new TypeToken<Map>() {
});
Map<String, Object> resultMap = JSONUtil.fromJSON(result.get("result"), new TypeToken<Map<String, Object>>() {
});
List<Map<String, String>> cardList = (List<Map<String, String>>) resultMap.get("cards");
StringBuilder decodeStr = new StringBuilder();
for (Map<String, String> map : cardList) {
decodeStr.append("card_number").append(map.get("card_number")).append("desc_card_number")
.append(CardUtil.cardDecode(map.get("card_number"), SYS_SECRET.getBytes("UTF-8")));
decodeStr.append(" card_pwd").append(map.get("card_pwd")).append("card_pwd")
.append(CardUtil.cardDecode(map.get("card_pwd"), SYS_SECRET.getBytes("UTF-8")));
decodeStr.append("\n");
}
System.out.println(decodeStr.toString());
System.out.println(CardUtil.cardEncode("CD10002502019061217430016421", SYS_SECRET.getBytes("UTF-8")));
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
}
/**
* 话费下单
*
* @throws Exception
*/
public void phoneOrderAddTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n话费下单{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_PHONE_ORDER_ADD);
InputPhoneOrderDto dto = new InputPhoneOrderDto();
dto.setChargeValue(Double.valueOf(50));
int count = 1;
for (String chargePhone : Arrays.asList("15972368779", "13971553804")) {
dto.setCustomerOrderNo(UUID.randomUUID().toString());
dto.setChargePhone(chargePhone);
client.setBizObject(dto);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
dto.setCustomerOrderNo(UUID.randomUUID().toString());
if (count++ >= 2) {
waitFor(client.excuteAsync());
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
}
/**
* 获得商品信息
*
* @throws Exception
*/
public static Map<String, Object> productInfoGetTest(FuLuConfigureDTO fuLuConfigureDTO,String productIdS) throws Exception {
LOGGER.info("\n获得商品信息{}", repeat("=", 100));
DefaultOpenApiClient client = new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_GOODS_GET);
InputProductDto dto = new InputProductDto();
int count = 1;
Map<String, Object> maps = new HashMap();
for (String productId : Arrays.asList(productIdS)) {
dto.setProductId(productId);
client.setBizObject(dto);
maps = (Map) JSON.parse(client.excute());
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
if (count++ >= 10) {
waitFor(client.excuteAsync());
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
return maps;
}
/**
* 获得商品模板信息
*
* @throws Exception
*/
public void productTemplateGetTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n获得商品模板信息{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_GOODS_TEMPLATE_GET);
InputProductTemplateDto dto = new InputProductTemplateDto();
dto.setTemplateId("e1dac0ea-dc86-4c9d-a778-c9e19203ecb8");
client.setBizObject(dto);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
waitFor(client.excuteAsync());
}
/**
* 流量下单
*
* @throws Exception
*/
public void trafficOrderAddTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n流量下单{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_TRAFFIC_ORDER_ADD);
InputTrafficOrderDto dto = new InputTrafficOrderDto();
dto.setChargeValue(Double.valueOf(1024));
dto.setPacketKind(4);
int count = 1;
for (String chargePhone : Arrays.asList("15972368779", "13971553804")) {
client.setBizObject(dto);
dto.setChargePhone(chargePhone);
dto.setCustomerOrderNo(UUID.randomUUID().toString());
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
dto.setCustomerOrderNo(UUID.randomUUID().toString());
if (count++ >= 2) {
waitFor(client.excuteAsync());
} else {
LOGGER.info("excuteAsync\n{}\n{}", client.excuteAsync().get(), repeat("-", 100));
}
}
}
/**
* 用户信息
*
* @throws Exception
*/
public static void userInfoGetTest(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n用户信息{}", repeat("=", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_USER_INFO_GET);
InputUserDto dto = new InputUserDto();
client.setBizObject(dto);
LOGGER.info("excute\n{}\n{}", client.excute(), repeat("-", 100));
waitFor(client.excuteAsync());
}
/**
* 用户信息高并发场景
*
* @throws Exception
*/
public static void userInfoGetTest2(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n用户信息高并发场景{}", repeat("=", 100));
Executor executor = Executors.newCachedThreadPool();
final int count = 10;
final CountDownLatch downLatch = new CountDownLatch(count);
for (int i = 0; i < count; ++i) {
executor.execute(new Runnable() {
@Override
public void run() {
try {
String name = Thread.currentThread().getName();
LOGGER.info("\n线程名{}{}", name, repeat("+", 100));
DefaultOpenApiClient client =
new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_USER_INFO_GET);
InputUserDto dto = new InputUserDto();
client.setBizObject(dto);
LOGGER.info("\n线程名{}\n{}\n{}", name, client.excute(), repeat("+", 100));
waitFor(client.excuteAsync());
} catch (Exception ex) {
LOGGER.error(ex.getMessage(), ex);
} finally {
downLatch.countDown();
}
}
});
}
downLatch.await();
}
/* 获得商品信息列表
*
* @throws Exception
*/
public static String getGoodsInfoList(FuLuConfigureDTO fuLuConfigureDTO) throws Exception {
LOGGER.info("\n获得商品信息{}", repeat("=", 100));
DefaultOpenApiClient client = new DefaultOpenApiClient(URL, fuLuConfigureDTO.getAppMerchantKey(), fuLuConfigureDTO.getAppSecretKey(), MethodConst.OPEN_API_GOODS_LIST);
InputProductDto dto = new InputProductDto();
client.setBizObject(dto);
return client.excute().toString();
}
public static void main(String[] args) {
try {
// productInfoGetTest();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,159 +0,0 @@
package cn.lili.common.fulu.model;
import cn.lili.common.fulu.core.utils.DateFormatUtil;
import cn.lili.common.fulu.core.utils.JSONUtil;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: chenYing
* @Date: 2019/8/19 0019 10:49
*/
public class CommonRequest implements Serializable {
private static final long serialVersionUID = 2L;
@SerializedName(value = "app_auth_token")
private String appAuthToken = "";
@SerializedName(value = "app_key")
private String appKey;
@SerializedName(value = "biz_content")
private String bizContent = "{}";
private transient Map<String, Object> bizContentMap = Collections.emptyMap();
private String charset;
private String format;
private String method;
private String sign;
@SerializedName(value = "sign_type")
private String signType;
private String timestamp;
private String version;
public CommonRequest() {
format = "json";
version = "2.0";
charset = "utf-8";
signType = "md5";
// timestamp = "2019-08-20 13:59:38";
timestamp = DateFormatUtil.currentDateTime();
}
public String getAppAuthToken() {
return appAuthToken;
}
public void setAppAuthToken(String appAuthToken) {
this.appAuthToken = appAuthToken;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getBizContent() {
if (!bizContentMap.isEmpty()) {
bizContent = JSONUtil.toJSON(bizContentMap);
}
return bizContent;
}
/**
* 直接将变量以json格式保存
*
* @param bizContent bizContent
*/
public void setBizContent(String bizContent) {
if (bizContent != null && !"".equals(bizContent.trim())) {
Map<String, Object> dataMap = JSONUtil.fromJSON(bizContent, new TypeToken<Map<String, Object>>() {
});
if (bizContentMap.isEmpty()) {
bizContentMap = new HashMap<String, Object>();
}
bizContentMap.putAll(dataMap);
}
}
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getSignType() {
return signType;
}
public void setSignType(String signType) {
this.signType = signType;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
/**
* 以key:value形式保存程序会转换为json格式
*
* @param key key
* @param value value
*/
public void setBizContent(String key, Object value) {
if (bizContentMap.isEmpty()) {
bizContentMap = new HashMap<String, Object>();
}
bizContentMap.put(key, value);
}
protected Object getBizContentValue(String key) {
return bizContentMap.get(key);
}
}

View File

@ -1,56 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 卡密订单input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:35
*/
public class InputCardOrderDto extends CommonRequest {
public InputCardOrderDto() {
super();
setMethod("fulu.order.card.add");
}
/**
* 购买数量
*
* @return Integer
*/
public Integer getBuyNum() {
Object value = getBizContentValue("buy_num");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setBuyNum(Integer buyNum) {
setBizContent("buy_num", buyNum);
}
/**
* 外部订单号
*
* @return String
*/
public String getCustomerOrderNo() {
Object value = getBizContentValue("customer_order_no");
return value != null ? String.valueOf(value) : null;
}
public void setCustomerOrderNo(String customerOrderNo) {
setBizContent("customer_order_no", customerOrderNo);
}
/**
* 商品编号
*
* @return Integer
*/
public Integer getProductId() {
Object value = getBizContentValue("product_id");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setProductId(Integer productId) {
setBizContent("product_id", productId);
}
}

View File

@ -1,213 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 直充商品订单input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:39
*/
public class InputDirectOrderDto extends CommonRequest {
public InputDirectOrderDto() {
super();
setMethod("fulu.order.direct.add");
}
/**
* 购买数量
*
* @return Integer
*/
public Integer getBuyNum() {
Object value = getBizContentValue("buy_num");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setBuyNum(Integer buyNum) {
setBizContent("buy_num", buyNum);
}
/**
* 充值账号
*
* @return String
*/
public String getChargeAccount() {
Object value = getBizContentValue("charge_account");
return value != null ? String.valueOf(value) : null;
}
public void setChargeAccount(String chargeAccount) {
setBizContent("charge_account", chargeAccount);
}
/**
* 充值游戏名称
*
* @return String
*/
public String getChargeGameName() {
Object value = getBizContentValue("charge_game_name");
return value != null ? String.valueOf(value) : null;
}
public void setChargeGameName(String chargeGameName) {
setBizContent("charge_game_name", chargeGameName);
}
/**
* 充值游戏区
*
* @return String
*/
public String getChargeGameRegion() {
Object value = getBizContentValue("charge_game_region");
return value != null ? String.valueOf(value) : null;
}
public void setChargeGameRegion(String chargeGameRegion) {
setBizContent("charge_game_region", chargeGameRegion);
}
/**
* 充值游戏角色
*
* @return String
*/
public String getChargeGameRole() {
Object value = getBizContentValue("charge_game_role");
return value != null ? String.valueOf(value) : null;
}
public void setChargeGameRole(String chargeGameRole) {
setBizContent("charge_game_role", chargeGameRole);
}
/**
* 充值游戏服
*
* @return String
*/
public String getChargeGameSrv() {
Object value = getBizContentValue("charge_game_srv");
return value != null ? String.valueOf(value) : null;
}
public void setChargeGameSrv(String chargeGameSrv) {
setBizContent("charge_game_srv", chargeGameSrv);
}
/**
* 下单真实Ip区域商品要传
*
* @return String
*/
public String getChargeIp() {
Object value = getBizContentValue("charge_ip");
return value != null ? String.valueOf(value) : null;
}
public void setChargeIp(String chargeIp) {
setBizContent("charge_ip", chargeIp);
}
/**
* 充值密码部分游戏类要传
*
* @return String
*/
public String getChargePassword() {
Object value = getBizContentValue("charge_password");
return value != null ? String.valueOf(value) : null;
}
public void setChargePassword(String chargePassword) {
setBizContent("charge_password", chargePassword);
}
/**
* 充值类型
*
* @return String
*/
public String getChargeType() {
Object value = getBizContentValue("charge_type");
return value != null ? String.valueOf(value) : null;
}
public void setChargeType(String chargeType) {
setBizContent("charge_type", chargeType);
}
/**
* 联系QQ
*
* @return String
*/
public String getContactQq() {
Object value = getBizContentValue("contact_qq");
return value != null ? String.valueOf(value) : null;
}
public void setContactQq(String contactQq) {
setBizContent("contact_qq", contactQq);
}
/**
* 联系电话
*
* @return String
*/
public String getContactTel() {
Object value = getBizContentValue("contact_tel");
return value != null ? String.valueOf(value) : null;
}
public void setContactTel(String contactTel) {
setBizContent("contact_tel", contactTel);
}
/**
* 外部订单号
*
* @return String
*/
public String getCustomerOrderNo() {
Object value = getBizContentValue("customer_order_no");
return value != null ? String.valueOf(value) : null;
}
public void setCustomerOrderNo(String customerOrderNo) {
setBizContent("customer_order_no", customerOrderNo);
}
/**
* 商品编号
*
* @return Integer
*/
public Integer getProductId() {
Object value = getBizContentValue("product_id");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setProductId(Integer productId) {
setBizContent("product_id", productId);
}
/**
* 剩余数量
*
* @return Integer
*/
public Integer getRemainingNumber() {
Object value = getBizContentValue("remaining_number");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setRemainingNumber(Integer remainingNumber) {
setBizContent("remaining_number", remainingNumber);
}
}

View File

@ -1,44 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 手机号归属地input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:08
*/
public class InputMatchPhoneProductListDto extends CommonRequest {
public InputMatchPhoneProductListDto() {
super();
setMethod("fulu.mobile.info.get");
}
/**
* 面值
*
* @return Double
*/
public Double getFaceValue() {
Object value = getBizContentValue("face_value");
return value != null ? Double.valueOf(value.toString()) : null;
}
public void setFaceValue(Double faceValue) {
setBizContent("face_value", faceValue);
}
/**
* 手机号
*
* @return String
*/
public String getPhone() {
Object value = getBizContentValue("phone");
return value != null ? String.valueOf(value) : null;
}
public void setPhone(String phone) {
setBizContent("phone", phone);
}
}

View File

@ -1,31 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 订单查单input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:23
*/
public class InputOrderGetDto extends CommonRequest {
public InputOrderGetDto() {
super();
setMethod("fulu.order.info.get");
}
/**
* 外部订单号
*
* @return String
*/
public String getCustomerOrderNo() {
Object value = getBizContentValue("customer_order_no");
return value != null ? String.valueOf(value) : null;
}
public void setCustomerOrderNo(String customerOrderNo) {
setBizContent("customer_order_no", customerOrderNo);
}
}

View File

@ -1,57 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 话费订单input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:31
*/
public class InputPhoneOrderDto extends CommonRequest {
public InputPhoneOrderDto() {
super();
setMethod("fulu.order.mobile.add");
}
/**
* 充值手机号
*
* @return String
*/
public String getChargePhone() {
Object value = getBizContentValue("charge_phone");
return value != null ? String.valueOf(value) : null;
}
public void setChargePhone(String chargePhone) {
setBizContent("charge_phone", chargePhone);
}
/**
* 充值数额
*
* @return Double
*/
public Double getChargeValue() {
Object value = getBizContentValue("charge_value");
return value != null ? Double.valueOf(value.toString()) : null;
}
public void setChargeValue(Double chargeValue) {
setBizContent("charge_value", chargeValue);
}
/**
* 外部订单号
*
* @return String
*/
public String getCustomerOrderNo() {
Object value = getBizContentValue("customer_order_no");
return value != null ? String.valueOf(value) : null;
}
public void setCustomerOrderNo(String customerOrderNo) {
setBizContent("customer_order_no", customerOrderNo);
}
}

View File

@ -1,30 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 商品信息input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:04
*/
public class InputProductDto extends CommonRequest {
public InputProductDto() {
super();
setMethod("fulu.goods.info.get");
}
/**
* 商品编号
*
* @return String
*/
public String getProductId() {
Object value = getBizContentValue("product_id");
return value != null ? String.valueOf(value) : null;
}
public void setProductId(String productId) {
setBizContent("product_id", productId);
}
}

View File

@ -1,29 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 商品模板信息input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:01
*/
public class InputProductTemplateDto extends CommonRequest {
public InputProductTemplateDto() {
super();
setMethod("fulu.goods.template.get");
}
/**
* 商品模板编号
*
* @return String
*/
public String getTemplateId() {
Object value = getBizContentValue("template_id");
return value != null ? String.valueOf(value) : null;
}
public void setTemplateId(String templateId) {
setBizContent("template_id", templateId);
}
}

View File

@ -1,72 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 流量订单input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 13:50
*/
public class InputTrafficOrderDto extends CommonRequest {
public InputTrafficOrderDto() {
super();
setMethod("fulu.order.data.add");
}
/**
* 充值手机号
*
* @return String
*/
public String getChargePhone() {
Object value = getBizContentValue("charge_phone");
return value != null ? String.valueOf(value) : null;
}
public void setChargePhone(String chargePhone) {
setBizContent("charge_phone", chargePhone);
}
/**
* 充值数额M
*
* @return Double
*/
public Double getChargeValue() {
Object value = getBizContentValue("charge_value");
return value != null ? Double.valueOf(value.toString()) : null;
}
public void setChargeValue(Double chargeValue) {
setBizContent("charge_value", chargeValue);
}
/**
* 外部订单号
*
* @return String
*/
public String getCustomerOrderNo() {
Object value = getBizContentValue("customer_order_no");
return value != null ? String.valueOf(value) : null;
}
public void setCustomerOrderNo(String customerOrderNo) {
setBizContent("customer_order_no", customerOrderNo);
}
/**
* 流量性质 1:小时 2: 3:7天 4: 5:季度 6:半年 7:
*
* @return Integer
*/
public Integer getPacketKind() {
Object value = getBizContentValue("packet_kind");
return value != null ? Integer.valueOf(value.toString()) : null;
}
public void setPacketKind(Integer packetKind) {
setBizContent("packet_kind", packetKind);
}
}

View File

@ -1,15 +0,0 @@
package cn.lili.common.fulu.model;
/**
* 用户信息input dto
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:06
*/
public class InputUserDto extends CommonRequest {
public InputUserDto() {
super();
setMethod("fulu.user.info.get");
}
}

View File

@ -1,46 +0,0 @@
package cn.lili.common.fulu.model.response;
/**
* 响应对象
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 15:06
*/
public class DefaultClientResponse {
private String code;
private String message;
private String result;
private String sign;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}

View File

@ -1,129 +0,0 @@
package cn.lili.common.fulu.sdk;
import cn.lili.common.fulu.core.http.FuluClient;
import cn.lili.common.fulu.core.http.IFuluClient;
import cn.lili.common.fulu.core.utils.JSONUtil;
import cn.lili.common.fulu.model.CommonRequest;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.Arrays;
import java.util.concurrent.Future;
/**
* 默认OpenApi客户请求实现
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:45
*/
public class DefaultOpenApiClient implements IDefaultOpenApiClient {
/**
* 商户AppKey
*/
private String appKey;
/**
* 业务参数
*/
private CommonRequest bizContent;
/**
* http请求
*/
private IFuluClient fuluClient;
/**
* 方法
*/
private String method;
/**
* 应用秘钥
*/
private String sysSecret;
// public DefaultOpenApiClient(String url, String appKey, String sysSecret) {
// this.appKey = appKey;
// this.sysSecret = sysSecret;
//
// if (url == null || "".equals(url.trim())) {
// this.fuluClient = new FuluClient();
// } else {
// this.fuluClient = new FuluClient(url);
// }
// }
/**
* 如果url没改变可以使用这个构造
*
* @param appKey appKey
* @param sysSecret sysSecret
*/
// public DefaultOpenApiClient(String appKey, String sysSecret) {
// this.appKey = appKey;
// this.fuluClient = new FuluClient();
// this.sysSecret = sysSecret;
// }
/**
* 使用public void setBizContent(String bizContent)此方法method不能为空必填
* 或者使用其它构造调用fulu.sup.open.api.model.CommonRequest的setMethod也可以
*
* @param url url
* @param appKey appKey
* @param sysSecret sysSecret
* @param method method
*/
public DefaultOpenApiClient(String url, String appKey, String sysSecret, String method) {
this.appKey = appKey;
this.sysSecret = sysSecret;
this.method = method;
if (url == null || "".equals(url.trim())) {
this.fuluClient = new FuluClient();
} else {
this.fuluClient = new FuluClient(url);
}
}
@Override
public String excute() {
doSign();
return fuluClient.send(JSONUtil.toJSON(this.bizContent));
}
@Override
public Future<String> excuteAsync() {
doSign();
return fuluClient.sendAsync(JSONUtil.toJSON(this.bizContent));
}
@Override
public void setBizContent(String bizContent) {
this.bizContent = new CommonRequest();
this.bizContent.setBizContent(bizContent);
this.bizContent.setAppKey(this.appKey);
this.bizContent.setMethod(this.method);
}
@Override
public void setBizObject(CommonRequest bizModel) {
this.bizContent = bizModel;
this.bizContent.setAppKey(this.appKey);
if (method != null && !"".equals(method)) {
this.bizContent.setMethod(this.method);
}
}
private void doSign() {
if (bizContent.getMethod() == null || "".equals(bizContent.getMethod().trim())) {
throw new RuntimeException("param \"method\" can not blank!");
}
this.bizContent.setSign(null);
this.bizContent.getBizContent();
String json = JSONUtil.toJSON(this.bizContent);
char[] charArray = json.toCharArray();
Arrays.sort(charArray);
String signStr = new String(charArray);
signStr = String.format("%s%s", signStr, sysSecret);
this.bizContent.setSign(DigestUtils.md5Hex(signStr));
}
}

View File

@ -1,44 +0,0 @@
package cn.lili.common.fulu.sdk;
import cn.lili.common.fulu.model.CommonRequest;
import java.util.concurrent.Future;
/**
* 默认OpenApi客户请求接口
*
* @Auther: chenYing
* @Date: 2019/8/19 0019 16:40
*/
public interface IDefaultOpenApiClient {
/**
* 执行请求同步方法
*
* @return String
*/
String excute();
/**
* 执行请求异步方法
*
* @return Future<String>
*/
Future<String> excuteAsync();
/**
* 设置业务参数
*
* @param bizContent
*/
@Deprecated
void setBizContent(String bizContent);
/**
* 设置业务参数
*/
void setBizObject(CommonRequest bizModel);
}

View File

@ -1,34 +0,0 @@
package cn.lili.modules.file.plugin;
import java.io.InputStream;
import java.util.List;
public interface QiNiuManagerPlugin {
/**
* 文件流上传
*
* @param inputStream
* @param key
* @return
*/
String inputStreamUpload(InputStream inputStream, String key);
/**
* 删除文件
*
* @param key
*/
void deleteFile(List<String> key);
/**
* 根据原图生成规定尺寸的图片
*
* @param url 连接
* @param width
* @param height
* @return
*/
String getUrl(String url, Integer width, Integer height);
}

View File

@ -1,143 +0,0 @@
package cn.lili.modules.file.plugin.impl;
import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.modules.file.plugin.QiNiuManagerPlugin;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.OssSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.DeleteObjectsRequest;
import com.google.gson.Gson;
import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.InputStream;
import java.util.List;
/**
* 阿里oss 文件操作
*
* @author Chopper
*/
@Component
@Slf4j
public class QiNiuFileManagerPlugin implements QiNiuManagerPlugin {
@Autowired
private SettingService settingService;
/**
* 下一个初始化配置参数的时间
* 这里为了防止多次调用redis减少与redis的交互时间
*/
private static Long nextInitSetting;
/**
* 暂时设定3分账请求一次设置
*/
private static final Long INTERVAL = 60 * 3 * 1000L;
/**
* 静态设置最快三分钟更新一次
*/
private static OssSetting ossSetting;
private Auth auth;
private UploadManager uploadManager;
private BucketManager bucketManager;
/**
* 获取oss client
*
* @return
*/
private OSS getQiNiuOssClient() {
OssSetting ossSetting = getSetting();
return new OSSClientBuilder().build(
ossSetting.getEndPoint(),
ossSetting.getAccessKeyId(),
ossSetting.getAccessKeySecret());
}
/**
* 获取配置
*
* @return
*/
private OssSetting getSetting() {
//如果没有配置或者没有下次刷新时间或者下次刷新时间小于当前时间则从redis 更新一次
if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) {
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
if (setting == null || StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.OSS_NOT_EXIST);
}
nextInitSetting = System.currentTimeMillis() + INTERVAL;
ossSetting = new Gson().fromJson(setting.getSettingValue(), OssSetting.class);
return ossSetting;
}
return ossSetting;
}
@Override
public String inputStreamUpload(InputStream inputStream, String key) {
OssSetting ossSetting = getSetting();
auth = Auth.create(ossSetting.getAccessKeyId(), ossSetting.getAccessKeySecret());
uploadManager = new UploadManager(new Configuration());
String upToken = auth.uploadToken(ossSetting.getBucketName());
try {
Response response = uploadManager.put(inputStream, ossSetting.getPicLocation() +"/"+ key, upToken, null, "image/jpg");
if (response.statusCode == 200) {
return ossSetting.getEndPoint() + "/"+ ossSetting.getPicLocation() + "/" + key;
}
} catch (QiniuException e) {
e.printStackTrace();
}
return "";
}
@Override
public void deleteFile(List<String> key) {
OssSetting ossSetting = getSetting();
if (bucketManager == null) {
if (auth == null) {
auth = Auth.create(ossSetting.getAccessKeyId(), ossSetting.getAccessKeySecret());
}
bucketManager = new BucketManager(auth, new Configuration());
}
//
// for (int i = 0; 0 < key.size(); i++) {
// try {
// bucketManager.delete(ossSetting.getBucketName()+ "/"+ ossSetting.getPicLocation(), key.get(i));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
@Override
public String getUrl(String url, Integer width, Integer height) {
//缩略图全路径
//返回缩略图全路径
return url + "?x-oss-process=style/" + width + "X" + height;
}
}

View File

@ -8,7 +8,6 @@ import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsOperationFuLuDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;

View File

@ -1,137 +0,0 @@
package cn.lili.modules.goods.entity.dto;
import cn.lili.common.validation.EnumValue;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 商品编辑DTO
*
* @author pikachu
* @since 2020-02-24 19:27:20
*/
@Data
@ToString
public class GoodsOperationFuLuDTO implements Serializable {
private static final long serialVersionUID = -509667581371776913L;
@ApiModelProperty(hidden = true)
private String goodsId;
@ApiModelProperty(value = "商品价格", required = true)
@NotNull(message = "商品价格不能为空")
@Min(value = 0, message = "商品价格不能为负数")
@Max(value = 99999999, message = "商品价格不能超过99999999")
private Double price;
@ApiModelProperty(value = "分类path")
private String categoryPath;
@ApiModelProperty(value = "店铺分类id", required = true)
@Size(max = 200, message = "选择了太多店铺分类")
private String storeCategoryPath;
@ApiModelProperty(value = "品牌id")
@Min(value = 0, message = "品牌值不正确")
private String brandId;
@ApiModelProperty(value = "商品名称", required = true)
@NotEmpty(message = "商品名称不能为空")
@Length(max = 50, message = "商品名称不能超过50个字符")
private String goodsName;
@ApiModelProperty(value = "详情")
private String intro;
@ApiModelProperty(value = "商品移动端详情")
private String mobileIntro;
@ApiModelProperty(value = "库存")
@Min(value = 0, message = "库存不能为负数")
@Max(value = 99999999, message = "库存不能超过99999999")
private Integer quantity;
@ApiModelProperty(value = "是否立即发布")
private Boolean release;
@ApiModelProperty(value = "是否是推荐商品")
private Boolean recommend;
@ApiModelProperty(value = "商品参数")
private List<GoodsParamsDTO> goodsParamsDTOList;
@ApiModelProperty(value = "商品图片")
private List<String> goodsGalleryList;
@ApiModelProperty(value = "运费模板id,不需要运费模板时值是0", required = true)
@NotNull(message = "运费模板不能为空没有运费模板时传值0")
@Min(value = 0, message = "运费模板值不正确")
private String templateId;
@ApiModelProperty(value = "sku列表")
@Valid
private List<Map<String, Object>> skuList;
@ApiModelProperty(value = "卖点")
private String sellingPoint;
@ApiModelProperty(value = "销售模式", required = true)
private String salesModel;
@ApiModelProperty(value = "是否有规格", hidden = true)
private String haveSpec;
@ApiModelProperty(value = "销售模式", required = true)
private String goodsUnit;
@ApiModelProperty(value = "商品描述")
private String info;
@ApiModelProperty(value = "是否重新生成sku数据")
private Boolean regeneratorSkuFlag = true;
/**
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
*/
@ApiModelProperty(value = "商品类型")
@EnumValue(strValues = {"PHYSICAL_GOODS", "VIRTUAL_GOODS", "E_COUPON"}, message = "商品类型参数值错误")
private String goodsType;
/**
* 商品视频
*/
@ApiModelProperty(value = "商品视频")
private String goodsVideo;
public String getGoodsName() {
//对商品对名称做一个极限处理这里没有用xss过滤是因为xss过滤为全局过滤影响很大
// 业务中全局代码中只有商品名称不能拥有英文逗号是由于商品名称存在一个数据库联合查询结果要根据逗号分组
return goodsName.replace(",", "");
}
//福禄所需参数
@ApiModelProperty(value = "商品编号", required = true)
@Length(max = 30, message = "商品编号太长不能超过30个字符")
private String sn;
@ApiModelProperty(value = "市场价格", required = true)
@NotNull(message = "市场价格不能为空")
private Double cost;
@ApiModelProperty(value = "重量", required = true)
@NotNull(message = "商品重量不能为空")
@Min(value = 0, message = "重量不能为负数")
@Max(value = 99999999, message = "重量不能超过99999999")
private Double weight;
}

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 商品品牌业务层
@ -40,6 +41,14 @@ public interface BrandService extends IService<Brand> {
*/
List<Brand> getBrandsByCategory(String categoryId);
/**
* 根据分类ID获取品牌列表
*
* @param categoryIds 分类ID
* @return 品牌列表
*/
List<Map<String, Object>> getBrandsMapsByCategory(List<String> categoryIds, String columns);
/**
* 添加品牌
*

View File

@ -6,6 +6,7 @@ import cn.lili.modules.goods.entity.vos.CategoryVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 商品分类业务层
@ -41,6 +42,14 @@ public interface CategoryService extends IService<Category> {
*/
List<Category> listByIdsOrderByLevel(List<String> ids);
/**
* 根据分类id集合获取所有分类根据层级排序
*
* @param ids 分类ID集合
* @return 商品分类列表
*/
List<Map<String, Object>> listMapsByIdsOrderByLevel(List<String> ids, String columns);
/**
* 获取分类树
*

View File

@ -2,7 +2,6 @@ package cn.lili.modules.goods.service;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsOperationFuLuDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;

View File

@ -5,6 +5,7 @@ import cn.lili.modules.goods.entity.vos.StoreGoodsLabelVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 店铺商品分类业务层
@ -30,6 +31,14 @@ public interface StoreGoodsLabelService extends IService<StoreGoodsLabel> {
*/
List<StoreGoodsLabel> listByStoreIds(List<String> ids);
/**
* 根据分类id集合获取所有店铺分类根据层级排序
*
* @param ids 商家ID
* @return 店铺分类列表
*/
List<Map<String, Object>> listMapsByStoreIds(List<String> ids, String columns);
/**
* 添加商品分类
*

View File

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -68,6 +69,14 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
return new ArrayList<>();
}
@Override
public List<Map<String, Object>> getBrandsMapsByCategory(List<String> categoryIds, String columns) {
QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
queryWrapper.select(columns);
queryWrapper.in("id", categoryIds);
return this.listMaps(queryWrapper);
}
@Override
public boolean addBrand(BrandVO brandVO) {

View File

@ -25,10 +25,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -80,6 +77,14 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
return this.list(new LambdaQueryWrapper<Category>().in(Category::getId, ids).orderByAsc(Category::getLevel));
}
@Override
public List<Map<String, Object>> listMapsByIdsOrderByLevel(List<String> ids, String columns) {
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.select(columns);
queryWrapper.in("id", ids).orderByAsc("level");
return this.listMaps(queryWrapper);
}
@Override
public List<CategoryVO> categoryTree() {
List<CategoryVO> categoryVOList = (List<CategoryVO>) cache.get(CachePrefix.CATEGORY.getPrefix());

View File

@ -18,7 +18,6 @@ import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsGallery;
import cn.lili.modules.goods.entity.dos.Wholesale;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsOperationFuLuDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;

View File

@ -12,6 +12,7 @@ import cn.lili.modules.goods.entity.vos.StoreGoodsLabelVO;
import cn.lili.modules.goods.mapper.StoreGoodsLabelMapper;
import cn.lili.modules.goods.service.StoreGoodsLabelService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
/**
* 店铺商品分类业务层实现
@ -83,6 +85,13 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl<StoreGoodsLabelMappe
return this.list(new LambdaQueryWrapper<StoreGoodsLabel>().in(StoreGoodsLabel::getId, ids).orderByAsc(StoreGoodsLabel::getLevel));
}
@Override
public List<Map<String, Object>> listMapsByStoreIds(List<String> ids, String columns) {
QueryWrapper<StoreGoodsLabel> queryWrapper = new QueryWrapper<StoreGoodsLabel>().in("id", ids).orderByAsc("level");
queryWrapper.select(columns);
return this.listMaps(queryWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public StoreGoodsLabel addStoreGoodsLabel(StoreGoodsLabel storeGoodsLabel) {

View File

@ -4,6 +4,7 @@ import cn.lili.cache.CachePrefix;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -43,6 +44,15 @@ public interface PromotionGoodsService extends IService<PromotionGoods> {
*/
List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds);
/**
* 获取sku所有有效活动
*
* @param skus 商品skuId
* @return 促销商品集合
*/
List<PromotionGoods> findSkuValidPromotions(List<GoodsSkuDTO> skus);
/**
* 分页获取促销商品信息
*

View File

@ -35,4 +35,12 @@ public interface PromotionService {
* @param goodsIdsJsonStr
*/
void removeByGoodsIds(String goodsIdsJsonStr);
/**
* 根据促销商品信息包装促销信息
*
* @param promotionGoodsList 促销商品信息
* @return 促销信息
*/
Map<String, Object> wrapperPromotionMapList(List<PromotionGoods> promotionGoodsList);
}

View File

@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
@ -35,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* 促销商品业务层实现
@ -87,6 +89,22 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
return this.list(queryWrapper);
}
@Override
public List<PromotionGoods> findSkuValidPromotions(List<GoodsSkuDTO> skus) {
List<String> categories = skus.stream().map(GoodsSku::getCategoryPath).collect(Collectors.toList());
List<String> skuIds = skus.stream().map(GoodsSku::getId).collect(Collectors.toList());
List<String> categoriesPath = new ArrayList<>();
categories.forEach(i -> categoriesPath.addAll(Arrays.asList(i.split(","))));
QueryWrapper<PromotionGoods> queryWrapper = new QueryWrapper<>();
queryWrapper.and(i -> i.or(j -> j.in(SKU_ID_COLUMN, skuIds))
.or(n -> n.eq("scope_type", PromotionsScopeTypeEnum.ALL.name()))
.or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())
.and(l -> l.in("scope_id", categoriesPath)))));
queryWrapper.and(i -> i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)).or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.NEW)));
return this.list(queryWrapper);
}
@Override
public IPage<PromotionGoods> pageFindAll(PromotionGoodsSearchParams searchParams, PageVO pageVo) {
return this.page(PageUtil.initPage(pageVo), searchParams.queryWrapper());

View File

@ -89,8 +89,19 @@ public class PromotionServiceImpl implements PromotionService {
*/
public Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId) {
String storeIds = storeId + "," + PromotionTools.PLATFORM_ID;
Map<String, Object> promotionMap = new HashMap<>();
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds);
return wrapperPromotionMapList(promotionGoodsList);
}
@Override
public void removeByGoodsIds(String goodsIdsJsonStr) {
List<String> goodsIds = JSONUtil.toList(goodsIdsJsonStr, String.class);
promotionGoodsService.deletePromotionGoodsByGoods(goodsIds);
kanjiaActivityGoodsService.deleteByGoodsIds(goodsIds);
}
public Map<String, Object> wrapperPromotionMapList(List<PromotionGoods> promotionGoodsList) {
Map<String, Object> promotionMap = new HashMap<>();
for (PromotionGoods promotionGoods : promotionGoodsList) {
String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId();
switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) {
@ -120,13 +131,6 @@ public class PromotionServiceImpl implements PromotionService {
return promotionMap;
}
@Override
public void removeByGoodsIds(String goodsIdsJsonStr) {
List<String> goodsIds = JSONUtil.toList(goodsIdsJsonStr, String.class);
promotionGoodsService.deletePromotionGoodsByGoods(goodsIds);
kanjiaActivityGoodsService.deleteByGoodsIds(goodsIds);
}
private void getGoodsCurrentSeckill(String esPromotionKey, PromotionGoods promotionGoods, Map<String, Object> promotionMap) {
Seckill seckill = seckillService.getById(promotionGoods.getPromotionId());
SeckillSearchParams searchParams = new SeckillSearchParams();

View File

@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@ -19,10 +18,7 @@ import cn.lili.common.vo.PageVO;
import cn.lili.elasticsearch.BaseElasticsearchService;
import cn.lili.elasticsearch.EsSuffix;
import cn.lili.elasticsearch.config.ElasticsearchProperties;
import cn.lili.modules.goods.entity.dos.Brand;
import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dos.StoreGoodsLabel;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
@ -33,7 +29,9 @@ import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.goods.service.StoreGoodsLabelService;
import cn.lili.modules.promotion.entity.dos.BasePromotions;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.service.PromotionGoodsService;
import cn.lili.modules.promotion.service.PromotionService;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.entity.dos.CustomWords;
@ -101,6 +99,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired
private PromotionService promotionService;
@Autowired
private PromotionGoodsService promotionGoodsService;
@Autowired
private CustomWordsService customWordsService;
@ -129,6 +130,18 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
@Autowired
private ElasticsearchOperations restTemplate;
/**
* 去除 重复元素
*
* @param list
* @return
*/
public static void removeDuplicate(List<String> list) {
HashSet<String> h = new HashSet<>(list);
list.clear();
list.addAll(h);
}
@Override
public void init() {
//获取索引任务标识
@ -173,19 +186,66 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
for (int i = 1; ; i++) {
List<EsGoodsIndex> esGoodsIndices = new ArrayList<>();
Page<GoodsSkuDTO> skuPage = new Page<>(i, 100);
Page<GoodsSkuDTO> skuPage = new Page<>(i, 2000);
IPage<GoodsSkuDTO> skuIPage = goodsSkuService.getGoodsSkuDTOByPage(skuPage, skuQueryWrapper);
if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) {
break;
}
List<PromotionGoods> skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIPage.getRecords());
List<String> brandIds = new ArrayList<>();
List<String> categoryPaths = new ArrayList<>();
List<String> storeCategoryPaths = new ArrayList<>();
for (GoodsSkuDTO goodsSkuDTO : skuIPage.getRecords()) {
if (CharSequenceUtil.isNotEmpty(goodsSkuDTO.getBrandId())) {
brandIds.add(goodsSkuDTO.getBrandId());
}
if (CharSequenceUtil.isNotEmpty(goodsSkuDTO.getStoreCategoryPath())) {
storeCategoryPaths.addAll(Arrays.asList(goodsSkuDTO.getStoreCategoryPath().split(",")));
}
if (CharSequenceUtil.isNotEmpty((goodsSkuDTO.getCategoryPath()))) {
categoryPaths.addAll(Arrays.asList(goodsSkuDTO.getCategoryPath().split(",")));
}
}
List<Map<String, Object>> brandList = new ArrayList<>();
if (CollUtil.isNotEmpty(brandIds)) {
brandList = this.brandService.getBrandsMapsByCategory(brandIds, "id,name,logo");
}
List<Map<String, Object>> categoryList = new ArrayList<>();
if (CollUtil.isNotEmpty(categoryList)) {
categoryList = this.categoryService.listMapsByIdsOrderByLevel(categoryPaths, "id,name");
}
List<Map<String, Object>> storeCategoryList = new ArrayList<>();
if (CollUtil.isNotEmpty(storeCategoryList)) {
storeCategoryList = this.storeGoodsLabelService.listMapsByStoreIds(storeCategoryPaths, "id,label_name");
}
for (GoodsSkuDTO goodsSku : skuIPage.getRecords()) {
int skuSource = 100;
EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku);
EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku, brandList, categoryList, storeCategoryList);
long count = esGoodsIndices.stream().filter(j -> j.getGoodsId().equals(esGoodsIndex.getGoodsId())).count();
if (count >= 1) {
skuSource -= count;
}
esGoodsIndex.setSkuSource(skuSource);
//设置促销信息
List<PromotionGoods> promotionGoods = skuValidPromotions.stream()
.filter(j ->
(CharSequenceUtil.isNotEmpty(j.getSkuId()) && j.getSkuId().equals(goodsSku.getId())) ||
j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getScopeId().contains(goodsSku.getCategoryPath())))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(promotionGoods)) {
esGoodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionService.wrapperPromotionMapList(promotionGoods)));
}
esGoodsIndices.add(esGoodsIndex);
//库存锁是在redis做的所以生成索引同时更新一下redis中的库存数量
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());
@ -273,7 +333,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
goodsIndexRepository.save(goods);
}
/**
* 商品分词
*
@ -309,18 +368,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
}
}
/**
* 去除 重复元素
*
* @param list
* @return
*/
public static void removeDuplicate(List<String> list) {
HashSet<String> h = new HashSet<>(list);
list.clear();
list.addAll(h);
}
/**
* 更新商品索引的的部分属性只填写更新的字段不需要更新的字段不要填写
*
@ -853,7 +900,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
return elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME;
}
private EsGoodsIndex wrapperEsGoodsIndex(GoodsSkuDTO goodsSku) {
private EsGoodsIndex wrapperEsGoodsIndex(GoodsSkuDTO goodsSku, List<Map<String, Object>> brandList, List<Map<String, Object>> categoryList, List<Map<String, Object>> storeCategoryList) {
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
//商品参数索引
@ -862,28 +909,27 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
}
//商品分类索引
if (goodsSku.getCategoryPath() != null) {
List<Category> categories = categoryService.listByIdsOrderByLevel(Arrays.asList(goodsSku.getCategoryPath().split(",")));
if (!categories.isEmpty()) {
index.setCategoryNamePath(ArrayUtil.join(categories.stream().map(Category::getName).toArray(), ","));
}
if (CollUtil.isNotEmpty(categoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getCategoryPath())) {
StringBuilder categoryNamePath = new StringBuilder();
categoryList.stream().filter(o -> goodsSku.getCategoryPath().contains(o.get("id").toString())).forEach(p -> categoryNamePath.append(p.get("name")).append(","));
categoryNamePath.deleteCharAt(categoryNamePath.length() - 1);
index.setCategoryNamePath(categoryNamePath.toString());
}
//商品品牌索引
Brand brand = brandService.getById(goodsSku.getBrandId());
if (brand != null) {
index.setBrandName(brand.getName());
index.setBrandUrl(brand.getLogo());
if (CollUtil.isNotEmpty(brandList) && CharSequenceUtil.isNotEmpty(goodsSku.getBrandId())) {
Optional<Map<String, Object>> brandInfo = brandList.stream().filter(p -> p.get("id").equals(goodsSku.getBrandId())).findFirst();
if (brandInfo.isPresent()) {
index.setBrandName(brandInfo.get().get("name").toString());
index.setBrandUrl(brandInfo.get().get("logo").toString());
}
}
//店铺分类索引
if (goodsSku.getStoreCategoryPath() != null && CharSequenceUtil.isNotEmpty(goodsSku.getStoreCategoryPath())) {
List<StoreGoodsLabel> storeGoodsLabels = storeGoodsLabelService.listByStoreIds(Arrays.asList(goodsSku.getStoreCategoryPath().split(",")));
if (!storeGoodsLabels.isEmpty()) {
index.setStoreCategoryNamePath(ArrayUtil.join(storeGoodsLabels.stream().map(StoreGoodsLabel::getLabelName).toArray(), ","));
if (CollUtil.isNotEmpty(storeCategoryList) && CharSequenceUtil.isNotEmpty(goodsSku.getStoreCategoryPath())) {
StringBuilder storeCategoryNamePath = new StringBuilder();
storeCategoryList.stream().filter(o -> goodsSku.getStoreCategoryPath().contains(o.get("id").toString())).forEach(p -> storeCategoryNamePath.append(p.get("label_name").toString()).append(","));
storeCategoryNamePath.deleteCharAt(storeCategoryNamePath.length() - 1);
index.setStoreCategoryNamePath(storeCategoryNamePath.toString());
}
}
//促销索引
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId());
index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
return index;
}
}

View File

@ -87,14 +87,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
NativeSearchQuery searchQuery = searchQueryBuilder.build();
log.debug("searchGoods DSL:{}", searchQuery.getQuery());
SearchHits<EsGoodsIndex> search = restTemplate.search(searchQuery, EsGoodsIndex.class);
// for (int i = 0; i < search.getSearchHits().size() ; i++){
// if (search.getSearchHits().get(i).getContent().getSmall().contains("fuluapiossproductnew.oss-cn-hangzhou.aliyuncs.com")){
// search.getSearchHits().get(i).getContent().setSmall(search.getSearchHits().get(i).getContent().getSmall().replace("?x-oss-process=style/200X200", ""));
// }
// if (search.getSearchHits().get(i).getContent().getThumbnail().contains("fuluapiossproductnew.oss-cn-hangzhou.aliyuncs.com")){
// search.getSearchHits().get(i).getContent().setThumbnail(search.getSearchHits().get(i).getContent().getThumbnail().replace("?x-oss-process=style/400X400", ""));
// }
// }
return SearchHitSupport.searchPageFor(search, searchQuery.getPageable());
}
@ -575,9 +567,9 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
filterFunctionBuilders.add(skuNoBuilder);
// 修改分数算法为无数字最大分数越高
FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.NONE).setWeight(3);
FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(buyCountScore);
filterFunctionBuilders.add(buyCountBuilder);
// FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.NONE).setWeight(10);
// FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(buyCountScore);
// filterFunctionBuilders.add(buyCountBuilder);
return filterFunctionBuilders;
}

View File

@ -1,23 +0,0 @@
package cn.lili.modules.store.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 店铺福禄配置
*
* @author pikachu
* @since 2021-01-11 15:10:51
*/
@Data
public class FuLuConfigureDTO {
@ApiModelProperty(value = "福禄app密钥")
private String appSecretKey;
@ApiModelProperty(value = "福禄商户号")
private String merchantNumber;
@ApiModelProperty(value = "福禄appKEY商户key")
private String appMerchantKey;
}

View File

@ -2,7 +2,6 @@ package cn.lili.modules.store.mapper;
import cn.hutool.core.date.DateTime;
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
@ -62,15 +61,6 @@ public interface StoreDetailMapper extends BaseMapper<StoreDetail> {
"from li_store_detail s where s.store_id=#{storeId}")
StoreAfterSaleAddressDTO getStoreAfterSaleAddressDTO(String storeId);
/**
* 获取店铺福禄配置DTO
*
* @param storeId 店铺ID
* @return 店铺店铺福禄配置DTO
*/
@Select("select s.app_secret_key,s.merchant_number,s.app_merchant_key from li_store_detail s where s.store_id =#{storeId}")
FuLuConfigureDTO getFuLuConfigureDTO(String storeId);
/**
* 获取待结算店铺列表
*

View File

@ -1,14 +1,12 @@
package cn.lili.controller.goods;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.fulu.core.utils.Test;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsOperationFuLuDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
@ -18,10 +16,6 @@ import cn.lili.modules.goods.entity.vos.StockWarningVO;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.service.StoreDetailService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import cn.lili.modules.store.service.StoreDetailService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -33,7 +27,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

View File

@ -3,7 +3,6 @@ package cn.lili.controller.settings;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.store.entity.dto.FuLuConfigureDTO;
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;