数据同步

This commit is contained in:
Jack 2025-01-22 00:19:23 +08:00
parent dbef829b38
commit 98f34bed3a
11 changed files with 342 additions and 45 deletions

View File

@ -342,6 +342,16 @@ public class AccountController {
return accountUserBaseService.saveOrUpdate(accountUserBase);
}
@RequestMapping(value = "/saveOrUpdateUserBase2", method = RequestMethod.POST)
public AccountUserBase saveOrUpdateUserBase2(@RequestBody AccountUserBase accountUserBase) {
return accountUserBaseService.saveOrUpdate2(accountUserBase).getSecond();
}
@RequestMapping(value = "/existByNickname", method = RequestMethod.POST)
public Boolean existByNickname(@RequestParam(name = "nickname") String nickname, @RequestParam(name = "storeId") String storeId) {
return accountUserBaseService.existByNickname(nickname, storeId);
}
@RequestMapping(value = "/editPassword", method = RequestMethod.POST)
public CommonResult editPassword(@RequestParam(name = "user_id") Integer user_id,
@RequestParam(name = "user_password") String user_password) {

View File

@ -4,6 +4,7 @@ import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.domain.UserDto;
import com.suisung.mall.common.modules.account.AccountUserBase;
import com.suisung.mall.core.web.service.IBaseService;
import org.springframework.data.util.Pair;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -143,4 +144,14 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
void callbackGoogle(HttpServletResponse response, String code);
boolean changePassword(String old_password, String password);
/**
* 判断店铺某个昵称是否存在
* @param nickname
* @param storeId
* @return
*/
Boolean existByNickname(String nickname, String storeId);
Pair<Boolean, AccountUserBase> saveOrUpdate2(AccountUserBase entity);
}

View File

@ -11,8 +11,13 @@ import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl;
@ -54,11 +59,13 @@ import com.suisung.mall.common.utils.pojo.dto.EmailDTO;
import com.suisung.mall.core.web.service.CloundService;
import com.suisung.mall.core.web.service.RedisService;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.sun.javafx.geom.ConcentricShapePair;
import io.seata.common.util.StringUtils;
import io.seata.spring.annotation.GlobalTransactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -2935,4 +2942,39 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
return true;
}
/**
* 判断店铺某个昵称是否存在
*
* @param nickname
* @param storeId
* @return
*/
@Override
public Boolean existByNickname(String nickname, String storeId) {
if (StrUtil.isBlank(nickname)) {
return false;
}
LambdaQueryWrapper<AccountUserBase> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountUserBase::getUser_nickname, nickname);
queryWrapper.eq(AccountUserBase::getStore_ids, storeId);
return count(queryWrapper) > 0;
}
@Override
public Pair<Boolean, AccountUserBase> saveOrUpdate2(AccountUserBase entity) {
Boolean flag = false;
if (null != entity) {
Class<?> cls = entity.getClass();
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!", new Object[0]);
String keyProperty = tableInfo.getKeyProperty();
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!", new Object[0]);
Object idVal = ReflectionKit.getFieldValue(entity, tableInfo.getKeyProperty());
flag = !com.baomidou.mybatisplus.core.toolkit.StringUtils.checkValNull(idVal) && !Objects.isNull(this.getById((Serializable)idVal)) ? this.edit(entity) : this.add(entity);
}
return Pair.of(flag, entity);
}
}

View File

