商品同步修改
This commit is contained in:
parent
1c60f938b6
commit
540820281d
@ -57,6 +57,9 @@ public interface PayService {
|
|||||||
@PostMapping(value = "/admin/pay/payController/editPayConsumeTrade")
|
@PostMapping(value = "/admin/pay/payController/editPayConsumeTrade")
|
||||||
boolean editPayConsumeTrade(@RequestBody Map params);
|
boolean editPayConsumeTrade(@RequestBody Map params);
|
||||||
|
|
||||||
|
@PostMapping(value = "/admin/pay/payController/saveOrUpdatePayUserResource")
|
||||||
|
boolean saveOrUpdatePayUserResource(@RequestBody PayUserResource params);
|
||||||
|
|
||||||
@PostMapping(value = "/admin/pay/payController/points")
|
@PostMapping(value = "/admin/pay/payController/points")
|
||||||
boolean points(@RequestParam(name = "user_id") Integer user_id,
|
boolean points(@RequestParam(name = "user_id") Integer user_id,
|
||||||
@RequestParam(name = "points") BigDecimal points,
|
@RequestParam(name = "points") BigDecimal points,
|
||||||
|
|||||||
@ -71,6 +71,12 @@ public class AccountUserBase implements Serializable {
|
|||||||
@ApiModelProperty(value = "快速登录码")
|
@ApiModelProperty(value = "快速登录码")
|
||||||
private String user_quickcode;
|
private String user_quickcode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户身份:0-个人身份;1-企业身份;")
|
||||||
|
private String user_type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "公司id")
|
||||||
|
private String user_company_id;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "用户权限集合")
|
@ApiModelProperty(value = "用户权限集合")
|
||||||
private List<AdminRightsGroup> roles;
|
private List<AdminRightsGroup> roles;
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
|
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||||
|
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||||
|
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||||
|
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.suisung.mall.common.pojo.req;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@ApiModel(description = "第三方会员同步请求参数")
|
||||||
|
public class SyncThirdMemberReq implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("会员手机号")
|
||||||
|
private String user_mobile;
|
||||||
|
@ApiModelProperty("会员昵称")
|
||||||
|
private String user_nickname;
|
||||||
|
@ApiModelProperty("会员真实姓名")
|
||||||
|
private String user_realname;
|
||||||
|
@ApiModelProperty("会员性别:1-男;2-女;")
|
||||||
|
private Integer user_gender;
|
||||||
|
@ApiModelProperty("会员生日 yyyy-MM-dd")
|
||||||
|
private String user_birthday;
|
||||||
|
@ApiModelProperty("会员等级:v1...v9")
|
||||||
|
private String user_level;
|
||||||
|
@ApiModelProperty("会员卡号")
|
||||||
|
private String user_level_card;
|
||||||
|
@ApiModelProperty("会员积分值")
|
||||||
|
private BigDecimal user_points;
|
||||||
|
@ApiModelProperty("会员余额")
|
||||||
|
private BigDecimal user_money;
|
||||||
|
@ApiModelProperty("加入时间")
|
||||||
|
private Date join_time;
|
||||||
|
}
|
||||||
@ -2,8 +2,12 @@ package com.suisung.mall.common.utils;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DateTimeUtils {
|
public class DateTimeUtils {
|
||||||
@ -11,4 +15,18 @@ public class DateTimeUtils {
|
|||||||
public static String formatDateTime(LocalDateTime localDateTime, String pattern) {
|
public static String formatDateTime(LocalDateTime localDateTime, String pattern) {
|
||||||
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
|
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Date parseDate(String dateString, String pattern) {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||||
|
try {
|
||||||
|
Date date = format.parse(dateString);
|
||||||
|
return date;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
// 设置年、月(注意:月份从 0 开始,即 0 表示一月)、日、时、分、秒
|
||||||
|
calendar.set(2000, 0, 1, 15, 30, 0);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,12 +7,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -223,6 +221,23 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成唯一码
|
||||||
|
* @param length
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String generateUniqueCode(int length) {
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
// 计算所需的字节数,根据 Base64 编码的特性,3 个字节编码为 4 个字符
|
||||||
|
int numBytes = (int) Math.ceil((length * 3.0 / 4.0));
|
||||||
|
byte[] randomBytes = new byte[numBytes];
|
||||||
|
secureRandom.nextBytes(randomBytes);
|
||||||
|
|
||||||
|
String base64 = Base64.getUrlEncoder().withoutPadding().encodeToString(randomBytes);
|
||||||
|
// 截取所需长度的子串
|
||||||
|
return base64.substring(0, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全地址去除省市区,保留详细地址
|
* 全地址去除省市区,保留详细地址
|
||||||
*
|
*
|
||||||
|
|||||||
@ -151,7 +151,17 @@ public class PayController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/saveOrUpdatePayUserResource", method = RequestMethod.POST)
|
||||||
|
public boolean saveOrUpdatePayUserResource(@RequestBody PayUserResource payUserResource) {
|
||||||
|
boolean flag;
|
||||||
|
try {
|
||||||
|
flag = payUserResourceService.saveOrUpdate(payUserResource);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取交易订单", notes = "获取交易订单")
|
@ApiOperation(value = "获取交易订单", notes = "获取交易订单")
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.suisung.mall.common.pojo.dto.ProductRecommendDTO;
|
|||||||
import com.suisung.mall.common.pojo.dto.ProductSearchDTO;
|
import com.suisung.mall.common.pojo.dto.ProductSearchDTO;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
||||||
|
import org.springframework.data.util.Pair;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -253,6 +254,7 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个商品基本信息
|
* 获取一个商品基本信息
|
||||||
|
*
|
||||||
* @param product_id
|
* @param product_id
|
||||||
* @param store_id
|
* @param store_id
|
||||||
* @return
|
* @return
|
||||||
@ -261,6 +263,7 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据店铺Id和商品货号,获取商品Id
|
* 根据店铺Id和商品货号,获取商品Id
|
||||||
|
*
|
||||||
* @param store_id
|
* @param store_id
|
||||||
* @param product_number
|
* @param product_number
|
||||||
* @return
|
* @return
|
||||||
@ -276,6 +279,8 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
|
|||||||
* @param storeId
|
* @param storeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean syncSxGoodsToShopProductBase(String storeId);
|
Boolean syncSxGoodsToShopProductBase(String storeId);
|
||||||
|
|
||||||
|
Pair<Boolean, String> saveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -680,6 +680,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
* @param shopProductAssistIndexList 辅助信息表
|
* @param shopProductAssistIndexList 辅助信息表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Pair<Boolean, String> saveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList) {
|
public Pair<Boolean, String> saveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList) {
|
||||||
Integer store_id = shopProductBase.getStore_id();
|
Integer store_id = shopProductBase.getStore_id();
|
||||||
if (store_id == null) {
|
if (store_id == null) {
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
package com.suisung.mall.shop.sync.controller;
|
package com.suisung.mall.shop.sync.controller;
|
||||||
|
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
|
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||||
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -19,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Api(tags = "第三方数据同步")
|
@Api(tags = "第三方数据同步")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/shop/sync/third")
|
@RequestMapping("/shop/sync/third")
|
||||||
@ -53,7 +56,7 @@ public class SyncThirdDataController {
|
|||||||
|
|
||||||
@ApiOperation(value = "会员数据同步", notes = "会员数据同步")
|
@ApiOperation(value = "会员数据同步", notes = "会员数据同步")
|
||||||
@RequestMapping(value = "/member", method = RequestMethod.POST)
|
@RequestMapping(value = "/member", method = RequestMethod.POST)
|
||||||
public ThirdApiRes syncMember(@RequestBody String reqBody) {
|
public ThirdApiRes syncMember(@RequestBody List<SyncThirdMemberReq> memberList) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,11 @@
|
|||||||
package com.suisung.mall.shop.sync.service;
|
package com.suisung.mall.shop.sync.service;
|
||||||
|
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
|
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface SyncThirdDataService {
|
public interface SyncThirdDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,4 +31,18 @@ public interface SyncThirdDataService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(JSONArray brandListJSON);
|
ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(JSONArray brandListJSON);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存商品记录
|
||||||
|
* @param goodsListJSON
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ThirdApiRes saveOrUpdateGoodsBatch(JSONArray goodsListJSON);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存会员记录
|
||||||
|
* @param memberList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ThirdApiRes saveOrUpdateMemberBatch(List<SyncThirdMemberReq> memberList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,29 +8,55 @@
|
|||||||
|
|
||||||
package com.suisung.mall.shop.sync.service.impl;
|
package com.suisung.mall.shop.sync.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.suisung.mall.common.api.StateCode;
|
||||||
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
|
import com.suisung.mall.common.feignService.AccountService;
|
||||||
|
import com.suisung.mall.common.feignService.PayService;
|
||||||
|
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||||
|
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductType;
|
import com.suisung.mall.common.modules.base.ShopBaseProductType;
|
||||||
|
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||||
|
import com.suisung.mall.common.modules.product.*;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||||
|
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||||
|
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductTypeService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductTypeService;
|
||||||
|
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
||||||
|
import com.suisung.mall.shop.product.service.impl.ShopProductBaseServiceImpl;
|
||||||
|
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||||
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.util.Pair;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(ShopProductBaseServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopBaseProductBrandService productBrandService;
|
private ShopBaseProductBrandService productBrandService;
|
||||||
|
|
||||||
@ -40,6 +66,20 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopBaseProductTypeService productTypeService;
|
private ShopBaseProductTypeService productTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AccountService accountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PayService payService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ShopProductBaseService shopProductBaseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ShopStoreBaseService shopStoreBaseService;
|
||||||
|
|
||||||
|
private int limitCnt = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存商品的分类
|
* 批量保存商品的分类
|
||||||
*
|
*
|
||||||
@ -59,13 +99,15 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
|||||||
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list != null && list.size() > 500) {
|
if (list != null && list.size() > limitCnt) {
|
||||||
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多500条!"));
|
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多"+limitCnt+"条!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String storeId = "3";
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
list.get(i).setStore_id("3"); // app 记录传进来
|
list.get(i).setStore_id(storeId); // app 记录传进来
|
||||||
list.get(i).setData_source(2); // 思迅数据来源
|
list.get(i).setData_source(2); // 思迅数据来源
|
||||||
list.get(i).setCategory_is_enable(1);
|
list.get(i).setCategory_is_enable(1);
|
||||||
|
|
||||||
@ -141,13 +183,15 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
|||||||
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goodBrandList != null && goodBrandList.size() > 500) {
|
if (goodBrandList != null && goodBrandList.size() > limitCnt) {
|
||||||
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多500条!"));
|
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多"+limitCnt+"条!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer storeId = 3;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < goodBrandList.size(); i++) {
|
for (int i = 0; i < goodBrandList.size(); i++) {
|
||||||
goodBrandList.get(i).setStore_id(3); // app 记录传进来
|
goodBrandList.get(i).setStore_id(storeId); // app 记录传进来
|
||||||
// 处理大分类字段
|
// 处理大分类字段
|
||||||
JSONObject o = (JSONObject) brandListJSON.get(i);
|
JSONObject o = (JSONObject) brandListJSON.get(i);
|
||||||
if (o != null && StrUtil.isNotBlank(o.getStr("category"))) {
|
if (o != null && StrUtil.isNotBlank(o.getStr("category"))) {
|
||||||
@ -165,4 +209,218 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
|||||||
|
|
||||||
return new ThirdApiRes().success("成功同步" + count + "条记录!", resp);
|
return new ThirdApiRes().success("成功同步" + count + "条记录!", resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存商品记录
|
||||||
|
*
|
||||||
|
* @param goodsListJSON
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ThirdApiRes saveOrUpdateGoodsBatch(JSONArray goodsListJSON) {
|
||||||
|
// TODO 验签、appid,必要参数判断
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(goodsListJSON)) {
|
||||||
|
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ShopBaseProductBrand> goodBrandList = JSONUtil.toList(goodsListJSON, ShopBaseProductBrand.class);
|
||||||
|
if (goodBrandList == null) {
|
||||||
|
return new ThirdApiRes().fail(1004, I18nUtil._("请求参数有误!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goodsListJSON.size() > limitCnt) {
|
||||||
|
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多"+limitCnt+"条!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer storeId = 3;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (JSONObject jsonObj : goodsListJSON.jsonIter()) {
|
||||||
|
Date currentDate = new Date();
|
||||||
|
|
||||||
|
Integer categoryId = Convert.toInt(jsonObj.get("first_category_name"), 0);
|
||||||
|
Integer storeIdInt = Convert.toInt(storeId);
|
||||||
|
ShopStoreBase store_row = shopStoreBaseService.get(storeId);
|
||||||
|
if (store_row == null) {
|
||||||
|
throw new ApiException(I18nUtil._("无法获取店铺信息!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ShopProductBase shopProductBase = new ShopProductBase();
|
||||||
|
shopProductBase.setProduct_sale_time(Convert.toDate(DateUtil.current() + 600)); //10分钟
|
||||||
|
shopProductBase.setStore_id(storeIdInt);
|
||||||
|
shopProductBase.setProduct_number((String) jsonObj.get("first_category_name"));
|
||||||
|
shopProductBase.setProduct_name((String) jsonObj.get("first_category_name"));
|
||||||
|
shopProductBase.setStore_name(store_row.getStore_name());
|
||||||
|
shopProductBase.setProduct_tips("");
|
||||||
|
shopProductBase.setProduct_video("");
|
||||||
|
shopProductBase.setTransport_type_id(StateCode.DELIVERY_TYPE_SAME_CITY);
|
||||||
|
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
|
||||||
|
shopProductBase.setProduct_inventory_lock(1002); //库存锁定(ENUM):1001-下单锁定;1002-支付锁定;
|
||||||
|
shopProductBase.setProduct_fx_enable(0); // 供应商是否允许批发市场分销
|
||||||
|
shopProductBase.setProduct_dist_enable(0); // 是否允许三级分销
|
||||||
|
shopProductBase.setProduct_from(1005);// 商品来源(ENUM):1000-发布;1001-天猫;1002-淘宝;1003-阿里巴巴;1004-京东;1005-思迅;
|
||||||
|
shopProductBase.setProduct_add_time(currentDate.getTime());
|
||||||
|
|
||||||
|
|
||||||
|
// ShopProductIndex
|
||||||
|
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
||||||
|
shopProductIndex.setProduct_add_time(currentDate.getTime());
|
||||||
|
shopProductIndex.setProduct_sale_time(DateUtil.current() + 600); //10分钟
|
||||||
|
shopProductIndex.setStore_category_ids(""); // 店铺分类编号(DOT)
|
||||||
|
shopProductIndex.setProduct_tags("");// 商品标签(DOT)
|
||||||
|
shopProductIndex.setBrand_id(0);
|
||||||
|
shopProductIndex.setProduct_name(shopProductBase.getProduct_name()); // 产品名称:店铺平台先在对用表中检索后通过id检索,检索使用
|
||||||
|
shopProductIndex.setProduct_name_index(shopProductIndex.getProduct_name()); // 名称索引关键字(DOT)
|
||||||
|
shopProductIndex.setCategory_id(categoryId); // 商品分类
|
||||||
|
shopProductIndex.setProduct_fx_enable(0); // 供应商是否允许批发市场分销
|
||||||
|
shopProductIndex.setProduct_dist_enable(0); // 是否允许三级分销
|
||||||
|
shopProductIndex.setStore_id(storeIdInt);
|
||||||
|
shopProductIndex.setStore_type(store_row.getStore_type());
|
||||||
|
shopProductIndex.setKind_id(StateCode.PRODUCT_KIND_ENTITY);// 实体商品
|
||||||
|
shopProductIndex.setStore_is_open(store_row.getStore_is_open());
|
||||||
|
shopProductIndex.setStore_is_selfsupport(store_row.getStore_is_selfsupport());
|
||||||
|
shopProductIndex.setStore_longitude(store_row.getStore_longitude());
|
||||||
|
shopProductIndex.setStore_latitude(store_row.getStore_latitude());
|
||||||
|
|
||||||
|
shopProductIndex.setCard_type_id(0);
|
||||||
|
shopProductIndex.setVoucher_activity_id("");
|
||||||
|
shopProductIndex.setCoupon_type_id(0);// product_assist_data // 辅助属性值列(DOT)
|
||||||
|
shopProductIndex.setProduct_transport_id(String.valueOf(StateCode.DELIVERY_TYPE_SAME_CITY));
|
||||||
|
|
||||||
|
ShopBaseProductCategory category_row = productCategoryService.get(categoryId);
|
||||||
|
if (ObjectUtil.isNotEmpty(category_row)) {
|
||||||
|
Integer type_id = category_row.getType_id();
|
||||||
|
shopProductIndex.setType_id(type_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// shop_product_data
|
||||||
|
ShopProductData shopProductData = new ShopProductData();
|
||||||
|
// product_id // 产品id
|
||||||
|
shopProductData.setProduct_edit_time(currentDate);
|
||||||
|
|
||||||
|
// shop_product_detail
|
||||||
|
ShopProductDetail shopProductDetail = new ShopProductDetail();
|
||||||
|
shopProductDetail.setProduct_detail("");
|
||||||
|
shopProductDetail.setProduct_param("");
|
||||||
|
shopProductDetail.setProduct_service("");
|
||||||
|
shopProductDetail.setProduct_tags("");
|
||||||
|
|
||||||
|
// shop_product_info
|
||||||
|
ShopProductInfo shopProductInfo = new ShopProductInfo();
|
||||||
|
shopProductInfo.setProduct_number((String) jsonObj.get("first_category_name"));// SPU商家编码:货号
|
||||||
|
shopProductInfo.setProduct_assist("");
|
||||||
|
shopProductInfo.setProduct_spec("");
|
||||||
|
shopProductInfo.setProduct_buy_limit(0); // 不限购
|
||||||
|
//商品规格
|
||||||
|
shopProductInfo.setSpec_ids("");
|
||||||
|
|
||||||
|
List<ShopProductItem> shopProductItemList = new ArrayList<>();
|
||||||
|
ShopProductItem shopProductItem = new ShopProductItem();
|
||||||
|
shopProductItem.setStore_id(storeIdInt);
|
||||||
|
shopProductItem.setCategory_id(categoryId);
|
||||||
|
shopProductItem.setItem_unit_price((BigDecimal) jsonObj.get("first_category_name"));
|
||||||
|
shopProductItem.setItem_advice_price((BigDecimal) jsonObj.get("first_category_name"));
|
||||||
|
shopProductItem.setItem_market_price((BigDecimal) jsonObj.get("first_category_name"));
|
||||||
|
shopProductItem.setItem_unit_points((BigDecimal) jsonObj.get("first_category_name"));
|
||||||
|
shopProductItem.setItem_quantity((Integer) jsonObj.get("first_category_name")); // 库存
|
||||||
|
shopProductItem.setItem_quantity_frozen(0);
|
||||||
|
shopProductItem.setItem_number((String) jsonObj.get("first_category_name"));// SKU商家编码
|
||||||
|
shopProductItem.setItem_barcode((String) jsonObj.get("first_category_name")); // 条形码正常情况下就是货号
|
||||||
|
shopProductItem.setItem_is_default(1);
|
||||||
|
shopProductItem.setItem_enable(1);
|
||||||
|
|
||||||
|
shopProductItemList.add(shopProductItem);
|
||||||
|
|
||||||
|
// 保存数据
|
||||||
|
Pair<Boolean, String> pair = shopProductBaseService.saveProduct(shopProductBase, shopProductIndex, shopProductData, shopProductDetail, shopProductInfo, shopProductItemList, new ArrayList<ShopProductImage>(), new ShopProductValidPeriod(), new ArrayList<ShopProductAssistIndex>());
|
||||||
|
if (!pair.getFirst()) {
|
||||||
|
logger.error(pair.getSecond());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> resp = new HashMap<>();
|
||||||
|
resp.put("count", count);
|
||||||
|
|
||||||
|
return new ThirdApiRes().success("成功同步" + count + "条记录!", resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存会员记录
|
||||||
|
*
|
||||||
|
* @param memberList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ThirdApiRes saveOrUpdateMemberBatch(List<SyncThirdMemberReq> memberList) {
|
||||||
|
if (CollUtil.isEmpty(memberList)) {
|
||||||
|
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
String storeId = "3";
|
||||||
|
if (memberList.size() > limitCnt) {
|
||||||
|
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多" + limitCnt + "条!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (SyncThirdMemberReq member : memberList) {
|
||||||
|
// account_user_base
|
||||||
|
AccountUserBase accountUserBase = new AccountUserBase();
|
||||||
|
accountUserBase.setUser_account(StringUtils.generateUniqueCode(8));
|
||||||
|
accountUserBase.setUser_nickname(member.getUser_nickname());
|
||||||
|
accountUserBase.setUser_state(2);// 状态(ENUM):0-锁定;1-未激活;2-已激活;
|
||||||
|
accountUserBase.setUser_is_admin(0);
|
||||||
|
accountUserBase.setStore_ids(storeId);
|
||||||
|
accountUserBase.setRights_group_id("0");// 普通用户
|
||||||
|
accountUserBase.setUser_type("0");
|
||||||
|
|
||||||
|
String user_key = IdUtil.simpleUUID();
|
||||||
|
String user_salt = IdUtil.simpleUUID();
|
||||||
|
String user_token = IdUtil.simpleUUID();
|
||||||
|
accountUserBase.setUser_salt(user_salt);
|
||||||
|
accountUserBase.setUser_token(user_token);
|
||||||
|
accountUserBase.setUser_key(user_key);
|
||||||
|
accountUserBase.setUser_password(SecureUtil.md5(user_salt + SecureUtil.md5(IdUtil.simpleUUID())));
|
||||||
|
|
||||||
|
Boolean success = accountService.saveOrUpdateUserBase(accountUserBase);
|
||||||
|
|
||||||
|
Integer userId = accountUserBase.getUser_id();
|
||||||
|
|
||||||
|
// account_user_info
|
||||||
|
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||||
|
accountUserInfo.setUser_id(userId);// todo
|
||||||
|
accountUserInfo.setUser_type_id(0);
|
||||||
|
accountUserInfo.setUser_mobile(member.getUser_mobile());
|
||||||
|
accountUserInfo.setUser_level_card(member.getUser_level_card());
|
||||||
|
//user_level_id
|
||||||
|
accountUserInfo.setUser_level_id(1); // todo select id
|
||||||
|
accountUserInfo.setUser_gender(member.getUser_gender());
|
||||||
|
accountUserInfo.setUser_mobile(member.getUser_mobile());
|
||||||
|
accountUserInfo.setUser_intl(CommonConstant.IDD_ZH_CN);
|
||||||
|
accountUserInfo.setUser_birthday(DateTimeUtils.parseDate(member.getUser_birthday(), "yyyy-MM-dd"));
|
||||||
|
success = accountService.saveOrUpdateUserInfo(accountUserInfo);
|
||||||
|
|
||||||
|
if (member.getUser_money() != null || member.getUser_points() != null) {
|
||||||
|
// 用户支付资源,积分,余额
|
||||||
|
PayUserResource payUserResource = new PayUserResource();
|
||||||
|
payUserResource.setUser_id(userId);
|
||||||
|
payUserResource.setUser_money(member.getUser_money());
|
||||||
|
payUserResource.setUser_money_frozen(BigDecimal.ZERO);
|
||||||
|
payUserResource.setUser_points(member.getUser_points());
|
||||||
|
payUserResource.setUser_points_frozen(BigDecimal.ZERO);
|
||||||
|
|
||||||
|
success = payService.saveOrUpdatePayUserResource(payUserResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(success) {count += 1;}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> resp = new HashMap<>();
|
||||||
|
resp.put("count", count);
|
||||||
|
|
||||||
|
return new ThirdApiRes().success("成功同步" + count + "条记录!", resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user