Commit 7fccc37a authored by 周健威's avatar 周健威

修改短信和部分功能

parent f964d476
...@@ -9,13 +9,21 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -9,13 +9,21 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
/** /**
* Created by ace on 2017/9/15. * Created by ace on 2017/9/15.
*/ */
@FeignClient("xx-app") @FeignClient("xx-app")
public interface ConfigFeign { public interface ConfigFeign {
/**
* 客服
*/
public static final int TYPE_CUS_SER = 400;
@RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET) @RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET)
ObjectRestResponse<Cofig> getAllByType(String types); ObjectRestResponse<List<Cofig>> getAllByType(String types);
@GetMapping("/cofig/app/unauth/withdraw_rule") @GetMapping("/cofig/app/unauth/withdraw_rule")
WithDrawRuleVo getWithDrawRule(); WithDrawRuleVo getWithDrawRule();
......
...@@ -12,6 +12,11 @@ public class OrderAccompanyDTO { ...@@ -12,6 +12,11 @@ public class OrderAccompanyDTO {
*/ */
private Integer id; private Integer id;
/**
* 物品类型
*/
private Integer type;
/** /**
* 物品名称 * 物品名称
*/ */
......
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
......
...@@ -3,22 +3,34 @@ package com.xxfc.platform.order.biz.inner; ...@@ -3,22 +3,34 @@ package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum; import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderMemberDetail; import com.xxfc.platform.order.entity.OrderMemberDetail;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail; import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderTourDetail;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
/** /**
* 订单退款记录表 * 订单退款记录表
...@@ -37,6 +49,21 @@ public class OrderMsgBiz { ...@@ -37,6 +49,21 @@ public class OrderMsgBiz {
public static final int RENT_CANCEL = 3; public static final int RENT_CANCEL = 3;
//
public static final int PAY = 1;
public static final int CANCEL = 2;
//客户通知2
// public static final int RENT_APP_A = 4;
// public static final int RENT_APP_B = 5;
// public static final int TOUR_APP = 6;
// public static final int MEMBER_APP = 7;
//参数
public static final String USER_N = "尊敬的客户";
public static final String USER_M = "尊贵的会员";
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
...@@ -46,6 +73,12 @@ public class OrderMsgBiz { ...@@ -46,6 +73,12 @@ public class OrderMsgBiz {
@Autowired @Autowired
VehicleFeign vehicleFeign; VehicleFeign vehicleFeign;
@Autowired
ConfigFeign configFeign;
@Autowired
OrderRefundBiz orderRefundBiz;
/** /**
* 处理App用户提醒短信的发送 * 处理App用户提醒短信的发送
* @param orvd * @param orvd
...@@ -175,6 +208,136 @@ public class OrderMsgBiz { ...@@ -175,6 +208,136 @@ public class OrderMsgBiz {
} }
} }
/**
* 支付订单处理提醒短信的发送
* @param orvd
* @param baseOrder
* @param appUserDTO
*/
public void handelMsgPayNew(OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, AppUserDTO appUserDTO) {
try {
OrderTypeEnum orderTypeEnum = OrderTypeEnum.codeAndDesc.get(baseOrder.getType());
Integer smstype;
List<String> smsParams = new ArrayList<String>();
switch (orderTypeEnum) {
case RENT_VEHICLE:
CompanyDetail startCompanyDetail = vehicleFeign.getCompanyDetail(orvd.getStartCompanyId()).getData();
CompanyDetail endCompanyDetail = vehicleFeign.getCompanyDetail(orvd.getEndCompanyId()).getData();
if(null != orvd.getStartCompanyId() && !SYS_FALSE.equals(orvd.getStartCompanyId())) {
//使用免费天数
if(null != orvd.getFreeDays() && orvd.getFreeDays() > 0) {
smstype = SmsTemplateDTO.PAY_B;
}else {
smstype = SmsTemplateDTO.PAY_A;
}
sms2AppUser(orvd, otd, omd, baseOrder, appUserDTO, smstype, smsParams);
//后台发送消息(客服)
Cofig cofig = configFeign.getAllByType(ConfigFeign.TYPE_CUS_SER+ "").getData().get(0);
sms2BgUser(cofig.getValue(), startCompanyDetail, endCompanyDetail, orvd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_C, smsParams);
//后台发送消息(出车人)
sms2BgUser(startCompanyDetail.getVehiceServicePhone(), startCompanyDetail, endCompanyDetail, orvd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_D, smsParams);
//后台发送消息(收车人)
sms2BgUser(endCompanyDetail.getVehiceServicePhone(), startCompanyDetail, endCompanyDetail, orvd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_D, smsParams);
}else {
log.error("通知短信异常,开始公司id 不存在或者为0 订单号:{}", baseOrder.getId());
}
break;
case TOUR:
sms2AppUser(orvd, otd, omd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_F, smsParams);
break;
case MEMBER:
sms2AppUser(orvd, otd, omd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_G, smsParams);
break;
default:
break;
}
}catch (Exception e) {
log.error(e.getMessage(), e);
}
}
/**
* 取消订单处理提醒短信的发送
* @param orvd
* @param baseOrder
* @param appUserDTO
*/
public void handelMsgCancel(OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, AppUserDTO appUserDTO) {
try {
OrderTypeEnum orderTypeEnum = OrderTypeEnum.codeAndDesc.get(baseOrder.getType());
Integer smstype;
List<String> smsParams = new ArrayList<String>();
switch (orderTypeEnum) {
case RENT_VEHICLE:
if(null != orvd.getEndCompanyId() && !SYS_FALSE.equals(orvd.getEndCompanyId())) {
//查询押金退款记录
OrderRefund orderRefund = orderRefundBiz.selectOne(new OrderRefund(){{
setOrderId(baseOrder.getId());
setRefundType(RefundTypeEnum.DEPOSIT.getCode());
}});
// if(BigDecimal.ZERO.equals(orderRefund))
//使用免费天数
if(null != orvd.getFreeDays() && orvd.getFreeDays() > 0) {
smstype = SmsTemplateDTO.CANCEL_B;
}else {
smstype = SmsTemplateDTO.CANCEL_A;
}
sms2AppUser(orvd, otd, omd, baseOrder, appUserDTO, smstype, smsParams);
//后台发送消息(出车人)
// sms2BgUser(startCompanyDetail.getVehiceServicePhone(), startCompanyDetail, endCompanyDetail, orvd, baseOrder, appUserDTO, SmsTemplateDTO.CANCEL_E, smsParams);
}else {
log.error("通知后台客户短信异常,结束公司id 不存在或者为0 订单号:{}", baseOrder.getId());
}
break;
case TOUR:
break;
case MEMBER:
break;
default:
break;
}
}catch (Exception e) {
log.error(e.getMessage(), e);
}
}
private void sms2AppUser(OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, AppUserDTO appUserDTO, Integer smstype, List<String> smsParams) {
handelSmsParamApp(orvd, otd, omd, baseOrder, smsParams, appUserDTO, smstype);
SmsTemplateDTO smsTemplateDTO = new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(smstype);
setParams(smsParams.toArray(new String[smsParams.size()]));
}};
thirdFeign.sendTemplate(smsTemplateDTO);
}
private void sms2RefundAppUser(BigDecimal originalAmount, BigDecimal violateAmount, BigDecimal residueAmount, BaseOrder baseOrder, AppUserDTO appUserDTO, Integer smstype, List<String> smsParams) {
handelDepositSmsParamApp(originalAmount, violateAmount, residueAmount, baseOrder, smsParams, appUserDTO, smstype);
SmsTemplateDTO smsTemplateDTO = new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(smstype);
setParams(smsParams.toArray(new String[smsParams.size()]));
}};
thirdFeign.sendTemplate(smsTemplateDTO);
}
private void sms2BgUser(String phone,BranchCompany sCompany, BranchCompany eCompany, OrderRentVehicleDetail orvd, BaseOrder baseOrder, AppUserDTO appUserDTO, Integer smstype, List<String> smsParams) {
handelSmsParamBg(sCompany, eCompany, orvd, baseOrder, smsParams, appUserDTO, smstype);
SmsTemplateDTO smsTemplateDTO = new SmsTemplateDTO(){{
setPhoneNumbers(phone);
setType(smstype);
setParams(smsParams.toArray(new String[smsParams.size()]));
}};
thirdFeign.sendTemplate(smsTemplateDTO);
}
private void handelSmsParam(OrderRentVehicleDetail orvd, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int handelType) { private void handelSmsParam(OrderRentVehicleDetail orvd, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int handelType) {
if(RENT_DELIVERY == handelType) { if(RENT_DELIVERY == handelType) {
smsParams.add(appUserDTO.getRealname()); smsParams.add(appUserDTO.getRealname());
...@@ -194,4 +357,135 @@ public class OrderMsgBiz { ...@@ -194,4 +357,135 @@ public class OrderMsgBiz {
} }
} }
private void handelSmsParamApp(OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int paramHandelType) {
switch (paramHandelType) {
case SmsTemplateDTO.PAY_A :
if(0 < baseOrder.getMemberLevel() ) {
smsParams.add(USER_M);
}else {
smsParams.add(USER_N);
}
smsParams.add(baseOrder.getRealAmount().toString());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(orvd.getStartAddr());
break;
case SmsTemplateDTO.PAY_B :
smsParams.add(orvd.getFreeDays().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
smsParams.add(baseOrder.getRealAmount().toString());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(orvd.getStartAddr());
break;
case SmsTemplateDTO.PAY_F :
smsParams.add(baseOrder.getName());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(otd.getStartTime())));
smsParams.add(otd.getStartAddr());
break;
case SmsTemplateDTO.PAY_G :
smsParams.add(baseOrder.getRealAmount().toString());
smsParams.add(omd.getRentFreeNum().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
break;
case SmsTemplateDTO.CANCEL_A :
if(0 < baseOrder.getMemberLevel() ) {
smsParams.add(USER_M);
}else {
smsParams.add(USER_N);
}
break;
default:
break;
}
}
private void handelDepositSmsParamApp(BigDecimal originalAmount, BigDecimal violateAmount, BigDecimal residueAmount, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int paramHandelType) {
switch (paramHandelType) {
case SmsTemplateDTO.CANCEL_C :
if(0 < baseOrder.getMemberLevel() ) {
smsParams.add(USER_M);
}else {
smsParams.add(USER_N);
}
smsParams.add(violateAmount.toString());
smsParams.add(residueAmount.toString());
break;
case SmsTemplateDTO.CANCEL_D :
smsParams.add(violateAmount.toString());
smsParams.add(residueAmount.toString());
break;
case SmsTemplateDTO.REFUND_A:
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Integer rentDepositAutoRefundTime = new Integer(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_DEPOSIT_AUTO_REFUND_TIME).getDetail());
if(0 < baseOrder.getMemberLevel() ) {
smsParams.add(USER_M);
}else {
smsParams.add(USER_N);
}
smsParams.add(baseOrder.getNo());
smsParams.add(originalAmount.toString());
smsParams.add(violateAmount.toString());
smsParams.add(residueAmount.toString());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(baseOrder.getRefundTime() + Long.valueOf(rentDepositAutoRefundTime * 60 * 60 * 1000))));
break;
case SmsTemplateDTO.REFUND_B:
if(0 < baseOrder.getMemberLevel() ) {
smsParams.add(USER_M);
}else {
smsParams.add(USER_N);
}
smsParams.add(baseOrder.getNo());
smsParams.add(originalAmount.toString());
smsParams.add(violateAmount.toString());
smsParams.add(residueAmount.toString());
break;
default:
break;
}
}
private void handelSmsParamBg(BranchCompany sCompany, BranchCompany eCompany, OrderRentVehicleDetail orvd, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int paramHandelType) {
switch (paramHandelType) {
case SmsTemplateDTO.PAY_C :
smsParams.add(appUserDTO.getRealname());
smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName());
smsParams.add(sCompany.getVehiceServicePhone());
smsParams.add(eCompany.getName());
smsParams.add(eCompany.getVehiceServicePhone());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getEndTime())));
smsParams.add(orvd.getDayNum().toString());
break;
case SmsTemplateDTO.PAY_D :
smsParams.add(appUserDTO.getRealname());
smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName());
smsParams.add(eCompany.getName());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getEndTime())));
smsParams.add(orvd.getDayNum().toString());
break;
case SmsTemplateDTO.PAY_E :
smsParams.add(appUserDTO.getRealname());
smsParams.add(appUserDTO.getUsername());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(sCompany.getName());
smsParams.add(baseOrder.getName());
break;
case SmsTemplateDTO.CANCEL_E :
smsParams.add(appUserDTO.getRealname());
smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName());
smsParams.add(eCompany.getName());
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getStartTime())));
smsParams.add(DateUtil.formatDateTime(DateUtil.date(orvd.getEndTime())));
smsParams.add(orvd.getDayNum().toString());
break;
default:
break;
}
}
} }
\ No newline at end of file
...@@ -71,7 +71,7 @@ public class RentDepositJobHandler extends IJobHandler { ...@@ -71,7 +71,7 @@ public class RentDepositJobHandler extends IJobHandler {
.where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RENT_VEHICLE) .where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RENT_VEHICLE)
.andEqualTo(BaseOrder::getStatus, OrderStatusEnum.ORDER_FINISH) //已完成的订单 .andEqualTo(BaseOrder::getStatus, OrderStatusEnum.ORDER_FINISH) //已完成的订单
.andEqualTo(BaseOrder::getRefundStatus, RefundStatusEnum.RESIDUE_ILLEGAL) //已归还了部分押金 .andEqualTo(BaseOrder::getRefundStatus, RefundStatusEnum.RESIDUE_ILLEGAL) //已归还了部分押金
.andLessThanOrEqualTo(BaseOrder::getRefundTime, System.currentTimeMillis() - (rentDepositAutoRefundTime * 60 * 60 * 1000)) .andLessThanOrEqualTo(BaseOrder::getRefundTime, System.currentTimeMillis() - (rentDepositAutoRefundTime * 60 * 1000))
.andLike(BaseOrder::getId, "%"+ i)).build()); .andLike(BaseOrder::getId, "%"+ i)).build());
//处理自动退剩余押金 //处理自动退剩余押金
......
...@@ -172,32 +172,20 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -172,32 +172,20 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
for(AccompanyingItemVo aiv : accompanyingItemList) { for(AccompanyingItemVo aiv : accompanyingItemList) {
if(AccompanyingItemType.TOOL.getCode().equals(aiv.getType()) if(AccompanyingItemType.TOOL.getCode().equals(aiv.getType())
|| AccompanyingItemType.EQUIPMENT.getCode().equals(aiv.getType())) { || AccompanyingItemType.EQUIPMENT.getCode().equals(aiv.getType())) {
OrderAccompanyDTO orderAccompanyDTO = new OrderAccompanyDTO(); OrderAccompanyDTO orderAccompanyDTO = BeanUtil.toBean(aiv, OrderAccompanyDTO.class);
orderAccompanyDTO.setId(aiv.getId());
orderAccompanyDTO.setName(aiv.getName());
orderAccompanyDTO.setUnit(aiv.getUnit());
orderAccompanyDTO.setUnitPrice(aiv.getPrice()); orderAccompanyDTO.setUnitPrice(aiv.getPrice());
orderAccompanyDTO.setNum(aiv.getNumber()); orderAccompanyDTO.setNum(aiv.getNumber());
oads.add(orderAccompanyDTO); oads.add(orderAccompanyDTO);
}else { }else {
OrderAccompanyDTO orderAccompanyDTO = orderAccompanyDTOMap.get(aiv.getId().toString()); OrderAccompanyDTO orderAccompanyDTO = orderAccompanyDTOMap.get(aiv.getId().toString());
if(null != orderAccompanyDTO) { if(null != orderAccompanyDTO) {
orderAccompanyDTO.setName(aiv.getName()); BeanUtil.copyProperties(aiv, orderAccompanyDTO);
orderAccompanyDTO.setUnit(aiv.getUnit());
orderAccompanyDTO.setUnitPrice(aiv.getPrice()); orderAccompanyDTO.setUnitPrice(aiv.getPrice());
oads.add(orderAccompanyDTO); oads.add(orderAccompanyDTO);
} }
} }
} }
bo.setAccompanyItems(oads); bo.setAccompanyItems(oads);
// for(OrderAccompanyDTO oad : bo.getAccompanyItems()) {
// AccompanyingItemVo aiv = accompanyingItemMap.get(oad.getId().toString());
// oad.setName(aiv.getName());
// oad.setUnit(aiv.getUnit());
// oad.setUnitPrice(aiv.getPrice());
// oad.setNum(aiv.getNumber());
// oad.setTotalAmount(oad.getUnitPrice().multiply(new BigDecimal(oad.getNum().toString())));
// }
//获取可用车辆 //获取可用车辆
acquireVehicle(bo); acquireVehicle(bo);
......
...@@ -59,9 +59,9 @@ public class SmsTemplateDTO { ...@@ -59,9 +59,9 @@ public class SmsTemplateDTO {
public static final int CANCEL_E = 21; public static final int CANCEL_E = 21;
//租车押金退还 //租车押金退还
public static final int FINISH_A = 22; public static final int REFUND_A = 22;
//违章押金退还 //违章押金退还
public static final int FINISH_B = 23; public static final int REFUND_B = 23;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment