数据同步
This commit is contained in:
parent
98f34bed3a
commit
aca19864ba
@ -147,6 +147,7 @@ public class LakalaServiceImpl implements LakalaService {
|
||||
V3LabsTradePreorderWechatBus wechatBus = new V3LabsTradePreorderWechatBus();
|
||||
wechatBus.setSubAppid("wx5a73f844dac0da5c"); // 小程序appId
|
||||
wechatBus.setUserId("oDVKR7T0qxg6O8tqIL9SgY6LXqqQ"); // 微信 openId
|
||||
wechatBus.setDeviceInfo("WEB"); // 终端设备号(门店号或收银设备ID),注意:PC网页或JSAPI支付请传”WEB”
|
||||
v3LabsTransPreorderWechatReq.setAccBusiFields(wechatBus);
|
||||
|
||||
try {
|
||||
@ -213,6 +214,7 @@ public class LakalaServiceImpl implements LakalaService {
|
||||
V3LabsTradePreorderWechatBus wechatBus = new V3LabsTradePreorderWechatBus();
|
||||
wechatBus.setSubAppid(xcxAppId); // 小程序appId
|
||||
wechatBus.setUserId(openId); // 微信 openId
|
||||
wechatBus.setDeviceInfo("WEB"); // 终端设备号(门店号或收银设备ID),注意:PC网页或JSAPI支付请传”WEB”
|
||||
v3LabsTransPreorderWechatReq.setAccBusiFields(wechatBus);
|
||||
|
||||
try {
|
||||
|
||||
@ -15,7 +15,6 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@ -58,33 +57,24 @@ import java.util.*;
|
||||
@Service
|
||||
public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
private final Logger logger = LoggerFactory.getLogger(ShopProductBaseServiceImpl.class);
|
||||
|
||||
private final int limitCnt = 300;
|
||||
@Autowired
|
||||
private ShopBaseProductBrandService productBrandService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseProductCategoryService productCategoryService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseProductTypeService productTypeService;
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductBaseService shopProductBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
|
||||
@Autowired
|
||||
private SyncAppService syncAppService;
|
||||
|
||||
private final int limitCnt = 300;
|
||||
|
||||
/**
|
||||
* 批量保存商品的分类
|
||||
*
|
||||
@ -121,30 +111,76 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
|
||||
JSONObject o = (JSONObject) categoryListJSON.get(i);
|
||||
if (o != null) {
|
||||
// 处理父类字段 产品分类
|
||||
if (StrUtil.isNotBlank(o.getStr("parent_name"))) {
|
||||
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("parent_name"));
|
||||
if (cate != null) {
|
||||
list.get(i).setParent_id(cate.getCategory_id());
|
||||
} else {
|
||||
// TODO 新增一个分类
|
||||
list.get(i).setParent_id(0);
|
||||
}
|
||||
} else {
|
||||
list.get(i).setParent_id(0);
|
||||
}
|
||||
|
||||
// 处理商品类型(强调共性)
|
||||
if (StrUtil.isNotBlank(o.getStr("type_name"))) {
|
||||
ShopBaseProductType productType = productTypeService.getProductTypeByName(o.getStr("type_name"));
|
||||
// 重要:分类类型处理(强调共性)
|
||||
Integer typeId = 1001;
|
||||
if (StrUtil.isNotBlank(o.getStr("product_type"))) {
|
||||
ShopBaseProductType productType = productTypeService.getProductTypeByName(o.getStr("product_type"));
|
||||
if (productType != null) {
|
||||
list.get(i).setType_id(productType.getType_id());
|
||||
} else {
|
||||
// TODO 新增一个类型
|
||||
// 新增一个类型
|
||||
ShopBaseProductType newProductType = new ShopBaseProductType();
|
||||
newProductType.setType_name(o.getStr("product_type"));
|
||||
newProductType.setType_buildin(0);
|
||||
|
||||
if(productTypeService.save(newProductType)){
|
||||
typeId = newProductType.getType_id();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list.get(i).setType_id(1001);
|
||||
|
||||
list.get(i).setType_id(typeId);
|
||||
}
|
||||
|
||||
|
||||
// 处理(第一级)父类字段 产品分类
|
||||
Integer firstParentId = 0;
|
||||
if (StrUtil.isNotBlank(o.getStr("first_category_name"))) {
|
||||
// TODO storeId 不判断一下吗?
|
||||
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("first_category_name"));
|
||||
if (cate != null) {
|
||||
list.get(i).setParent_id(cate.getCategory_id());
|
||||
} else {
|
||||
// 新增一个(第一级)父类
|
||||
ShopBaseProductCategory firstCate = new ShopBaseProductCategory();
|
||||
firstCate.setCategory_name(o.getStr("first_category_name"));
|
||||
firstCate.setParent_id(0);
|
||||
firstCate.setStore_id(storeId);
|
||||
firstCate.setType_id(typeId);
|
||||
firstCate.setData_source(2);
|
||||
if (productCategoryService.saveOrUpdate(firstCate)){
|
||||
// 当前子分类的父类id
|
||||
firstParentId = firstCate.getId();
|
||||
list.get(i).setParent_id(firstParentId);
|
||||
}
|
||||
}
|
||||
|
||||
list.get(i).setParent_id(firstParentId);
|
||||
}
|
||||
|
||||
// 处理(第二级)父类字段 产品分类
|
||||
if (StrUtil.isNotBlank(o.getStr("second_category_name"))) {
|
||||
// TODO storeId 不判断一下吗?
|
||||
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("second_category_name"));
|
||||
if (cate != null) {
|
||||
list.get(i).setParent_id(cate.getCategory_id());
|
||||
} else {
|
||||
// 新增一个(第二级)父类
|
||||
ShopBaseProductCategory secondCate = new ShopBaseProductCategory();
|
||||
secondCate.setCategory_name(o.getStr("second_category_name"));
|
||||
secondCate.setParent_id(firstParentId);
|
||||
secondCate.setStore_id(storeId);
|
||||
secondCate.setType_id(typeId);
|
||||
secondCate.setData_source(2);
|
||||
if (productCategoryService.saveOrUpdate(secondCate)){
|
||||
// 当前子分类的第二级父类id
|
||||
list.get(i).setParent_id(secondCate.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理商品类型
|
||||
|
||||
}
|
||||
|
||||
ShopBaseProductCategory productCategoryTemp = productCategoryService.getCategoryByName(list.get(i).getParent_id(), list.get(i).getCategory_name(), list.get(i).getStore_id());
|
||||
@ -189,9 +225,8 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
if (syncApp == null) {
|
||||
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||
}
|
||||
|
||||
String storeId = syncApp.getStore_id();
|
||||
|
||||
|
||||
List<ShopBaseProductBrand> goodBrandList = JSONUtil.toList(brandListJSON, ShopBaseProductBrand.class);
|
||||
if (goodBrandList == null) {
|
||||
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
||||
@ -201,16 +236,17 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多" + limitCnt + "条!"));
|
||||
}
|
||||
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < goodBrandList.size(); i++) {
|
||||
goodBrandList.get(i).setStore_id(Integer.valueOf(storeId)); // app 记录传进来
|
||||
// 处理大分类字段
|
||||
JSONObject o = (JSONObject) brandListJSON.get(i);
|
||||
if (o != null && StrUtil.isNotBlank(o.getStr("category"))) {
|
||||
// category 一般是父分类名
|
||||
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("category"));
|
||||
if (cate != null) {
|
||||
goodBrandList.get(i).setCategory_id(cate.getCategory_id());
|
||||
} else {
|
||||
// TODO 如果没有分类,是否新建?
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,13 +449,13 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
|
||||
// 新增用户记录后,不知道有没有返回 userId ?
|
||||
Integer userId = accountUserBase2.getUser_id();
|
||||
if(userId==null || userId<=0){
|
||||
if (userId == null || userId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// account_user_info
|
||||
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||
accountUserInfo.setUser_id(userId);// todo
|
||||
accountUserInfo.setUser_id(userId);
|
||||
accountUserInfo.setUser_type_id(0);
|
||||
accountUserInfo.setUser_mobile(member.getUser_mobile());
|
||||
accountUserInfo.setUser_level_card(member.getUser_level_card());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user