|
|
@ -30,6 +30,7 @@ import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -52,6 +53,43 @@ public class OrderAfterSalesApplyController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsOrderChildService orderChildService; |
|
|
|
private BsOrderChildService orderChildService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/calculate",method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "计算预计退款金额") |
|
|
|
|
|
|
|
public ResponseData calculate(@RequestParam(value = "childOrderNo" , required = true) String childOrderNo, |
|
|
|
|
|
|
|
@RequestParam(value = "productCount" , required = true) Integer productCount) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 查询子订单
|
|
|
|
|
|
|
|
OrderChildModel orderChild = orderChildService.getDetail(childOrderNo); |
|
|
|
|
|
|
|
if (orderChild == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品订单"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (productCount > orderChild.getSurplusRefundCount()) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "数量超过子订单可退数量"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
|
|
|
if (orderChild.getSurplusRefundCount().equals(productCount)) { |
|
|
|
|
|
|
|
// 全部退款
|
|
|
|
|
|
|
|
param.put("refundPrice", orderChild.getSurplusRefundPrice()); |
|
|
|
|
|
|
|
param.put("refundIntegral", orderChild.getSurplusRefundIntegral()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 部分退款
|
|
|
|
|
|
|
|
// 计算单价
|
|
|
|
|
|
|
|
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); |
|
|
|
|
|
|
|
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")) |
|
|
|
|
|
|
|
.divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); |
|
|
|
|
|
|
|
param.put("refundPrice", unitPrice.multiply(new BigDecimal(productCount.toString()))); |
|
|
|
|
|
|
|
param.put("refundIntegral", unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(param); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("error!",e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/apply",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/apply",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "申请") |
|
|
|
@ApiOperation(value = "申请") |
|
|
|