@ -4,10 +4,7 @@ import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.account.*;
import com.suisung.mall.common.pojo.output.TimelineOutput;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
@ -134,6 +131,18 @@ public interface AccountService {
@PostMapping(value = "/admin/account/accountController/saveOrUpdateUserBase")
boolean saveOrUpdateUserBase(@RequestBody AccountUserBase accountUserBase);
@RequestMapping(value = "/admin/account/accountController/saveOrUpdateUserBase2", method = RequestMethod.POST)
AccountUserBase saveOrUpdateUserBase2(@RequestBody AccountUserBase accountUserBase);
/**
* 判断一个店铺是否存在某个昵称的会员
* @param nickname
* @param storeId
* @return
*/
@PostMapping(value = "/admin/account/accountController/existByNickname")
boolean existByNickname(@RequestParam(name = "nickname") String nickname, @RequestParam(name = "storeId") String storeId);
@PostMapping(value = "/admin/account/accountController/editPassword")
CommonResult editPassword(@RequestParam(name = "user_id") Integer user_id,
@RequestParam(name = "user_password") String user_password);

View File

@ -0,0 +1,39 @@
/*
* 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.res;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 微信场景下返回acc_resp_fields域
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PayAccRespFieldsRes implements Serializable {
private String prepay_id;
private String pay_sign;
private String app_id;
private String time_stamp;
private String nonce_str;
@JsonProperty("package")
private String pkg;
private String sign_type;
private String partner_id;
private String sub_mch_id;
private String code_image;
private String code;
private String redirect_url;
private String best_pay_info;
}

View File

@ -9,11 +9,34 @@
package com.suisung.mall.pay.service;
import cn.hutool.json.JSONObject;
import com.suisung.mall.common.pojo.res.PayAccRespFieldsRes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface LakalaService {
/**
* 初始化拉卡拉支付参数
*/
void doInit();
JSONObject transPreOrder(HttpServletRequest request, HttpServletResponse response, String orderId);
/**
* 拉卡拉预下单
*
* @param merchantNo 商户号
* @param termNo 终端号
* @param xcxAppId 小程序appid
* @param openId openid
* @param orderId 订单号
* @param subject 订单标题
* @param totalAmount 订单金额
* @param notifyURL 回调地址
* @param requestIP 请求ip
* @param remark 备注
* @return
*/
PayAccRespFieldsRes transPreOrder(String merchantNo, String termNo, String xcxAppId, String openId, String orderId, String subject, String totalAmount, String notifyURL, String requestIP, String remark);
}

View File

@ -9,6 +9,7 @@
package com.suisung.mall.pay.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.ijpay.core.kit.IpKit;
import com.lkl.laop.sdk.Config2;
@ -18,6 +19,8 @@ import com.lkl.laop.sdk.request.V3LabsTransPreorderRequest;
import com.lkl.laop.sdk.request.model.V3LabsTradeLocationInfo;
import com.lkl.laop.sdk.request.model.V3LabsTradePreorderWechatBus;
import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.pojo.res.PayAccRespFieldsRes;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.pay.service.LakalaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -154,7 +157,77 @@ public class LakalaServiceImpl implements LakalaService {
return JSONUtil.parseObj(responseStr);
} catch (SDKException e) {
log.error("transPreOrder error", e);
throw new ApiException("支付失败:",e);
throw new ApiException(I18nUtil._("获取公众号绑定信息失败!"), e);
}
}
/**
* 拉卡拉预下单
*
* @param merchantNo 商户号
* @param termNo 终端号
* @param xcxAppId 小程序appid
* @param openId openid
* @param orderId 订单号
* @param subject 订单标题
* @param totalAmount 订单金额
* @param notifyURL 回调地址
* @param requestIP 请求ip
* @param remark 备注
* @return
* */
@Override
public PayAccRespFieldsRes transPreOrder(String merchantNo, String termNo, String xcxAppId, String openId, String orderId, String subject, String totalAmount, String notifyURL, String requestIP, String remark) {
// 1. 配置初始化
doInit();
if (StrUtil.isBlank(merchantNo)) {
merchantNo = this.merchantNo;
}
if (StrUtil.isBlank(termNo)) {
termNo = this.termNo;
}
//2. 装配数据
/*** 微信主扫场景示例 */
V3LabsTransPreorderRequest v3LabsTransPreorderWechatReq = new V3LabsTransPreorderRequest();
v3LabsTransPreorderWechatReq.setMerchantNo(merchantNo);
v3LabsTransPreorderWechatReq.setTermNo(termNo);
v3LabsTransPreorderWechatReq.setOutTradeNo(orderId);
v3LabsTransPreorderWechatReq.setSubject(subject);
//微信WECHAT 支付宝ALIPAY 银联UQRCODEPAY 翼支付: BESTPAY 苏宁易付宝: SUNING 拉卡拉支付账户LKLACC 网联小钱包NUCSPAY 京东钱包JD
v3LabsTransPreorderWechatReq.setAccountType("WECHAT");
// 41:NATIVEALIPAY云闪付支持京东白条分期51:JSAPI微信公众号支付支付宝服务窗支付银联JS支付翼支付JS支付拉卡拉钱包支付71:微信小程序支付 61:APP支付微信APP支付
v3LabsTransPreorderWechatReq.setTransType("51");
v3LabsTransPreorderWechatReq.setTotalAmount(totalAmount);
v3LabsTransPreorderWechatReq.setNotifyUrl(notifyURL);
v3LabsTransPreorderWechatReq.setRemark(remark);
//地址位置信息
V3LabsTradeLocationInfo v3LabsTradePreorderLocationInfo = new V3LabsTradeLocationInfo(requestIP);
v3LabsTransPreorderWechatReq.setLocationInfo(v3LabsTradePreorderLocationInfo);
//微信主扫场景下 acc_busi_fields 域内容
V3LabsTradePreorderWechatBus wechatBus = new V3LabsTradePreorderWechatBus();
wechatBus.setSubAppid(xcxAppId); // 小程序appId
wechatBus.setUserId(openId); // 微信 openId
v3LabsTransPreorderWechatReq.setAccBusiFields(wechatBus);
try {
//3. 发送请求
String responseStr = LKLSDK.httpPost(v3LabsTransPreorderWechatReq);
if (StrUtil.isBlank(responseStr)) {
return null;
}
PayAccRespFieldsRes res = JSONUtil.parseObj(responseStr).get("acc_resp_fields", PayAccRespFieldsRes.class);
//4. 响应
return res;
} catch (SDKException e) {
log.error("拉卡拉支付出错:", e);
throw new ApiException(I18nUtil._("支付失败:"), e);
}
}

