提交 641b4e4f 作者: 张小凤

rental(add)

上级 8826de2a
...@@ -52,4 +52,6 @@ public interface RentalOrdersDao { ...@@ -52,4 +52,6 @@ public interface RentalOrdersDao {
OrderRefundDO getApplicationInformation(Integer id); OrderRefundDO getApplicationInformation(Integer id);
CouponDO couponMoney(Integer couponId);
} }
...@@ -48,21 +48,28 @@ public class RentalOrdersServiceImpl implements RentalOrdersService { ...@@ -48,21 +48,28 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
@Value("${userapp.url}") @Value("${userapp.url}")
private String userAppUrl; private String userAppUrl;
@Value("${pms.url}")
private String pmsUrl;
@Value("${payment.url}")
private String paymentUrl;
@Override @Override
public OrderInfoDTO feignAddLease(BaseAccountDTO user, LeaseOrderVO param) { public OrderInfoDTO feignAddLease(BaseAccountDTO user, LeaseOrderVO param) {
//用户信息的远程调用 //用户信息的远程调用
ResponseEntity<String> responseEntity = UserId(user.getUserAccountId()); ResponseEntity<String> responseEntity = UserId(user.getUserAccountId());
UserAccountSimpleDTO account = JSON.parseObject(responseEntity.getBody(), UserAccountSimpleDTO.class); UserAccountSimpleDTO account = JSON.parseObject(responseEntity.getBody(), UserAccountSimpleDTO.class);
OrderInfoDO orderInfo = new OrderInfoDO(param); //优惠券id获取优惠券面值
// 每天单价 OrderInfoDO orderInfo = new OrderInfoDO(param);
BigDecimal unitPrice = orderInfo.getUnitPrice(); PriceAcquisition priceAcquisition = getPriceAcquisition(param, account);
int i = 12; BigDecimal unitPrice = getUnitPrice(priceAcquisition);
BigDecimal bigDecimal = BigDecimal.valueOf(i); //每天单价
orderInfo.setUnitPrice(bigDecimal); orderInfo.setUnitPrice(unitPrice);
// 天数 // 天数
orderInfo.setPayDay(2); orderInfo.setActualPay(extracted(param, unitPrice));
orderInfo.setPayDay(day(param));
orderInfo.setRepoAccountId(user.getUserAccountId()); orderInfo.setRepoAccountId(user.getUserAccountId());
orderInfo.setUid(user.getUid()); orderInfo.setUid(user.getUid());
orderInfo.setBuyerName(user.getUserName()); orderInfo.setBuyerName(user.getUserName());
...@@ -83,6 +90,34 @@ public class RentalOrdersServiceImpl implements RentalOrdersService { ...@@ -83,6 +90,34 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return dto; return dto;
} }
/**
* 实际需要支付价格计算
*
* @param param
*/
private BigDecimal extracted(LeaseOrderVO param, BigDecimal unitPrice) {
CouponDO couponDO = rentalOrdersDao.couponMoney(param.getCouponId());
BigDecimal couponMoney = BigDecimal.valueOf(0);
if (couponDO != null) {
couponMoney = couponDO.getCouponMoney();
}
//实际需要支付的价格
BigDecimal dayDecimal = BigDecimal.valueOf(day(param));
BigDecimal multiply = dayDecimal.multiply(unitPrice);
BigDecimal actualPay = multiply.subtract(couponMoney);
return actualPay;
}
//远程设置
private PriceAcquisition getPriceAcquisition(LeaseOrderVO param, UserAccountSimpleDTO account) {
PriceAcquisition priceAcquisition = new PriceAcquisition();
priceAcquisition.setUserId(account.getId());
priceAcquisition.setDay(day(param));
priceAcquisition.setSpecsId(param.getSpecsId());
priceAcquisition.setChannelLevelId(account.getCooperationTagId());
return priceAcquisition;
}
private ResponseEntity<String> UserId(Integer repoAccountId) { private ResponseEntity<String> UserId(Integer repoAccountId) {
// 用户信息 // 用户信息
...@@ -95,38 +130,6 @@ public class RentalOrdersServiceImpl implements RentalOrdersService { ...@@ -95,38 +130,6 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return response; return response;
} }
@Override
@Transactional
public ResultBody addLease(BaseAccountDTO account, RentalOrderVO param) {
// 通过用户获取渠道等级id 未完善
Integer channelLevelId = getChannelLevel(account.getUserAccountId());
// 通过渠道等级获取每一天的单价 未完善
Double unitPrice = getUnitPrice(param, channelLevelId);
Integer day = day(param);
// 计算方式 单价 乘以 数量*天数 减去优惠券的价格最后得到需要支付的价格是吗
// 需要支付的价格
Double payment = null;
payment = unitPrice * param.getWareNum() * day;
CouponUserDO coupon = rentalOrdersDao.coupon(param.getCouponId());
// 优惠券是否过期
long now = System.currentTimeMillis();
long time = coupon.getEndTime().getTime();
if (now > time) {
return ResultBody.error("优惠券过期");
}
BigDecimal couponMoney = coupon.getCouponMoney();
double v = couponMoney.doubleValue();
payment -= v;
// 下单
OrderInfoDO orderInfoDO = new OrderInfoDO();
// rentalOrdersDao.insertOrderInfo(orderInfo);
return ResultBody.success();
}
/** /**
* 通过用户id 获取用户剩余的金额 * 通过用户id 获取用户剩余的金额
...@@ -139,7 +142,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService { ...@@ -139,7 +142,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
//封装请求头 //封装请求头
headers.add("token", token); headers.add("token", token);
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers); HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers);
ResponseEntity<String> result4 = restTemplate.exchange("http://localhost:8088/payment/repocash/RemainingBalance?repoAccountId=" + repoAccountId, ResponseEntity<String> result4 = restTemplate.exchange(paymentUrl + "repocash/RemainingBalance?repoAccountId=" + repoAccountId,
HttpMethod.GET, formEntity, String.class); HttpMethod.GET, formEntity, String.class);
String body = result4.getBody(); String body = result4.getBody();
BigDecimal bigDecimal = new BigDecimal(body); BigDecimal bigDecimal = new BigDecimal(body);
...@@ -162,38 +165,33 @@ public class RentalOrdersServiceImpl implements RentalOrdersService { ...@@ -162,38 +165,33 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
return 1; return 1;
} }
/** /**
* 获取每一天的价格 * 获取每一天的价格
* *
* @param
* @param param * @param param
* @param channelLevelId
* @return * @return
*/ */
private Double getUnitPrice(RentalOrderVO param, Integer channelLevelId) { private BigDecimal getUnitPrice(PriceAcquisition param) {
PriceAcquisition priceAcquisition = new PriceAcquisition();
// 传 规格id ,用户id,天数,渠道等级id 给刘,获取到价格
Date startDate = param.getStartDate();
Date endDate = param.getEndDate();
long start = startDate.getTime();
long end = endDate.getTime();
long day = end - start;
int i = (int) day;
// 调用远程接口获取单价 计算方式 单价 乘以 数量*天数 减去优惠券的价格最后得到需要支付的价格是吗
// 单价
Integer unitPrice = 1;
// 需要支付的价格 // 需要支付的价格
return 12.09; /* ResponseEntity<String> responseEntity = restTemplate.postForEntity(pmsUrl + "product/spec/getSpecLeaseUnitPrice"
, param, String.class);
String body = responseEntity.getBody();
BigDecimal bigDecimal = new BigDecimal(body);*/
// 模拟
int i = 12;
BigDecimal bigDecimal = BigDecimal.valueOf(i);
return bigDecimal;
} }
public Integer day(RentalOrderVO param) { public Integer day(LeaseOrderVO param) {
Date startDate = param.getStartDate(); Date startDate = param.getStartDate();
Date endDate = param.getEndDate(); Date endDate = param.getEndDate();
long start = startDate.getTime(); long start = startDate.getTime();
long end = endDate.getTime(); long end = endDate.getTime();
long day = end - start; long day = end - start;
int i = (int) day; Integer i = (int) day / 24 / 60 / 60 / 1000;
return i; return i;
} }
......
...@@ -5,13 +5,16 @@ import com.mmc.oms.common.ResultBody; ...@@ -5,13 +5,16 @@ import com.mmc.oms.common.ResultBody;
import com.mmc.oms.model.dto.BaseAccountDTO; import com.mmc.oms.model.dto.BaseAccountDTO;
import com.mmc.oms.model.dto.OrderInfoDTO; import com.mmc.oms.model.dto.OrderInfoDTO;
import com.mmc.oms.model.qo.OrderInfoQO; import com.mmc.oms.model.qo.OrderInfoQO;
import com.mmc.oms.model.vo.*; import com.mmc.oms.model.vo.LeaseOrderVO;
import com.mmc.oms.model.vo.OrderStatusVO;
import com.mmc.oms.model.vo.OrderVcuVO;
import com.mmc.oms.model.vo.ReturnWareVO;
/** /**
* @Author small @Date 2023/5/26 10:52 @Version 1.0 * @Author small @Date 2023/5/26 10:52 @Version 1.0
*/ */
public interface RentalOrdersService { public interface RentalOrdersService {
ResultBody addLease(BaseAccountDTO account, RentalOrderVO rentalOrderVO);
OrderInfoDTO getOrderDetail(String orderNo); OrderInfoDTO getOrderDetail(String orderNo);
......
...@@ -56,4 +56,7 @@ userapp: ...@@ -56,4 +56,7 @@ userapp:
payment: payment:
url: http://localhost:8088/payment/ url: http://localhost:8088/payment/
pms:
url: http://localhost:8099/pms/
...@@ -583,4 +583,34 @@ ...@@ -583,4 +583,34 @@
FROM order_refund FROM order_refund
where order_info_id = #{id} where order_info_id = #{id}
</select> </select>
<select id="couponMoney" resultType="com.mmc.oms.entity.CouponDO">
select id,
coupon_name,
coupon_money AS couponMoney,
coupon_discount,
is_limited,
restricted_access,
coupon_total,
last_total,
coupon_type,
use_type,
min_price,
primary_key,
is_fixed_time,
use_start_time,
use_end_time,
coupon_day,
get_type,
user_tag,
coupon_status,
is_del,
create_time,
update_time,
preferential_limit,
verification_type
from coupon
where is_del = false
and id = #{couponId}
</select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论