|
|
@@ -0,0 +1,152 @@ |
|
|
|
package cn.com.taiji.ias.manager.ass; |
|
|
|
|
|
|
|
import cn.com.taiji.common.manager.net.http.ServiceHandleException; |
|
|
|
import cn.com.taiji.core.entity.ass.AssOrderinfo; |
|
|
|
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; |
|
|
|
import cn.com.taiji.core.entity.basic.QtkVehicleInfo; |
|
|
|
import cn.com.taiji.core.entity.dict.ass.AssOrderStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.ass.AssOrderStep; |
|
|
|
import cn.com.taiji.core.entity.dict.ass.AssOrderType; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.SourceType; |
|
|
|
import cn.com.taiji.core.entity.dict.issue.OrderPayType; |
|
|
|
import cn.com.taiji.core.entity.dict.issue.OrderType; |
|
|
|
import cn.com.taiji.core.entity.issue.IssueProduct; |
|
|
|
import cn.com.taiji.core.entity.issue.IssueProductPay; |
|
|
|
import cn.com.taiji.core.entity.user.Staff; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.ass.SignChangeApplyRequest; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.ass.SignChangeApplyResponse; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.valid.ErrorMsgBuilder; |
|
|
|
import cn.com.taiji.core.repo.jpa.issue.IssueProductPayRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.issue.IssueProductRepo; |
|
|
|
import cn.com.taiji.ias.dict.DataType; |
|
|
|
import cn.com.taiji.ias.model.MyFinals; |
|
|
|
import cn.com.taiji.ias.model.ServiceLogEvent; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author:ChenChao |
|
|
|
* @Date:2025/9/18 15:53 |
|
|
|
* @Filename:SignChangeApplyManager |
|
|
|
* @description: |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class SignChangeApplyManager extends AbstractAssManager<SignChangeApplyRequest>{ |
|
|
|
|
|
|
|
public SignChangeApplyManager() { |
|
|
|
super(DataType.SIGNCHANGE_APPLY); |
|
|
|
} |
|
|
|
public static final String VEHICLE_INFO = "vehicle"; |
|
|
|
public static final String PRODUCT = "product"; |
|
|
|
@Autowired |
|
|
|
private IssueProductRepo issueProductRepo; |
|
|
|
@Autowired |
|
|
|
private IssueProductPayRepo issueProductPayRepo; |
|
|
|
@Override |
|
|
|
protected String getDataId(SignChangeApplyRequest req) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void formatValidateInternal(ErrorMsgBuilder builder, SignChangeApplyRequest req, ServiceLogEvent event, Map<String, Object> dataStream) throws ServiceHandleException { |
|
|
|
req.relatedValid(builder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void businessValidateInternal(ErrorMsgBuilder builder, SignChangeApplyRequest req, ServiceLogEvent event, Map<String, Object> dataStream) throws ServiceHandleException { |
|
|
|
AssOrderinfo assOrderinfo = orderInfoRepo.findByVehicleIdAndOrderStatusAndOrderType(req.getVehicleId(), AssOrderStatus.NORMAL, AssOrderType.PLATE_INFO_CHANGE); |
|
|
|
if (assOrderinfo != null) { |
|
|
|
throw newBusinessException("查询到您有正在进行中的订单,不允许再次申请"); |
|
|
|
} |
|
|
|
QtkVehicleInfo vehicleInfo = vehicleInfoRepo.findByVehicleId(req.getVehicleId()); |
|
|
|
if (vehicleInfo == null) throw newBusinessException("未找到车辆信息"); |
|
|
|
IssueProduct product = issueProductRepo.findByReleaseId(req.getProductId()); |
|
|
|
if (product == null) { |
|
|
|
throw newBusinessException("未找到产品信息"); |
|
|
|
} |
|
|
|
if (!product.getNeedPay()) { |
|
|
|
throw newBusinessException("当前产品不可支付使用,请联系客服"); |
|
|
|
} |
|
|
|
dataStream.put(VEHICLE_INFO, vehicleInfo); |
|
|
|
dataStream.put(PRODUCT, product); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void persistInternal(SignChangeApplyRequest req, ServiceLogEvent event, Map<String, Object> dataStream) throws ServiceHandleException { |
|
|
|
|
|
|
|
QtkVehicleInfo vehicleInfo = (QtkVehicleInfo) dataStream.get(VEHICLE_INFO); |
|
|
|
IssueProduct product = (IssueProduct) dataStream.get(PRODUCT); |
|
|
|
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(vehicleInfo.getCustomerId()); |
|
|
|
|
|
|
|
//创建售后单 |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
AssOrderinfo assOrderinfo = new AssOrderinfo(); |
|
|
|
assOrderinfo.setOrderType(AssOrderType.PLATE_INFO_CHANGE); |
|
|
|
assOrderinfo.setOrderSource(req.getOrderSource()); |
|
|
|
assOrderinfo.setAgencyId(MyFinals.QTZL_AGENCY_ID); |
|
|
|
assOrderinfo.setOpenId(req.getOpenId()); |
|
|
|
if (SourceType.SERVICE_HALL == req.getOrderSource()){ |
|
|
|
Staff staff = staffRepo.findByStaffId(req.getStaffId()); |
|
|
|
assOrderinfo.setAgencyId(staff.getAgencyId()); |
|
|
|
assOrderinfo.setChannelId(staff.getServiceHallId()); |
|
|
|
assOrderinfo.setStaffOpenId(req.getOpenId()); |
|
|
|
}else if (SourceType.WECHAT == req.getOrderSource()){ |
|
|
|
assOrderinfo.setChannelId(MyFinals.QTZL_CHANNELWX_ID); |
|
|
|
}else { |
|
|
|
assOrderinfo.setChannelId(MyFinals.QTZL_CHANNEL_ID); |
|
|
|
} |
|
|
|
assOrderinfo.setOrderNo(createOrderNo(assOrderinfo.getAgencyId())); |
|
|
|
assOrderinfo.setOrderStatus(AssOrderStatus.NORMAL); |
|
|
|
assOrderinfo.setOrderStep(AssOrderStep.ORDER_INIT); |
|
|
|
assOrderinfo.setApplyTime(now); |
|
|
|
assOrderinfo.setCustomerTel(customerInfo.getCustomerTel());//原车牌 电话 |
|
|
|
assOrderinfo.setCustomerId(customerInfo.getCustomerId());//原车牌 ETC用户Id |
|
|
|
assOrderinfo.setCustomerName(customerInfo.getCustomerName());//原车牌 ETC用户姓名 |
|
|
|
assOrderinfo.setCustomerIdType(customerInfo.getCustomerIdType());//原车牌 ETC用户证件类型 |
|
|
|
assOrderinfo.setCustomerIdNum(customerInfo.getCustomerIdNum());//原车牌 ETC用户证件号码 |
|
|
|
assOrderinfo.setUserType(customerInfo.getUserType());//原车牌 ETC用户类型 |
|
|
|
// assOrderinfo.setArtificialStatus(); |
|
|
|
assOrderinfo.setVehicleId(vehicleInfo.getVehicleId()); |
|
|
|
assOrderinfo.setVehiclePlate(vehicleInfo.getVehiclePlate()); |
|
|
|
assOrderinfo.setVehiclePlateColor(vehicleInfo.getVehiclePlateColor()); |
|
|
|
orderInfoRepo.persist(assOrderinfo); |
|
|
|
dataStream.put(ORDER, assOrderinfo); |
|
|
|
//创建支付单 |
|
|
|
List<IssueProductPay> productPays = issueProductPayRepo.findByReleaseId(product.getReleaseId()); |
|
|
|
for (IssueProductPay productPay : productPays) { |
|
|
|
OrderPayType orderPayType = OrderPayType.valueOf(productPay.getFeeType()); |
|
|
|
Long fee = 0l; |
|
|
|
switch (orderPayType) { |
|
|
|
case HANDLE: |
|
|
|
fee = product.getHandleFee(); |
|
|
|
break; |
|
|
|
case MARGIN: |
|
|
|
fee = product.getMarginFee(); |
|
|
|
break; |
|
|
|
case PRESTORE: |
|
|
|
fee = product.getPrestoreFee(); |
|
|
|
break; |
|
|
|
case PROCESS: |
|
|
|
fee = product.getProcessFee(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
payTools.createPayOrder(assOrderinfo.getOrderNo(), OrderType.AFTERSALE, fee, productPay.getPayConfigId(), orderPayType, product.getAgencyId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected SignChangeApplyResponse getRes(SignChangeApplyRequest req, ServiceLogEvent event, Map<String, Object> dataStream) throws ServiceHandleException, IOException { |
|
|
|
AssOrderinfo assOrderinfo = (AssOrderinfo) dataStream.get(ORDER); |
|
|
|
SignChangeApplyResponse res = new SignChangeApplyResponse(); |
|
|
|
res.setId(assOrderinfo.getId()); |
|
|
|
res.setOrderNo(assOrderinfo.getOrderNo()); |
|
|
|
res.setReceiveTime(getReceiveTimeStr(event)); |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |