|
|
|
@ -2,10 +2,14 @@ package cc.hiver.mall.purchaseocr.service.impl; |
|
|
|
|
|
|
|
import cc.hiver.core.common.utils.CommonUtil; |
|
|
|
import cc.hiver.core.common.utils.SecurityUtil; |
|
|
|
import cc.hiver.core.entity.LogiticsCompany; |
|
|
|
import cc.hiver.core.entity.User; |
|
|
|
import cc.hiver.core.logisticsaddressbook.entity.LogisticsAddressBook; |
|
|
|
import cc.hiver.core.logisticsaddressbook.service.LogisticsAddressBookService; |
|
|
|
import cc.hiver.core.logisticsaddressbook.vo.LogisticsAddressBookQueryVo; |
|
|
|
import cc.hiver.core.logisticsstation.entity.LogisticsStation; |
|
|
|
import cc.hiver.core.logisticsstation.service.LogisticsStationService; |
|
|
|
import cc.hiver.core.logisticsstation.vo.LogisticsStationQueryVo; |
|
|
|
import cc.hiver.mall.common.constant.PurchaseConstant; |
|
|
|
import cc.hiver.mall.config.thread.AiPurchaseThread; |
|
|
|
import cc.hiver.mall.config.thread.ThreadPoolConfiguration; |
|
|
|
@ -83,6 +87,9 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
@Autowired |
|
|
|
private LogisticsAddressBookService logisticsAddressBookService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LogisticsStationService logisticsStationService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject batchSave(PurchaseOciPictureAddVo purchaseOciPictureAddVo) { |
|
|
|
@ -248,14 +255,14 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
final String attributeList = object.getString("attributeList"); |
|
|
|
final JSONArray attributeListJsonArray = JSON.parseArray(attributeList); |
|
|
|
// 根据货号去查询商品,如果
|
|
|
|
final List<Product> byProductSn = productService.getByProductSn(productSn, shopId,""); |
|
|
|
final List<Product> byProductSn = productService.getByProductSn(productSn, shopId, ""); |
|
|
|
if (StringUtils.isNotEmpty(singleProductId) || (byProductSn != null && !byProductSn.isEmpty())) { |
|
|
|
// 原则上一个店铺一个货号对应一个商品,这里如果查到了,直接拿第一个。
|
|
|
|
Product product = new Product(); |
|
|
|
if(!byProductSn.isEmpty()){ |
|
|
|
if (!byProductSn.isEmpty()) { |
|
|
|
product = byProductSn.get(0); |
|
|
|
} |
|
|
|
if(StringUtils.isNotEmpty(singleProductId)){ |
|
|
|
if (StringUtils.isNotEmpty(singleProductId)) { |
|
|
|
// 20240928 app/sale/buyAi接口加个参数productId,如果传值了,查规格库存数的时候就查这款商品的
|
|
|
|
product = productService.getById(singleProductId); |
|
|
|
} |
|
|
|
@ -283,13 +290,13 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
// ai语音入库旧商品 如果通义千问返回的价格为0,返回当前采购价 ,采购价:purchasePrice
|
|
|
|
if (price.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
purchaseDetail.setPurchasePrice(product.getPurchasePrice()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
purchaseDetail.setPurchasePrice(price); |
|
|
|
} |
|
|
|
// ai语音入库旧商品 如果通义千问返回的价格为0,返回当前批发价 ,批发价:wholesalePrice
|
|
|
|
if (wholesalePrice.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
purchaseDetail.setWholesalePrice(product.getWholesalePrice()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
purchaseDetail.setWholesalePrice(wholesalePrice); |
|
|
|
} |
|
|
|
purchaseDetail.setAttrId(product.getAttrId()); |
|
|
|
@ -401,9 +408,9 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
|
|
|
|
} |
|
|
|
// 如果客户id不为空,那么就查询商品的购买记录
|
|
|
|
if(StringUtils.isNotEmpty(customerId)){ |
|
|
|
if (StringUtils.isNotEmpty(customerId)) { |
|
|
|
// 获取客户的购买次数
|
|
|
|
final List<BuyCountVo> buyCount = saleService.buyCount(customerId,oldProductIdList); |
|
|
|
final List<BuyCountVo> buyCount = saleService.buyCount(customerId, oldProductIdList); |
|
|
|
// 封装为Map
|
|
|
|
final Map<String, Integer> buyCountMap = new HashMap<>(); |
|
|
|
for (BuyCountVo buyCountVo : buyCount) { |
|
|
|
@ -440,9 +447,9 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
for (int j = 0; j < attributeListJsonArray.size(); j++) { |
|
|
|
final JSONObject attributeListObject = attributeListJsonArray.getJSONObject(j); |
|
|
|
String color = attributeListObject.getString("color"); |
|
|
|
color = StringUtils.isEmpty(color) ? "均色" :color.toUpperCase(); |
|
|
|
color = StringUtils.isEmpty(color) ? "均色" : color.toUpperCase(); |
|
|
|
String size = attributeListObject.getString("size"); |
|
|
|
size = StringUtils.isEmpty(size) ? "均码" :size.toUpperCase(); |
|
|
|
size = StringUtils.isEmpty(size) ? "均码" : size.toUpperCase(); |
|
|
|
String productCount1 = attributeListObject.getString("productCount"); |
|
|
|
productCount1 = StringUtils.isEmpty(productCount1) ? "0" : productCount1; |
|
|
|
final Matcher countMatchered = COMPILE.matcher(productCount1); |
|
|
|
@ -521,7 +528,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
BigDecimal weight = BigDecimal.ZERO; |
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
final Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?"); |
|
|
|
if(StringUtils.isNotEmpty(weightStr)){ |
|
|
|
if (StringUtils.isNotEmpty(weightStr)) { |
|
|
|
final Matcher matcher = pattern.matcher(weightStr); |
|
|
|
if (matcher.find()) { |
|
|
|
// 获取匹配到的数字字符串并转换为BigDecimal
|
|
|
|
@ -533,7 +540,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
customInfoOfAiVo.setWeight(weight); |
|
|
|
final String countStr = object.getString("count"); |
|
|
|
int count = 0; |
|
|
|
if(StringUtils.isNotEmpty(countStr)){ |
|
|
|
if (StringUtils.isNotEmpty(countStr)) { |
|
|
|
final Matcher countMatchered = COMPILE.matcher(countStr); |
|
|
|
String replaced = ""; |
|
|
|
if (countMatchered.find()) { |
|
|
|
@ -547,7 +554,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
customInfoOfAiVo.setMethodOfSettlement(methodOfSettlement); |
|
|
|
final String tipsStr = object.getString("tips"); |
|
|
|
BigDecimal tips = BigDecimal.ZERO; |
|
|
|
if(StringUtils.isNotEmpty(tipsStr)){ |
|
|
|
if (StringUtils.isNotEmpty(tipsStr)) { |
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
final Matcher matcherOfTips = pattern.matcher(tipsStr); |
|
|
|
if (matcherOfTips.find()) { |
|
|
|
@ -561,7 +568,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
customInfoOfAiVos.add(customInfoOfAiVo); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
returnJsonObject.put("code", 500); |
|
|
|
} |
|
|
|
returnJsonObject.put("data", customInfoOfAiVos); |
|
|
|
@ -593,7 +600,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
BigDecimal weight = BigDecimal.ZERO; |
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
final Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?"); |
|
|
|
if(StringUtils.isNotEmpty(weightStr)){ |
|
|
|
if (StringUtils.isNotEmpty(weightStr)) { |
|
|
|
final Matcher matcher = pattern.matcher(weightStr); |
|
|
|
if (matcher.find()) { |
|
|
|
// 获取匹配到的数字字符串并转换为BigDecimal
|
|
|
|
@ -605,7 +612,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
logisticsOrderOfAiVo.setWeight(weight); |
|
|
|
final String countStr = object.getString("count"); |
|
|
|
int count = 0; |
|
|
|
if(StringUtils.isNotEmpty(countStr)){ |
|
|
|
if (StringUtils.isNotEmpty(countStr)) { |
|
|
|
final Matcher countMatchered = COMPILE.matcher(countStr); |
|
|
|
String replaced = ""; |
|
|
|
if (countMatchered.find()) { |
|
|
|
@ -617,7 +624,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
logisticsOrderOfAiVo.setCount(count); |
|
|
|
final String tipsStr = object.getString("tips"); |
|
|
|
BigDecimal tips = BigDecimal.ZERO; |
|
|
|
if(StringUtils.isNotEmpty(tipsStr)){ |
|
|
|
if (StringUtils.isNotEmpty(tipsStr)) { |
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
final Matcher matcherOfTips = pattern.matcher(tipsStr); |
|
|
|
if (matcherOfTips.find()) { |
|
|
|
@ -631,7 +638,7 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
|
|
|
|
final String premiumStr = object.getString("premium"); |
|
|
|
BigDecimal premium = BigDecimal.ZERO; |
|
|
|
if(StringUtils.isNotEmpty(premiumStr)){ |
|
|
|
if (StringUtils.isNotEmpty(premiumStr)) { |
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
final Matcher matcherOfPremium = pattern.matcher(premiumStr); |
|
|
|
if (matcherOfPremium.find()) { |
|
|
|
@ -650,11 +657,13 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
logisticsAddressBookQueryVo.setAddressType(1); |
|
|
|
logisticsAddressBookQueryVo.setShipperOrReceiverName(shipperName); |
|
|
|
logisticsAddressBookQueryVo.setMobile(shipperMobile); |
|
|
|
LogiticsCompany currCompany = securityUtil.getCurrCompany(); |
|
|
|
logisticsAddressBookQueryVo.setCompanyId(currCompany.getCompanyId()); |
|
|
|
final cn.hutool.json.JSONObject logisticsAddressBookList = logisticsAddressBookService.getLogisticsAddressBookList(logisticsAddressBookQueryVo); |
|
|
|
if("1".equals(logisticsAddressBookList.get("flag"))){ |
|
|
|
if ("1".equals(logisticsAddressBookList.get("flag"))) { |
|
|
|
final List<LogisticsAddressBook> data = (List<LogisticsAddressBook>) logisticsAddressBookList.get("data"); |
|
|
|
logisticsOrderOfAiVo.setShipperList(data); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
log.info(logisticsAddressBookList.get("msg").toString()); |
|
|
|
} |
|
|
|
// 收货人 receiverName,receiverMobile
|
|
|
|
@ -663,16 +672,24 @@ public class PurchaseOcrPictureServiceImpl implements PurchaseOcrPictureService |
|
|
|
receiverQueryVo.setShipperOrReceiverName(receiverName); |
|
|
|
receiverQueryVo.setMobile(receiverMobile); |
|
|
|
final cn.hutool.json.JSONObject receiverList = logisticsAddressBookService.getLogisticsAddressBookList(receiverQueryVo); |
|
|
|
if("1".equals(receiverList.get("flag"))){ |
|
|
|
if ("1".equals(receiverList.get("flag"))) { |
|
|
|
final List<LogisticsAddressBook> data = (List<LogisticsAddressBook>) receiverList.get("data"); |
|
|
|
logisticsOrderOfAiVo.setReceiverList(data); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
log.info(receiverList.get("msg").toString()); |
|
|
|
} |
|
|
|
|
|
|
|
// 到达站列表
|
|
|
|
if (StringUtils.isNotEmpty(arrivalStationName)) { |
|
|
|
LogisticsStationQueryVo logisticsRouteQueryVo = new LogisticsStationQueryVo(); |
|
|
|
logisticsRouteQueryVo.setStationName(arrivalStationName); |
|
|
|
List<LogisticsStation> logisticsStationListBystationName = logisticsStationService.getLogisticsStationListBystationName(logisticsRouteQueryVo); |
|
|
|
logisticsOrderOfAiVo.setLogisticsStationList(logisticsStationListBystationName); |
|
|
|
} |
|
|
|
logisticsOrderOfAiVos.add(logisticsOrderOfAiVo); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
returnJsonObject.put("code", 500); |
|
|
|
} |
|
|
|
returnJsonObject.put("data", logisticsOrderOfAiVos); |
|
|
|
|