View File

@ -32,7 +32,6 @@ import com.ijpay.wxpay.WxPayApi;
import com.ijpay.wxpay.WxPayApiConfig;
import com.ijpay.wxpay.WxPayApiConfigKit;
import com.ijpay.wxpay.enums.WxApiType;
import com.ijpay.wxpay.enums.WxDomain;
import com.ijpay.wxpay.model.RefundModel;
import com.ijpay.wxpay.model.UnifiedOrderModel;
import com.suisung.mall.common.api.*;
@ -48,6 +47,7 @@ import com.suisung.mall.common.modules.order.ShopOrderInfo;
import com.suisung.mall.common.modules.order.ShopOrderReturn;
import com.suisung.mall.common.modules.pay.*;
import com.suisung.mall.common.modules.pay.dto.ItemActivityInfoDTO;
import com.suisung.mall.common.pojo.res.PayAccRespFieldsRes;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.LogUtil;
@ -113,6 +113,8 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
private DataSourceTransactionManager transactionManager;
@Autowired
private TransactionDefinition transactionDefinition;
@Autowired
private LakalaService lakalaService;
/**
* 获取支付密码
@ -253,8 +255,8 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
trade_row.setTrade_title(I18nUtil._("在线购物"));
trade_row.setTrade_desc(I18nUtil._("在线购物"));
}
// 重要支付
toPay(request, response, trade_row, payTypeBean);
// 微信支付重要
executeMultiChannelPayment(request, response, trade_row, payTypeBean);
return;
} else {
// 处理订单支付成功
@ -385,12 +387,14 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
}
/**
* 支付
* 多渠道支付
*
* @param trade_row
* @param request
* @param response
* @param trade_row 支付交易记录
* @param payTypeBean 支付类型实例
*/
// todo 多种支付方式
private void toPay(HttpServletRequest request, HttpServletResponse response, PayConsumeTrade trade_row, PayTypeBean payTypeBean) {
private void executeMultiChannelPayment(HttpServletRequest request, HttpServletResponse response, PayConsumeTrade trade_row, PayTypeBean payTypeBean) {
Integer trade_is_paid = trade_row.getTrade_is_paid();
if (ObjectUtil.equal(trade_is_paid, StateCode.ORDER_PAID_STATE_YES)) {
@ -417,7 +421,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
aliPcPay(response, trade_row, payTypeBean);
break;
case WX_XCX:
// 小程序
// 小程序 appId
String wechat_xcx_app_id = accountBaseConfigService.getConfig("wechat_xcx_app_id");
wxJSAPIPay(request, response, trade_row, payTypeBean.getOpenid(), wechat_xcx_app_id);
break;
@ -562,6 +566,87 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
setResponseBody(response, data);
}
/**
* 拉卡拉第三方支付
*
* @param request
* @param response
* @param payConsumeTrade
* @param openId
* @param appId
*/
public void lakalaJSAPIPay(HttpServletRequest request, HttpServletResponse response, PayConsumeTrade payConsumeTrade, String openId, String appId) {
// 商户订单号
String out_trade_no = payConsumeTrade.getOrder_id();
String subject = payConsumeTrade.getTrade_title();
String trade_remark = ObjectUtil.defaultIfNull(payConsumeTrade.getTrade_remark(), "");
// 实际付款金额
String total_fee = StrUtil.toString(NumberUtil.mul(NumberUtil.round(payConsumeTrade.getTrade_payment_amount(), 2), 100).intValue());
// 微信支付配置值
WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig();
// https://mall.gpxscs.cn/mobile/pay/index
String domain = wxPayApiConfig.getDomain();
String requestIP = IpKit.getRealIp(request);
String notifyUrl = domain + "/wxPay_notify_url";
// 初始化拉卡拉支付配置
PayAccRespFieldsRes field = lakalaService.transPreOrder(null, null,
appId, openId, out_trade_no, subject, total_fee,
notifyUrl,
requestIP, trade_remark);
// 统一下单请求参数构建
Map<String, String> params = UnifiedOrderModel.builder()
.appid(field.getApp_id())
.mch_id(field.getSub_mch_id())
.openid(openId)
.out_trade_no(out_trade_no)
.total_fee(total_fee) // 订单总金额单位为分
.notify_url(notifyUrl)
.trade_type(TradeType.JSAPI.getTradeType())
.spbill_create_ip(requestIP)
.time_start(DateUtil.format(new Date(), "yyyyMMddHHmmss"))
.nonce_str(field.getNonce_str())
.body(subject) // 商品描述
.goods_tag(trade_remark)// 订单优惠标记
.attach("") //自定义数据说明
.build()
.createSign(wxPayApiConfig.getPartnerKey(), SignType.HMACSHA256);
String xmlResult = WxPayApi.pushOrder(false, params);
Map<String, String> resultMap = WxPayKit.xmlToMap(xmlResult);
String returnCode = resultMap.get("return_code");
String returnMsg = resultMap.get("return_msg");
Map data = new HashMap();
data.put("code", 1);
data.put("data", new Object());
data.put("message", returnMsg);
if (!WxPayKit.codeIsOk(returnCode)) {
setResponseBody(response, data);
return;
}
String resultCode = resultMap.get("result_code");
if (!WxPayKit.codeIsOk(resultCode)) {
setResponseBody(response, data);
return;
}
// 预支付订单 Id
String prepayId = resultMap.get("prepay_id");
Map<String, Object> packageParams = Convert.toMap(String.class, Object.class, WxPayKit.prepayIdCreateSign(prepayId, appId, wxPayApiConfig.getPartnerKey(), SignType.HMACSHA256));
data.put("status", 200);
Map result = new HashMap();
result.put("data", packageParams);
result.put("statusCode", 200);
data.put("data", result);
setResponseBody(response, data);
}
/**
* 设置响应 body
*
@ -578,7 +663,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
writer.close();
response.flushBuffer();
} catch (IOException e) {
logger.error("响应body数据IO异常" + e.getMessage(), e);
logger.error("响应body数据IO异常{}", e);
writer.close();
}

View File

@ -17,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@ -24,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/shop/sync/third")
public class SyncThirdDataController {
@Autowired
@Resource
private SyncThirdDataService syncThirdDataService;
@ -60,8 +61,8 @@ public class SyncThirdDataController {
public ThirdApiRes syncGoods(HttpServletRequest request,
@RequestParam String appKey,
@RequestParam String sign,
@RequestBody String reqBody) {
return null;
@RequestBody JSONArray goodsListJSON) {
return syncThirdDataService.saveOrUpdateGoodsBatch(appKey, sign, goodsListJSON);
}
@ApiOperation(value = "会员数据同步", notes = "会员数据同步")
@ -70,7 +71,7 @@ public class SyncThirdDataController {
@RequestParam String appKey,
@RequestParam String sign,
@RequestBody List<SyncThirdMemberReq> memberList) {
return null;
return syncThirdDataService.saveOrUpdateMemberBatch(appKey, sign, memberList);
}

View File

@ -22,7 +22,7 @@ public interface SyncThirdDataService {
* @param categoryListJSON
* @return
*/
ThirdApiRes saveOrUpdateShopBaseProductCategoryBatch(String appId, String sign, JSONArray categoryListJSON);
ThirdApiRes saveOrUpdateShopBaseProductCategoryBatch(String appKey, String sign, JSONArray categoryListJSON);
/**
* 批量保存商品品牌记录
@ -30,19 +30,19 @@ public interface SyncThirdDataService {
* @param brandListJSON
* @return
*/
ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(String appId, String sign, JSONArray brandListJSON);
ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(String appKey, String sign, JSONArray brandListJSON);
/**
* 批量保存商品记录
* @param goodsListJSON
* @return
*/
ThirdApiRes saveOrUpdateGoodsBatch(String appId, String sign, JSONArray goodsListJSON);
ThirdApiRes saveOrUpdateGoodsBatch(String appKey, String sign, JSONArray goodsListJSON);
/**
* 批量保存会员记录
* @param memberList
* @return
*/
ThirdApiRes saveOrUpdateMemberBatch(String appId, String sign, List<SyncThirdMemberReq> memberList);
ThirdApiRes saveOrUpdateMemberBatch(String appKey, String sign, List<SyncThirdMemberReq> memberList);
}

View File

@ -92,13 +92,13 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
* @return
*/
@Override
public ThirdApiRes saveOrUpdateShopBaseProductCategoryBatch(String appId, String sign, JSONArray categoryListJSON) {
if (StrUtil.isBlank(appId) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(categoryListJSON)) {
public ThirdApiRes saveOrUpdateShopBaseProductCategoryBatch(String appKey, String sign, JSONArray categoryListJSON) {
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(categoryListJSON)) {
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
}
// 验签appid必要参数判断
SyncApp syncApp = syncAppService.checkAppSign(appId, sign, categoryListJSON.toString());
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, categoryListJSON.toString());
if (syncApp == null) {
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
}
@ -179,13 +179,13 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
* @return
*/
@Override
public ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(String appId, String sign, JSONArray brandListJSON) {
if (StrUtil.isBlank(appId) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(brandListJSON)) {
public ThirdApiRes saveOrUpdateShopBaseProductBrandBatch(String appKey, String sign, JSONArray brandListJSON) {
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(brandListJSON)) {
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
}
// 验签appid必要参数判断
SyncApp syncApp = syncAppService.checkAppSign(appId, sign, brandListJSON.toString());
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, brandListJSON.toString());
if (syncApp == null) {
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
}
@ -230,23 +230,18 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
* @return
*/
@Override
public ThirdApiRes saveOrUpdateGoodsBatch(String appId, String sign, JSONArray goodsListJSON) {
if (StrUtil.isBlank(appId) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(goodsListJSON)) {
public ThirdApiRes saveOrUpdateGoodsBatch(String appKey, String sign, JSONArray goodsListJSON) {
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(goodsListJSON)) {
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
}
// 验签appid必要参数判断
SyncApp syncApp = syncAppService.checkAppSign(appId, sign, goodsListJSON.toString());
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, goodsListJSON.toString());
if (syncApp == null) {
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
}
String storeId = syncApp.getStore_id();
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 + "条!"));
}
@ -279,7 +274,6 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
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());
@ -372,19 +366,18 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
* @return
*/
@Override
public ThirdApiRes saveOrUpdateMemberBatch(String appId, String sign, List<SyncThirdMemberReq> memberList) {
if (StrUtil.isBlank(appId) || StrUtil.isBlank(sign) || CollUtil.isEmpty(memberList)) {
public ThirdApiRes saveOrUpdateMemberBatch(String appKey, String sign, List<SyncThirdMemberReq> memberList) {
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || CollUtil.isEmpty(memberList)) {
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
}
// 验签appid必要参数判断
SyncApp syncApp = syncAppService.checkAppSign(appId, sign, JSONUtil.toJsonStr(memberList));
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, JSONUtil.toJsonStr(memberList));
if (syncApp == null) {
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
}
String storeId = syncApp.getStore_id();
if (memberList.size() > limitCnt) {
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多" + limitCnt + "条!"));
}
@ -398,9 +391,10 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
accountUserBase.setUser_state(2);// 状态(ENUM):0-锁定;1-未激活;2-已激活;
accountUserBase.setUser_is_admin(0);
accountUserBase.setStore_ids(storeId);
accountUserBase.setRights_group_id("0");// 普通用户
accountUserBase.setRights_group_id("0");// 普通用户不是商家
accountUserBase.setUser_type("0");
// 默认给了随机密码和盐token
String user_key = IdUtil.simpleUUID();
String user_salt = IdUtil.simpleUUID();
String user_token = IdUtil.simpleUUID();
@ -409,9 +403,19 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
accountUserBase.setUser_key(user_key);
accountUserBase.setUser_password(SecureUtil.md5(user_salt + SecureUtil.md5(IdUtil.simpleUUID())));
Boolean success = accountService.saveOrUpdateUserBase(accountUserBase);
// 判断店铺是不是存在该昵称的会员了
Boolean exists = accountService.existByNickname(member.getUser_nickname(), storeId);
if (exists) {
continue;
}
Integer userId = accountUserBase.getUser_id();
AccountUserBase accountUserBase2 = accountService.saveOrUpdateUserBase2(accountUserBase);
// 新增用户记录后不知道有没有返回 userId
Integer userId = accountUserBase2.getUser_id();
if(userId==null || userId<=0){
continue;
}
// account_user_info
AccountUserInfo accountUserInfo = new AccountUserInfo();
@ -425,7 +429,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
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);
boolean success = accountService.saveOrUpdateUserInfo(accountUserInfo);
if (member.getUser_money() != null || member.getUser_points() != null) {
// 用户支付资源积分余额