订单信息处理
This commit is contained in:
parent
7eac0a3518
commit
dd0d0c61da
|
|
@ -5,13 +5,18 @@ import cn.iocoder.yudao.module.haoka.api.ApiFrom;
|
|||
import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO;
|
||||
import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.OrderOperateLogSaveReqVO;
|
||||
import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.HaoKaProductRespVO;
|
||||
import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.ProductLimitAreaRespVO;
|
||||
import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.ProductLimitCardRespVO;
|
||||
import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.ProductLimitRespVO;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.ApiDealResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.ApiDealStrategyService;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiCreateParam;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiCreateResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService;
|
||||
import cn.iocoder.yudao.module.haoka.service.orderoperatelog.OrderOperateLogService;
|
||||
import cn.iocoder.yudao.module.haoka.service.product.ProductLimitService;
|
||||
import cn.iocoder.yudao.module.haoka.service.smstask.SmsTaskService;
|
||||
import cn.iocoder.yudao.module.haoka.utils.IdCardAgeCalculator;
|
||||
import cn.iocoder.yudao.module.haoka.utils.SnowflakeId;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -28,6 +33,8 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|||
|
||||
import cn.iocoder.yudao.module.haoka.dal.mysql.orders.OrdersMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
||||
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
|
||||
|
|
@ -50,7 +57,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
@Resource
|
||||
private SmsTaskService smsTaskService;
|
||||
|
||||
@Resource
|
||||
private ProductLimitService productLimitService;
|
||||
@Resource
|
||||
private OrderOperateLogService orderOperateLogService;
|
||||
/**
|
||||
|
|
@ -141,7 +149,19 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
throw exception(ORDERS_NOT_EXISTS);
|
||||
}
|
||||
OrdersDO updateObj = BeanUtils.toBean(updateReqVO, OrdersDO.class);
|
||||
|
||||
if("120".equals(updateReqVO.getStatus())){
|
||||
// 提交初审时判断限制条件
|
||||
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(oldOrderDo.getOnSaleProductId());
|
||||
ProductLimitRespVO productLimit = productLimitService.getProductLimit(onSaleProductPreOrder.getParentProduct().getHaokaProductLimitId());
|
||||
// 市区编码
|
||||
String addressCityCode = oldOrderDo.getAddressCityCode();
|
||||
// 省编码
|
||||
String addressProvinceCode = oldOrderDo.getAddressProvinceCode();
|
||||
int i = IdCardAgeCalculator.calculateAge(oldOrderDo.getIdCardNum());
|
||||
String idCardNum = oldOrderDo.getIdCardNum();
|
||||
List<ProductLimitCardRespVO> productLimitCardRespVO = productLimit.getProductLimitCardRespVO();
|
||||
List<ProductLimitAreaRespVO> productLimitAreaVos = productLimit.getProductLimitAreaVos();
|
||||
}
|
||||
// 保证下面字段信息不会变化
|
||||
updateObj.setOnSaleProductId(oldOrderDo.getOnSaleProductId());
|
||||
updateObj.setProducerId(oldOrderDo.getProducerId());
|
||||
|
|
@ -174,8 +194,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
// 更新
|
||||
OrdersDO updateObj = BeanUtils.toBean(updateReqVO, OrdersDO.class);
|
||||
// 判断自动发货还是手动发货 根据在售产品查询产品配置中的发货类型
|
||||
Long productId = updateObj.getProductId();
|
||||
OnSaleProductPreOrderRespVO onSaleProduct = onSaleProductService.getOnSaleProductPreOrder(productId);
|
||||
OnSaleProductPreOrderRespVO onSaleProduct = onSaleProductService.getOnSaleProductPreOrder(updateObj.getOnSaleProductId());
|
||||
HaoKaProductRespVO haoKaProduct = onSaleProduct.getParentProduct();
|
||||
Integer autoType = haoKaProduct.getAutoType();
|
||||
updateObj.setAutoType(autoType);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package cn.iocoder.yudao.module.haoka.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class IdCardAgeCalculator {
|
||||
|
||||
/**
|
||||
* 根据身份证号码计算年龄
|
||||
*
|
||||
* @param idCard 身份证号码
|
||||
* @return 年龄
|
||||
* @throws IllegalArgumentException 如果身份证号码无效
|
||||
*/
|
||||
public static int calculateAge(String idCard) {
|
||||
// 校验身份证号码长度
|
||||
if (idCard == null || (idCard.length() != 15 && idCard.length() != 18)) {
|
||||
throw new IllegalArgumentException("无效的身份证号码");
|
||||
}
|
||||
|
||||
// 提取出生日期部分
|
||||
String birthDateStr;
|
||||
if (idCard.length() == 15) {
|
||||
// 15位身份证:7-12位是出生日期(YYMMDD)
|
||||
birthDateStr = "19" + idCard.substring(6, 12);
|
||||
} else {
|
||||
// 18位身份证:7-14位是出生日期(YYYYMMDD)
|
||||
birthDateStr = idCard.substring(6, 14);
|
||||
}
|
||||
|
||||
// 解析出生日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
LocalDate birthDate = LocalDate.parse(birthDateStr, formatter);
|
||||
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
// 计算年龄
|
||||
return Period.between(birthDate, currentDate).getYears();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue