订单字段优化

This commit is contained in:
Jack 2025-04-14 10:56:24 +08:00
parent 37c3333665
commit 80563a0785
14 changed files with 611 additions and 65 deletions

View File

@ -71,6 +71,9 @@ public class EsignContract implements Serializable {
@ApiModelProperty(value = "店铺编号")
private String store_id;
@ApiModelProperty(value = "代理商ID(esign_platform_info表id)0-表示只有平台方,没有代理商")
private Long distributor_id;
@ApiModelProperty(value = "签署流程ID")
private String sign_flow_id;

View File

@ -45,6 +45,7 @@ public class LklLedgerMember implements Serializable {
private String audit_status;
private String audit_status_text;
private String remark;
private Long mch_id;
private String version;
private Date created_at;
private Date updated_at;

View File

@ -48,6 +48,7 @@ public class LklLedgerReceiver implements Serializable {
private String acct_clear_bank_code;
private String attach_list;
private String settle_type;
private Long platform_id;
private String version;
private Integer status;
private Date created_at;

View File

@ -42,6 +42,12 @@ public class ShopMerchEntry implements Serializable {
@ApiModelProperty(value = "商家店铺的名称")
private String store_name;
@ApiModelProperty(value = "商家店铺LOGO图片")
private String store_logo;
@ApiModelProperty(value = "商家店铺招牌图片")
private String store_banner;
@ApiModelProperty(value = "入驻商家的联系人姓名")
private String contact_name;
@ -69,6 +75,12 @@ public class ShopMerchEntry implements Serializable {
@ApiModelProperty(value = "入驻商家店铺维度")
private String store_latitude;
@ApiModelProperty(value = "店铺经营介绍")
private String sales_info;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "入驻商家店铺所在的省")
private String province_id;
@ -78,6 +90,9 @@ public class ShopMerchEntry implements Serializable {
@ApiModelProperty(value = "入驻商家店铺所在的县区")
private String county_id;
@ApiModelProperty(value = "店铺地区 省份/城市/乡县")
private String store_area;
@ApiModelProperty(value = "入驻商家店铺的详细地址")
private String store_address;
@ -108,6 +123,12 @@ public class ShopMerchEntry implements Serializable {
@ApiModelProperty(value = "入驻商家许可证图片的存储路径")
private String license_image;
@ApiModelProperty(value = "商家营业执照有效开始时间")
private String biz_license_period_begin;
@ApiModelProperty(value = "商家营业执照有效结束时间")
private String biz_license_period_end;
@ApiModelProperty(value = "入驻商家的法人姓名")
private String legal_person_name;
@ -123,21 +144,54 @@ public class ShopMerchEntry implements Serializable {
@ApiModelProperty(value = "入驻商家法人身份证反面图片的存储路径")
private String legal_person_id_images2;
@ApiModelProperty(value = "企业法人身份证居住地址")
private String legal_person_id_addr;
@ApiModelProperty(value = "企业法人身份证有效期开始时间")
private String legal_person_id_period_begin;
@ApiModelProperty(value = "企业法人身份证有效期结束时间")
private String legal_person_id_period_end;
@ApiModelProperty(value = "个人入驻时的身份证号码")
private String individual_id_number;
@ApiModelProperty(value = "个人入驻时身份证正面图片的存储路径")
@ApiModelProperty(value = "个人身份证姓名")
private String individual_id_name;
@ApiModelProperty(value = "个人身份证正面图片的存储路径")
private String individual_id_images;
@ApiModelProperty(value = "个人入驻时身份证反面图片的存储路径")
@ApiModelProperty(value = "个人身份证反面图片的存储路径")
private String individual_id_images2;
@ApiModelProperty(value = "个人身份证居住地址")
private String individual_id_addr;
@ApiModelProperty(value = "个人身份证有效期开始时间")
private String individual_id_period_begin;
@ApiModelProperty(value = "个人身份证有效期结束时间")
private String individual_id_period_end;
@ApiModelProperty(value = "入驻商家的开户⾏号")
private String bank_code;
@ApiModelProperty(value = "入驻商家的开户银行")
private String bank_name;
@ApiModelProperty(value = "入驻商家开户银行的支行名称")
private String bank_branch_name;
@ApiModelProperty(value = "结算账户清算⾏号")
private String clearing_bank_code;
@ApiModelProperty(value = "结算账户银行卡图片")
private String bank_image;
@ApiModelProperty(value = "结算银行地区,格式: 省份/城市/乡县")
private String bank_area;
@ApiModelProperty(value = "入驻商家的收款账户号码")
private String account_number;

View File

@ -8,6 +8,8 @@
package com.suisung.mall.common.utils;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@ -54,16 +56,15 @@ public class RestTemplateHttpUtil {
* @param <T> 泛型类型
* @return 响应对象
*/
public static <T> T sendGetWithHeader(String url, Map<String, String> headers, Class<T> responseType) {
public static <T> ResponseEntity<T> sendGetWithHeader(String url, JSONObject headers, Class<T> responseType) {
HttpHeaders httpHeaders = new HttpHeaders();
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpHeaders.add(entry.getKey(), entry.getValue());
for (Map.Entry<String, Object> entry : headers.entrySet()) {
httpHeaders.add(entry.getKey(), (String) entry.getValue());
}
}
HttpEntity<?> entity = new HttpEntity<>(httpHeaders);
ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, entity, responseType);
return response.getBody();
return restTemplate.exchange(url, HttpMethod.GET, entity, responseType);
}
@ -92,11 +93,12 @@ public class RestTemplateHttpUtil {
/**
* 发送带 header POST form-data 请求
* @param url 请求的 URL
* @param headers 请求头
* @param formData form-data 数据
*
* @param url 请求的 URL
* @param headers 请求头
* @param formData form-data 数据
* @param responseType 响应的类型
* @param <T> 泛型类型
* @param <T> 泛型类型
* @return 响应对象
*/
public static <T> T sendPostFormData(String url, Map<String, String> headers, Map<String, String> formData, Class<T> responseType) {
@ -120,4 +122,35 @@ public class RestTemplateHttpUtil {
return response.getBody();
}
/**
* 发送带 header POST form-data 请求
*
* @param url 请求的 URL
* @param headers 请求头
* @param formData form-data 数据
* @param responseType 响应的类型
* @param <T> 泛型类型
* @return 响应对象
*/
public static <T> ResponseEntity<T> sendPostFormDataBackEntity(String url, JSONObject headers, JSONObject formData, Class<T> responseType) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
if (headers != null) {
for (Map.Entry<String, Object> entry : headers.entrySet()) {
httpHeaders.add(entry.getKey(), (String) entry.getValue());
}
}
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
if (formData != null) {
for (Map.Entry<String, Object> entry : formData.entrySet()) {
multiValueMap.add(entry.getKey(), JSONUtil.toJsonStr(entry.getValue()));
}
}
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(multiValueMap, httpHeaders);
ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.POST, entity, responseType);
return response;
}
}

View File

@ -294,6 +294,12 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
return base64.substring(0, length);
}
/**
* 去除省市区保留详细地址
*
* @param fullAddress
* @return
*/
public static String removeProvinceCityDistrict(String fullAddress) {
if (StringUtils.isBlank(fullAddress)) {
return "";
@ -328,6 +334,26 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
}
}
/**
* 去除省市区保留详细地址
*
* @param fullAddress
* @return
*/
public static String removeProvinceCityDistrict2(String fullAddress) {
// 定义省市县区的关键字
String[] keywords = {"", "", "自治区", "特别行政区", "地区", "", "自治州", "", "", "自治县", "", "自治旗", "县级市"};
for (String keyword : keywords) {
int index = fullAddress.indexOf(keyword);
if (index != -1) {
// 若找到关键字截取关键字之后的部分
fullAddress = fullAddress.substring(index + keyword.length());
}
}
return fullAddress;
}
/**
* 判断字符串是否是XML或JSON格式
*

View File

@ -8,8 +8,12 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -270,4 +274,48 @@ public class UploadUtil {
}
}
/**
* 下载图片到本地
*
* @param imageUrl 图片的URL地址
* @return 下载后的文件对象
* @throws IOException 如果下载失败
*/
public static File downloadImageFromUrl(String imageUrl) {
try {
URL url = new URL(imageUrl);
Path tempFilePath = Files.createTempFile("image", "." + getFileExtension(imageUrl));
try (InputStream in = url.openStream()) {
Files.copy(in, tempFilePath, StandardCopyOption.REPLACE_EXISTING);
}
return tempFilePath.toFile();
} catch (IOException e) {
System.err.println("下载图片时发生错误: " + e.getMessage());
return null;
}
}
// 合并从文件路径和 URL 获取文件后缀的方法
public static String getFileExtension(String input) {
if (input == null) {
return null;
}
String path;
try {
// 尝试将输入解析为 URL
URL url = new URL(input);
URI uri = url.toURI();
path = uri.getPath();
} catch (Exception e) {
// 如果解析失败将输入当作文件路径处理
path = input;
}
int lastIndex = path.lastIndexOf('.');
if (lastIndex == -1 || lastIndex == path.length() - 1) {
return "";
}
return path.substring(lastIndex + 1);
}
}

View File

@ -73,6 +73,8 @@ public class LakalaPayServiceImpl implements LakalaPayService {
private String orgCode;
@Value("${project.domain}")
private String projectDomain;
@Value("${spring.profiles.active}")
private String profile;
@Lazy
@ -427,6 +429,9 @@ public class LakalaPayServiceImpl implements LakalaPayService {
req.setSplitEntrustFilePath(splitEntrustFilePath);
// req.setSplitEntrustFilePath("G1/M00/06/64/CrFdEmBQc-aAGc_XAAAiIbS3WIE960.pdf");
if (profile.equals("prod")) {
projectDomain = projectDomain + "/api";
}
String retUrl = projectDomain + "/mobile/pay/lakala/ledger/applyLedgerMerNotify";
req.setRetUrl(retUrl);
@ -476,7 +481,7 @@ public class LakalaPayServiceImpl implements LakalaPayService {
String authorization = request.getHeader("Authorization");
String requestBody = LakalaUtil.getBody(request);
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
if (!checkSuccess) {
return JSONUtil.createObj().set("retCode", "OP90002").set("retMsg", "验签失败!");
}
@ -688,7 +693,7 @@ public class LakalaPayServiceImpl implements LakalaPayService {
String authorization = request.getHeader("Authorization");
String requestBody = LakalaUtil.getBody(request);
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
if (!checkSuccess) {
return JSONUtil.createObj().set("retCode", "OP90002").set("retMsg", "验签失败!");
}

View File

@ -47,11 +47,12 @@ public class LklLedgerMemberServiceImpl extends BaseServiceImpl<LklLedgerMemberM
return updateById(record);
}
return save(record);
return add(record);
}
/**
* 更新审核结果
*
* @param applyId
* @param merInnerNo
* @param merCupNo
@ -63,7 +64,7 @@ public class LklLedgerMemberServiceImpl extends BaseServiceImpl<LklLedgerMemberM
* @return
*/
@Override
public Boolean updateAuditResult(String applyId, String merInnerNo, String merCupNo, String entrustFileName, String entrustFilePath, String auditStatus, String auditStatusText, String remark){
public Boolean updateAuditResult(String applyId, String merInnerNo, String merCupNo, String entrustFileName, String entrustFilePath, String auditStatus, String auditStatusText, String remark) {
if (StrUtil.isBlank(applyId) || StrUtil.isBlank(merCupNo) || StrUtil.isBlank(auditStatus)) {
return false;
}

View File

@ -559,6 +559,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
esignContract.setReq_params(reqParams);
esignContract.setUnsigned_contract_url(esignContractFillingFile.getUnsigned_contract_local_url());
esignContract.setStore_id(esignContractFillingFile.getStore_id());
esignContract.setDistributor_id(shopMerchEntry.getDistributor_id()); // 代理商ID(esign_platform_info表id)0-表示只有平台方没有代理商
esignContract.setSign_flow_status(-1);//合作方签署状态-1:预备数据阶段1-等待签署2 - 已完成所有签署方完成签署3 - 已撤销发起方撤销签署任务5 - 已过期签署截止日到期后触发7 - 已拒签签署方拒绝签署
return saveOrUpdateByMchMobile(esignContract);

View File

@ -8,22 +8,37 @@
package com.suisung.mall.shop.lakala.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.modules.merch.ShopMerchEntry;
import com.suisung.mall.common.utils.RestTemplateHttpUtil;
import com.suisung.mall.common.utils.StringUtils;
import com.suisung.mall.common.utils.UploadUtil;
import com.suisung.mall.core.web.service.RedisService;
import com.suisung.mall.shop.store.service.ShopMerchEntryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.util.Pair;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@Service
public class CommonService {
private static final Logger log = LoggerFactory.getLogger(CommonService.class);
@Value("${lakala.tk.server_url}")
private String serverUrl;
@ -33,13 +48,23 @@ public class CommonService {
@Value("${lakala.tk.client_secret}")
private String clientSecret;
@Value("${spring.profiles.active}")
private String profile;
@Resource
private ShopMerchEntryService shopMerchEntryService;
@Autowired
private RedisService redisService;
protected String buildLklTkUrl(String urlPath){
protected String buildLklTkUrl(String urlPath) {
return serverUrl + urlPath;
}
protected boolean isProd() {
return "prod".equalsIgnoreCase(profile);
}
/**
* 请求获取token商户进件
*
@ -67,10 +92,318 @@ public class CommonService {
return "";
}
String token = jsonObj.getStr("token_type") + jsonObj.getStr("access_token");
String token = jsonObj.getStr("token_type") + " " + jsonObj.getStr("access_token");
redisService.set(authorizationKey, token, jsonObj.getLong("expires_in"));
return token;
}
/**
* (重要) 请求拉卡拉进件
*
* @param mchMobile 商家手机号
* @return
*/
public Pair<Boolean, String> registrationMerchant(String mchMobile) {
String authorization = getLklTkAuthorization();
if (StrUtil.isBlank(authorization)) {
return Pair.of(false, "获取拉卡拉token失败");
}
JSONObject header = new JSONObject();
header.put("Authorization", getLklTkAuthorization());
// 获取商家入驻信息组成请求参数
ShopMerchEntry shopMerchEntry = shopMerchEntryService.getShopMerchEntryByCondition(mchMobile, null, CommonConstant.MCH_APPR_STA_PASS);
if (ObjectUtil.isEmpty(shopMerchEntry)) {
return Pair.of(false, "商家入驻信息不存在");
}
JSONObject formData = new JSONObject();
formData.put("userNo", "29153396");
formData.put("email", mchMobile + "@163.com");
formData.put("busiCode", "B2B_SYT");
formData.put("merRegName", shopMerchEntry.getStore_name());
Boolean isQy = CommonConstant.MCH_ENTITY_TYPE_QY.equals(shopMerchEntry.getEntity_type());
String merType = isQy ? "TP_MERCHANT" : "TP_PERSONAL";
formData.put("merType", merType);
formData.put("merName", shopMerchEntry.getStore_name());
formData.put("merAddr", StringUtils.removeProvinceCityDistrict(shopMerchEntry.getStore_address()));
Map<String, String> areaCode = getAreaCode(shopMerchEntry.getStore_area(), false);
if (ObjectUtil.isNotEmpty(areaCode)) {
formData.put("provinceCode", areaCode.get("provinceCode"));
formData.put("cityCode", areaCode.get("cityCode"));
formData.put("countyCode", areaCode.get("countyCode"));
}
formData.put("longtude", shopMerchEntry.getStore_longitude()); //longitude 经度
formData.put("latitude", shopMerchEntry.getStore_latitude());
formData.put("source", "H5");
formData.put("larIdType", "01");
String larName = isQy ? shopMerchEntry.getLegal_person_name() : shopMerchEntry.getContact_name();
String larIdCard = isQy ? shopMerchEntry.getLegal_person_id_number() : shopMerchEntry.getIndividual_id_number();
String larIdCardStart = isQy ? shopMerchEntry.getLegal_person_id_period_begin() : shopMerchEntry.getIndividual_id_period_begin();
String larIdCardEnd = isQy ? shopMerchEntry.getLegal_person_id_period_end() : shopMerchEntry.getIndividual_id_period_end();
formData.put("larName", larName);
formData.put("larIdCard", larIdCard);
formData.put("larIdCardStart", larIdCardStart); // 身份证有效期开始时间
formData.put("larIdCardEnd", larIdCardEnd); // 身份证有效期结束时间
formData.put("businessContent", shopMerchEntry.getSales_info());
// 营业执照信息
if (isQy) {
formData.put("licenseName", shopMerchEntry.getBiz_license_company());
formData.put("licenseNo", shopMerchEntry.getBiz_license_number());
formData.put("licenseDtStart", shopMerchEntry.getBiz_license_period_begin());
formData.put("licenseDtEnd", shopMerchEntry.getBiz_license_period_end());
}
formData.put("contactMobile", mchMobile);
formData.put("contactName", shopMerchEntry.getContact_name());
formData.put("openningBankCode", shopMerchEntry.getBank_code());//结算账户开户
formData.put("openningBankName", shopMerchEntry.getBank_name());//结算账户开户名称
formData.put("clearingBankCode", shopMerchEntry.getClearing_bank_code());//结算账户清算
formData.put("accountNo", shopMerchEntry.getAccount_number()); //结算人银行卡号
formData.put("accountName", shopMerchEntry.getAccount_holder_name()); //结算人账户名称
formData.put("accountIdCard", shopMerchEntry.getLegal_person_id_number());//结算证件号码(身份证)
formData.put("settleType", "D1"); //结算类型D0秒到D1次日结算
formData.put("settlementType", "AUTOMATIC"); // 结算方式MANUAL:手动结算(结算至拉卡拉APP钱包),AUTOMATIC:自动结算到银行卡,REGULAR:定时结算仅企业商户支持
formData.put("accountType", isQy ? "57" : "58"); //结算账户类型: 57 对公 58 对私
//结算信息省份代码
Map<String, String> bankAreaCode = getAreaCode(shopMerchEntry.getBank_area(), true);
if (ObjectUtil.isNotEmpty(bankAreaCode)) {
formData.put("settleProvinceCode", bankAreaCode.get("provinceCode"));
formData.put("settleCityCode", bankAreaCode.get("cityCode"));
String[] bankAreaName = shopMerchEntry.getBank_area().split(",");
if (bankAreaName.length >= 2) {
formData.put("settleProvinceName", bankAreaName[0]);
formData.put("settleCityName", bankAreaName[1]);
}
}
JSONObject bizContent = new JSONObject();
bizContent.put("activityId", 687);
bizContent.put("termNum", "1");
bizContent.put("mcc", "1");
bizContent.put("fees", new JSONArray() {{
put(new JSONObject() {{
put("feeCode", "WECHAT");
put("feeValue", 0.38);
}});
}});
formData.put("bizContent", bizContent);
JSONArray attachments = new JSONArray();
JSONObject ID_CARD_FRONT = updatePhoto(shopMerchEntry.getIndividual_id_images(), "ID_CARD_FRONT", true);
if (ID_CARD_FRONT != null) {
attachments.put(ID_CARD_FRONT); // 身份证正面
}
JSONObject ID_CARD_BEHIND = updatePhoto(shopMerchEntry.getIndividual_id_images2(), "ID_CARD_BEHIND", true);
if (ID_CARD_BEHIND != null) {
attachments.put(ID_CARD_BEHIND); // 身份证国徽面
}
JSONObject SETTLE_ID_CARD_FRONT = updatePhoto(shopMerchEntry.getLegal_person_id_images(), "SETTLE_ID_CARD_FRONT", true);
if (SETTLE_ID_CARD_FRONT != null) {
attachments.put(SETTLE_ID_CARD_FRONT); // 结算人身份证正面
}
JSONObject SETTLE_ID_CARD_BEHIND = updatePhoto(shopMerchEntry.getLegal_person_id_images2(), "SETTLE_ID_CARD_BEHIND", true);
if (SETTLE_ID_CARD_BEHIND != null) {
attachments.put(SETTLE_ID_CARD_BEHIND); // 结算人身份证国徽面
}
JSONObject BUSINESS_LICENCE = updatePhoto(shopMerchEntry.getBiz_license_image(), "BUSINESS_LICENCE", true);
if (BUSINESS_LICENCE != null) {
attachments.put(BUSINESS_LICENCE); // 营业执照
}
JSONObject SHOP_OUTSIDE_IMG = updatePhoto(shopMerchEntry.getFront_facade_image(), "SHOP_OUTSIDE_IMG", false);
if (SHOP_OUTSIDE_IMG != null) {
attachments.put(SHOP_OUTSIDE_IMG); // 门店门面图片
}
JSONObject SHOP_INSIDE_IMG = updatePhoto(shopMerchEntry.getEnvironment_image(), "SHOP_INSIDE_IMG", false);
if (SHOP_INSIDE_IMG != null) {
attachments.put(SHOP_INSIDE_IMG); // 门店内部图片
}
JSONObject BANK_CARD = updatePhoto(shopMerchEntry.getBank_image(), "BANK_CARD", true);
if (BANK_CARD != null) {
attachments.put(BANK_CARD); // 银行卡图片
}
formData.put("attchments", attachments);
String urlPath = "/sit/htkregistration/merchant";
if (isProd()) {
urlPath = "/registration/merchant";
}
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostFormDataBackEntity(buildLklTkUrl(urlPath), header, formData, JSONObject.class);
if (ObjectUtil.isEmpty(response) || response.getStatusCode() != HttpStatus.OK) {
String errMsg = "请求分账系统出错!";
if (ObjectUtil.isNotEmpty(response.getBody()) && ObjectUtil.isNotEmpty(response.getBody().getStr("message"))) {
errMsg = response.getBody().getStr("message");
}
return Pair.of(false, "进件失败:" + errMsg);
}
// 根据入驻商家的代理商或平台方顺便新增一个接收方记录
// TODO 新增 lkl_ledger_member 数据 等待异步审核通知更改状态
String merchantNo = response.getBody().getStr("merchantNo"); //拉卡拉内部商户号
return Pair.of(true, "进件成功!");
}
/**
* 获取拉卡拉省市区编码
*
* @param areaName 省份/城市/乡县
* @return
*/
public Map<String, String> getAreaCode(String areaName, Boolean isBankArea) {
if (StrUtil.isBlank(areaName)) {
return new HashMap<String, String>() {{
put("provinceCode", "");
put("cityCode", "");
put("countyCode", "");
}};
}
String[] areaNames = areaName.split("/");
if (areaNames.length < 2) {
return new HashMap<String, String>() {{
put("provinceCode", "");
put("cityCode", "");
put("countyCode", "");
}};
}
String provinceName = areaNames[0];
String cityName = areaNames[1];
String countryName = "";
if (areaNames.length >= 3) {
countryName = areaNames[2];
}
String urlPath = "/organization";
if (isBankArea) {
urlPath = "/organization/bank";
}
String authorization = getLklTkAuthorization();
if (StrUtil.isBlank(authorization)) {
log.error("获取拉卡拉token失败");
return new HashMap<String, String>() {{
put("provinceCode", "");
put("cityCode", "");
put("countyCode", "");
}};
}
JSONObject header = new JSONObject();
header.put("Authorization", getLklTkAuthorization());
Map<String, String> areaCodeMap = new HashMap<>();
// 省份列表
ResponseEntity<JSONArray> response = RestTemplateHttpUtil.sendGetWithHeader(buildLklTkUrl(urlPath + "/1"), header, JSONArray.class);
if (ObjectUtil.isNotEmpty(response) && response.getStatusCode() == HttpStatus.OK) {
String provinceCode = "";
String cityCode = "";
String countyCode = "";
JSONArray jsonArray = response.getBody();
if (CollUtil.isNotEmpty(jsonArray)) {
for (JSONObject jsonObject : jsonArray.jsonIter()) {
if (StrUtil.contains(jsonObject.getStr("name"), provinceName)) {
provinceCode = jsonObject.getStr("code");
areaCodeMap.put("provinceCode", provinceCode);
break;
}
}
// 城市列表
if (StrUtil.isNotBlank(provinceCode)) {
response = RestTemplateHttpUtil.sendGetWithHeader(buildLklTkUrl(urlPath + "/" + provinceCode), header, JSONArray.class);
jsonArray = response.getBody();
if (CollUtil.isNotEmpty(jsonArray)) {
for (JSONObject jsonObject : jsonArray.jsonIter()) {
if (StrUtil.contains(jsonObject.getStr("name"), cityName)) {
cityCode = jsonObject.getStr("code");
areaCodeMap.put("cityCode", cityCode);
break;
}
}
}
}
// 乡列表
if (StrUtil.isNotBlank(cityCode)) {
response = RestTemplateHttpUtil.sendGetWithHeader(buildLklTkUrl(urlPath + "/" + cityCode), header, JSONArray.class);
jsonArray = response.getBody();
if (CollUtil.isNotEmpty(jsonArray)) {
for (JSONObject jsonObject : jsonArray.jsonIter()) {
if (StrUtil.contains(jsonObject.getStr("name"), countryName)) {
countyCode = jsonObject.getStr("code");
areaCodeMap.put("countyCode", countyCode);
break;
}
}
}
}
}
}
return areaCodeMap;
}
public JSONObject updatePhoto(String fileUrl, String imgType, Boolean isOcr) {
if (StrUtil.isBlank(fileUrl)) {
return null;
}
JSONObject header = new JSONObject();
header.put("Authorization", getLklTkAuthorization());
JSONObject formData = new JSONObject();
File file = UploadUtil.downloadImageFromUrl(fileUrl);
formData.put("file", file);
formData.put("imgType", imgType);
formData.put("sourcechnl", "0");
formData.put("isOcr", isOcr);
String urlPath = "/file/upload";
ResponseEntity<JSONObject> response = RestTemplateHttpUtil.sendPostFormDataBackEntity(buildLklTkUrl(urlPath), header, formData, JSONObject.class);
if (ObjectUtil.isEmpty(response) || response.getStatusCode() != HttpStatus.OK) {
return null;
}
JSONObject result = response.getBody();
if (result == null) {
return null;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", result.get("url"));
jsonObject.put("type", imgType);
return jsonObject;
}
}

View File

@ -127,5 +127,14 @@ public interface ShopMerchEntryService {
*/
Boolean updateMerchEntryStoreStatus(String loginMobile, Integer storeStatus);
/**
* 更新商家入驻申请的店铺 ID
*
* @param id
* @param storeId
* @return
*/
Boolean updateMerchEntryStoreId(Long id, Integer storeId);
}

View File

@ -685,4 +685,22 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
updateWrapper.eq("login_mobile", loginMobile).set("store_status", storeStatus);
return update(updateWrapper);
}
/**
* 更新商家入驻申请的店铺 ID
*
* @param id
* @param storeId
* @return
*/
@Override
public Boolean updateMerchEntryStoreId(Long id, Integer storeId) {
if (ObjectUtil.isEmpty(id) && ObjectUtil.isEmpty(storeId)) {
return false;
}
return update(new UpdateWrapper<ShopMerchEntry>()
.eq("id", id)
.set("store_id", storeId));
}
}

View File

@ -1641,7 +1641,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
DateTime tempTime = DateUtil.parse("1970-01-01");
//经纬度计算
//兼容不同终端 已经无推荐地址情况
//兼容不同终端 无推荐地址情况
String store_area = store_row.getStore_area();
// 设置经纬度默认值
@ -1751,7 +1751,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
// 初始化时添加一条店铺分析信息
ShopStoreAnalytics store_analytics_column = new ShopStoreAnalytics();
store_analytics_column.setStore_id(store_row.getStore_id());
if (!shopStoreAnalyticsService.saveOrUpdate(store_analytics_column)) {
throw new ApiException(ResultCode.FAILED);
}
@ -1971,6 +1970,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
throw new ApiException(ResultCode.FAILED);
}
// 添加默认客户等级
InvoicingCustomerLevel invoicingCustomerLevel = new InvoicingCustomerLevel();
invoicingCustomerLevel.setCustomer_level_name(I18nUtil._("普通(系统默认,不可删除)"));
invoicingCustomerLevel.setCustomer_level_discountrate(new BigDecimal("100"));
@ -3083,7 +3083,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
list.put(slide);
}
shopStoreInfo.setStore_slide(list.toString());
shopStoreInfo.setStore_address(shopMerchEntry.getStore_address()); // 包含省市区的详细地址
shopStoreInfo.setStore_state_id(StateCode.STORE_STATE_YES);
if (!shopStoreInfoService.save(shopStoreInfo)) {
@ -3159,48 +3158,11 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
}
// 初始化时添加一条店铺分析信息
ShopStoreAnalytics store_analytics_column = new ShopStoreAnalytics();
store_analytics_column.setStore_id(storeId);
if (!shopStoreAnalyticsService.saveOrUpdate(store_analytics_column)) {
throw new ApiException(ResultCode.FAILED);
}
// 初始化店铺商品标签
QueryWrapper<ShopBaseProductTag> tagQueryWrapper = new QueryWrapper<>();
tagQueryWrapper.orderByAsc("product_tag_id");
Page<ShopBaseProductTag> base_product_tag_row = shopBaseProductTagService.lists(tagQueryWrapper, 1, 5);
List<ShopStoreProductTag> store_product_tag_row = new ArrayList<>();
for (ShopBaseProductTag teg : base_product_tag_row.getRecords()) {
ShopStoreProductTag shopStoreProductTag = new ShopStoreProductTag();
store_product_tag_row.add(shopStoreProductTag);
shopStoreProductTag.setProduct_tag_id(teg.getProduct_tag_id());
shopStoreProductTag.setStore_id(storeId);
shopStoreProductTag.setProduct_tag_time(today);
shopStoreProductTag.setStore_product_tag_buildin(1);
}
if (CollUtil.isNotEmpty(store_product_tag_row)) {
if (!shopStoreProductTagService.saveOrUpdate(store_product_tag_row)) {
throw new ApiException(ResultCode.FAILED);
}
}
//初始化默认店铺仓库
InvoicingWarehouseBase invoicingWarehouseBase = new InvoicingWarehouseBase();
invoicingWarehouseBase.setWarehouse_name(I18nUtil._("默认"));
invoicingWarehouseBase.setStore_id(storeId);
invoicingWarehouseBase.setWarehouse_address("");
invoicingWarehouseBase.setWarehouse_number("");
invoicingWarehouseBase.setWarehouse_contact("");
if (!invoicingWarehouseBaseService.saveOrUpdate(invoicingWarehouseBase)) {
throw new ApiException(ResultCode.FAILED);
}
// 注意关联店铺到用户给用户增加店铺管理员权限
initShopKeeperRightsGroup(userId, storeId);
initStoreExtraInfo(userId, storeId);
// 更改店铺Id
shopMerchEntryService.updateMerchEntryStoreId(shopMerchEntry.getId(), storeId);
return Pair.of(storeId, "新增成功");
} catch (Exception e) {
@ -3215,11 +3177,51 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
* @param userId
* @param storeId
*/
private void initShopKeeperRightsGroup(Integer userId, Integer storeId) {
private void initStoreExtraInfo(Integer userId, Integer storeId) {
if (ObjectUtil.isNull(userId) || ObjectUtil.isNull(storeId)) {
return;
}
Date today = new Date(); // 当前时间
// 初始化时添加一条店铺分析信息
ShopStoreAnalytics store_analytics_column = new ShopStoreAnalytics();
store_analytics_column.setStore_id(storeId);
if (!shopStoreAnalyticsService.saveOrUpdate(store_analytics_column)) {
throw new ApiException(ResultCode.FAILED);
}
// 初始化店铺商品标签
QueryWrapper<ShopBaseProductTag> tagQueryWrapper = new QueryWrapper<>();
tagQueryWrapper.orderByAsc("product_tag_id");
Page<ShopBaseProductTag> base_product_tag_row = shopBaseProductTagService.lists(tagQueryWrapper, 1, 5);
List<ShopStoreProductTag> store_product_tag_row = new ArrayList<>();
for (ShopBaseProductTag teg : base_product_tag_row.getRecords()) {
ShopStoreProductTag shopStoreProductTag = new ShopStoreProductTag();
store_product_tag_row.add(shopStoreProductTag);
shopStoreProductTag.setProduct_tag_id(teg.getProduct_tag_id());
shopStoreProductTag.setStore_id(storeId);
shopStoreProductTag.setProduct_tag_time(today);
shopStoreProductTag.setStore_product_tag_buildin(1);
}
if (CollUtil.isNotEmpty(store_product_tag_row)) {
if (!shopStoreProductTagService.saveOrUpdate(store_product_tag_row)) {
throw new ApiException(ResultCode.FAILED);
}
}
//初始化默认店铺仓库
InvoicingWarehouseBase invoicingWarehouseBase = new InvoicingWarehouseBase();
invoicingWarehouseBase.setWarehouse_name(I18nUtil._("默认"));
invoicingWarehouseBase.setStore_id(storeId);
invoicingWarehouseBase.setWarehouse_address("");
invoicingWarehouseBase.setWarehouse_number("");
invoicingWarehouseBase.setWarehouse_contact("");
if (!invoicingWarehouseBaseService.saveOrUpdate(invoicingWarehouseBase)) {
throw new ApiException(ResultCode.FAILED);
}
//初始化默认权限
Page<Serializable> page = shopStoreEmployeeRightsBaseService.listKey(new QueryWrapper<>(), 1, ConfigConstant.MAX_LIST_NUM);
@ -3334,6 +3336,18 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
}
// 添加默认运输模板
ShopStoreTransportType shopStoreTransportType = new ShopStoreTransportType();
shopStoreTransportType.setTransport_type_name(I18nUtil._("通用全免")); // 模板名称
shopStoreTransportType.setStore_id(storeId); // 所属店铺
shopStoreTransportType.setTransport_type_pricing_method(1); // 计费规则(ENUM):1-按件数;2-按重量;3-按体积
shopStoreTransportType.setTransport_type_time(today);
shopStoreTransportType.setTransport_type_freight_free(BigDecimal.ZERO); // 免运费额度
shopStoreTransportType.setTransport_type_free(1);
if (!shopStoreTransportTypeService.saveOrUpdate(shopStoreTransportType)) {
throw new ApiException(I18nUtil._("添加运输模板失败"));
}
// 店铺配置
ShopStoreConfig shopStoreConfig = new ShopStoreConfig();
shopStoreConfig.setStore_id(storeId);
@ -3369,9 +3383,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
shopStoreConfig.setSc_festival_amount_down(BigDecimal.ZERO);
shopStoreConfig.setSc_festival_amount_upper(BigDecimal.ZERO);
shopStoreConfig.setSc_festival_float_proportion(BigDecimal.ZERO);
if (!shopStoreConfigService.saveOrUpdate(shopStoreConfig)) {
throw new ApiException(ResultCode.FAILED);
throw new ApiException(I18nUtil._("添加订单流转配置失败"));
}
// 添加默认客户等级
@ -3382,7 +3395,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
invoicingCustomerLevel.setCustomer_level_desc("");
if (!invoicingCustomerLevelService.saveOrUpdate(invoicingCustomerLevel)) {
throw new ApiException(ResultCode.FAILED);
throw new ApiException(I18nUtil._("添加默认客户等级失败"));
}
}