|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.kmall.api.contants.Dict;
|
|
import com.kmall.api.contants.Dict;
|
|
import com.kmall.api.dao.*;
|
|
import com.kmall.api.dao.*;
|
|
import com.kmall.api.entity.*;
|
|
import com.kmall.api.entity.*;
|
|
|
|
+import com.kmall.api.service.merch.OmsMerchPropertiesBuilder;
|
|
import com.kmall.api.util.CommonUtil;
|
|
import com.kmall.api.util.CommonUtil;
|
|
import com.kmall.common.dao.TemplateConfDao;
|
|
import com.kmall.common.dao.TemplateConfDao;
|
|
import com.kmall.common.entity.FormIdsEntity;
|
|
import com.kmall.common.entity.FormIdsEntity;
|
|
@@ -53,6 +54,8 @@ public class ApiOrderService {
|
|
private FormIdsService formIdsService;
|
|
private FormIdsService formIdsService;
|
|
@Autowired
|
|
@Autowired
|
|
private ApiGoodsMapper apiGoodsMapper;
|
|
private ApiGoodsMapper apiGoodsMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private FreightService freightService;
|
|
|
|
|
|
public OrderVo queryObject(Long id) {
|
|
public OrderVo queryObject(Long id) {
|
|
return apiOrderMapper.queryObject(id);
|
|
return apiOrderMapper.queryObject(id);
|
|
@@ -163,58 +166,76 @@ public class ApiOrderService {
|
|
productInfo.addSellVolume();
|
|
productInfo.addSellVolume();
|
|
productVos.add(productInfo);
|
|
productVos.add(productInfo);
|
|
}
|
|
}
|
|
- List<OrderVo> orderInfoList = new ArrayList();
|
|
|
|
- OrderVo order00 = null;
|
|
|
|
- OrderVo order02 = null;
|
|
|
|
- OrderVo order10 = null;
|
|
|
|
- OrderVo order11 = null;
|
|
|
|
- String merchOrderSn = "EMATO"+new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
|
|
|
|
|
|
+
|
|
|
|
+ BigDecimal freightPrice00 = new BigDecimal(0.00);
|
|
|
|
+ BigDecimal freightPrice02 = new BigDecimal(0.00);
|
|
|
|
+ BigDecimal freightPrice10 = new BigDecimal(0.00);
|
|
|
|
+ BigDecimal freightPrice11 = new BigDecimal(0.00);
|
|
|
|
+ Boolean isBizType00 = false;
|
|
|
|
+ Boolean isBizType02 = false;
|
|
|
|
+ Boolean isBizType10 = false;
|
|
|
|
+ Boolean isBizType11 = false;
|
|
//订单按业务类型进行分单
|
|
//订单按业务类型进行分单
|
|
for (CartVo goodsItem : checkedGoodsList) {
|
|
for (CartVo goodsItem : checkedGoodsList) {
|
|
//订单业务类型:00:保税备货, 02:保税展示补货,10:保税展示跨境,11:普通商品
|
|
//订单业务类型:00:保税备货, 02:保税展示补货,10:保税展示跨境,11:普通商品
|
|
if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
- order00 = setOrderVo(loginUser,jsonParam,storeId,checkedGoodsList,goodsItem.getGoodsBizType());
|
|
|
|
- order00.setOrderBizType(goodsItem.getGoodsBizType());
|
|
|
|
- order00.setMerchOrderSn(merchOrderSn);
|
|
|
|
- if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript00)) {
|
|
|
|
- order00.setPostscript(postscript00);
|
|
|
|
- }
|
|
|
|
|
|
+ FreightEntity freightEntity = freightService.queryObjectByGoodsId(goodsItem.getGoods_id());
|
|
|
|
+ freightPrice00 =freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;//查询商品运费信息
|
|
|
|
+ isBizType00 =true;
|
|
}
|
|
}
|
|
if(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
if(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
- order02 = setOrderVo(loginUser,jsonParam,storeId,checkedGoodsList,goodsItem.getGoodsBizType());
|
|
|
|
- order02.setOrderBizType(goodsItem.getGoodsBizType());
|
|
|
|
- order02.setMerchOrderSn(merchOrderSn);
|
|
|
|
- if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript02)) {
|
|
|
|
- order02.setPostscript(postscript02);
|
|
|
|
- }
|
|
|
|
|
|
+ FreightEntity freightEntity = freightService.queryObjectByGoodsId(goodsItem.getGoods_id());
|
|
|
|
+ freightPrice02 =freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;//查询商品运费信息
|
|
|
|
+ isBizType02 =true;
|
|
}
|
|
}
|
|
if(Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
if(Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
- order10 = setOrderVo(loginUser,jsonParam,storeId,checkedGoodsList,goodsItem.getGoodsBizType());
|
|
|
|
- order10.setOrderBizType(goodsItem.getGoodsBizType());
|
|
|
|
- order10.setMerchOrderSn(merchOrderSn);
|
|
|
|
- if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript10)) {
|
|
|
|
- order10.setPostscript(postscript10);
|
|
|
|
- }
|
|
|
|
|
|
+ FreightEntity freightEntity = freightService.queryObjectByGoodsId(goodsItem.getGoods_id());
|
|
|
|
+ freightPrice10 =freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;//查询商品运费信息
|
|
|
|
+ isBizType10 =true;
|
|
}
|
|
}
|
|
if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
- order11 = setOrderVo(loginUser,jsonParam,storeId,checkedGoodsList,goodsItem.getGoodsBizType());
|
|
|
|
- order11.setOrderBizType(goodsItem.getGoodsBizType());
|
|
|
|
- order11.setMerchOrderSn(merchOrderSn);
|
|
|
|
- if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript11)) {
|
|
|
|
- order11.setPostscript(postscript11);
|
|
|
|
- }
|
|
|
|
|
|
+ FreightEntity freightEntity = freightService.queryObjectByGoodsId(goodsItem.getGoods_id());
|
|
|
|
+ freightPrice11 =freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice11;//查询商品运费信息
|
|
|
|
+ isBizType11 =true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(order00!=null){
|
|
|
|
|
|
+
|
|
|
|
+ List<OrderVo> orderInfoList = new ArrayList();
|
|
|
|
+ String merchOrderSn = "EMATO"+new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
|
|
|
|
+ if(isBizType00){
|
|
|
|
+ OrderVo order00 = setOrderVo(loginUser,jsonParam,storeId,freightPrice00,checkedGoodsList,Dict.orderBizType.item_00.getItem());
|
|
|
|
+ order00.setOrderBizType(Dict.orderBizType.item_00.getItem());
|
|
|
|
+ order00.setMerchOrderSn(merchOrderSn);
|
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript00)) {
|
|
|
|
+ order00.setPostscript(postscript00);
|
|
|
|
+ }
|
|
orderInfoList.add(order00);
|
|
orderInfoList.add(order00);
|
|
}
|
|
}
|
|
- if(order02!=null){
|
|
|
|
|
|
+ if(isBizType02){
|
|
|
|
+ OrderVo order02 = setOrderVo(loginUser,jsonParam,storeId,freightPrice02,checkedGoodsList,Dict.orderBizType.item_02.getItem());
|
|
|
|
+ order02.setOrderBizType(Dict.orderBizType.item_02.getItem());
|
|
|
|
+ order02.setMerchOrderSn(merchOrderSn);
|
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript02)) {
|
|
|
|
+ order02.setPostscript(postscript02);
|
|
|
|
+ }
|
|
orderInfoList.add(order02);
|
|
orderInfoList.add(order02);
|
|
}
|
|
}
|
|
- if(order10!=null){
|
|
|
|
|
|
+ if(isBizType10){
|
|
|
|
+ OrderVo order10 = setOrderVo(loginUser,jsonParam,storeId,freightPrice10,checkedGoodsList,Dict.orderBizType.item_10.getItem());
|
|
|
|
+ order10.setOrderBizType(Dict.orderBizType.item_10.getItem());
|
|
|
|
+ order10.setMerchOrderSn(merchOrderSn);
|
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript10)) {
|
|
|
|
+ order10.setPostscript(postscript10);
|
|
|
|
+ }
|
|
orderInfoList.add(order10);
|
|
orderInfoList.add(order10);
|
|
}
|
|
}
|
|
- if(order11!=null){
|
|
|
|
|
|
+ if(isBizType11){
|
|
|
|
+ OrderVo order11 = setOrderVo(loginUser,jsonParam,storeId,freightPrice11,checkedGoodsList,Dict.orderBizType.item_11.getItem());
|
|
|
|
+ order11.setOrderBizType(Dict.orderBizType.item_11.getItem());
|
|
|
|
+ order11.setMerchOrderSn(merchOrderSn);
|
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(postscript11)) {
|
|
|
|
+ order11.setPostscript(postscript11);
|
|
|
|
+ }
|
|
orderInfoList.add(order11);
|
|
orderInfoList.add(order11);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -261,16 +282,17 @@ public class ApiOrderService {
|
|
resultObj.put("data", orderInfoMap);
|
|
resultObj.put("data", orderInfoMap);
|
|
|
|
|
|
// 优惠券标记已用
|
|
// 优惠券标记已用
|
|
- for (OrderVo orderInfo : orderInfoList) {
|
|
|
|
|
|
+ /*for (OrderVo orderInfo : orderInfoList) {
|
|
if (null != userCouponId && 0 != userCouponId) {
|
|
if (null != userCouponId && 0 != userCouponId) {
|
|
UserCouponVo userCouponVo = apiUserCouponMapper.queryObject(userCouponId);
|
|
UserCouponVo userCouponVo = apiUserCouponMapper.queryObject(userCouponId);
|
|
if (null != userCouponVo && (null == userCouponVo.getOrder_id() || 0 == userCouponVo.getOrder_id())) {
|
|
if (null != userCouponVo && (null == userCouponVo.getOrder_id() || 0 == userCouponVo.getOrder_id())) {
|
|
userCouponVo.setUsed_time(new Date());
|
|
userCouponVo.setUsed_time(new Date());
|
|
userCouponVo.setOrder_id(orderInfo.getId());
|
|
userCouponVo.setOrder_id(orderInfo.getId());
|
|
|
|
+ userCouponVo.setIsUsed(Dict.isUsed.item_1.getItem());
|
|
apiUserCouponMapper.update(userCouponVo);
|
|
apiUserCouponMapper.update(userCouponVo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
}
|
|
}
|
|
|
|
|
|
return resultObj;
|
|
return resultObj;
|
|
@@ -281,15 +303,15 @@ public class ApiOrderService {
|
|
* @param loginUser
|
|
* @param loginUser
|
|
* @param jsonParam
|
|
* @param jsonParam
|
|
* @param storeId
|
|
* @param storeId
|
|
|
|
+ * @param freightPrice
|
|
* @param checkedGoodsList
|
|
* @param checkedGoodsList
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public OrderVo setOrderVo(UserVo loginUser,JSONObject jsonParam,Long storeId,List<CartVo> checkedGoodsList,String orderBizType){
|
|
|
|
|
|
+ public OrderVo setOrderVo(UserVo loginUser,JSONObject jsonParam,Long storeId,BigDecimal freightPrice,List<CartVo> checkedGoodsList,String bizType){
|
|
|
|
+ OrderVo orderInfo = new OrderVo();
|
|
Integer userCouponId = jsonParam.getInteger("userCouponId");
|
|
Integer userCouponId = jsonParam.getInteger("userCouponId");
|
|
String postscript = jsonParam.getString("postscript");
|
|
String postscript = jsonParam.getString("postscript");
|
|
- Long fullCutCouponId = jsonParam.getLong("fullCutCouponId");
|
|
|
|
-// BigDecimal freightPrice = new BigDecimal(10.00);
|
|
|
|
- BigDecimal freightPrice = new BigDecimal(0.00);
|
|
|
|
|
|
+ Long fullCutCouponId = jsonParam.getLong("fullCutCouponId");//满减券
|
|
AddressVo addressVo = jsonParam.getObject("checkedAddress", AddressVo.class);
|
|
AddressVo addressVo = jsonParam.getObject("checkedAddress", AddressVo.class);
|
|
Date delivery_date = jsonParam.getDate("delivery_date");
|
|
Date delivery_date = jsonParam.getDate("delivery_date");
|
|
if (null == delivery_date) {
|
|
if (null == delivery_date) {
|
|
@@ -299,53 +321,60 @@ public class ApiOrderService {
|
|
if (StringUtils.isNullOrEmpty(delivery_remark)) {
|
|
if (StringUtils.isNullOrEmpty(delivery_remark)) {
|
|
delivery_remark = "尽快送达";
|
|
delivery_remark = "尽快送达";
|
|
}
|
|
}
|
|
-
|
|
|
|
- //统计商品总价
|
|
|
|
|
|
+ BigDecimal fullCutCouponDec = new BigDecimal(0);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
- for (CartVo cartItem : checkedGoodsList) {
|
|
|
|
- if(orderBizType.equalsIgnoreCase(cartItem.getGoodsBizType())){
|
|
|
|
- goodsTotalPrice = goodsTotalPrice.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
|
|
|
|
|
|
+ for (CartVo goodsItem : checkedGoodsList) {
|
|
|
|
+ if(bizType.equalsIgnoreCase(goodsItem.getGoodsBizType())){
|
|
|
|
+ goodsTotalPrice = goodsTotalPrice.add(goodsItem.getRetail_price().multiply(new BigDecimal(goodsItem.getNumber())));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //获取订单使用的优惠券
|
|
|
|
- BigDecimal couponPrice = new BigDecimal(0.00);
|
|
|
|
|
|
+ //查询未使用的优惠券
|
|
String couponName = "";
|
|
String couponName = "";
|
|
|
|
+ UserCouponVo couponVo = null;
|
|
|
|
+ BigDecimal couponPrice = new BigDecimal(0.00);
|
|
if (null != userCouponId && 0 != userCouponId) {
|
|
if (null != userCouponId && 0 != userCouponId) {
|
|
- UserCouponVo couponVo = apiUserCouponMapper.queryObject(userCouponId);
|
|
|
|
|
|
+ couponVo = apiUserCouponMapper.queryObjectByIdAndUsed(userCouponId);
|
|
if (null != couponVo && null != couponVo.getType_money()) {
|
|
if (null != couponVo && null != couponVo.getType_money()) {
|
|
couponPrice = couponVo.getType_money();
|
|
couponPrice = couponVo.getType_money();
|
|
couponName = couponVo.getCoupon_name();
|
|
couponName = couponVo.getCoupon_name();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 获取优惠信息提示
|
|
|
|
-// Map couponParam = new HashMap();
|
|
|
|
-// couponParam.put("enabled", true);
|
|
|
|
-// Integer[] send_types = new Integer[]{7};
|
|
|
|
-// couponParam.put("send_types", send_types);
|
|
|
|
-// List<CouponVo> couponVos = apiCouponMapper.queryList(couponParam);
|
|
|
|
-// if (null != couponVos && couponVos.size() > 0) {
|
|
|
|
-// for (CouponVo couponVo : couponVos) {
|
|
|
|
-// // 是否免运费
|
|
|
|
-// if (couponVo.getSend_type() == 7 && couponVo.getMin_goods_amount().compareTo(goodsTotalPrice) <= 0) {
|
|
|
|
-// freightPrice = couponVo.getType_money();
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- // 获取优惠信息 满减
|
|
|
|
- BigDecimal fullCutCouponDec = new BigDecimal(0);
|
|
|
|
|
|
+
|
|
|
|
+ /*// 获取优惠信息提示
|
|
|
|
+ Map couponParam = new HashMap();
|
|
|
|
+ couponParam.put("enabled", true);
|
|
|
|
+ Integer[] send_types = new Integer[]{7};
|
|
|
|
+ couponParam.put("send_types", send_types);
|
|
|
|
+ List<CouponVo> couponVos = apiCouponMapper.queryList(couponParam);
|
|
|
|
+ if (null != couponVos && couponVos.size() > 0) {
|
|
|
|
+ for (CouponVo couponVo : couponVos) {
|
|
|
|
+ // 是否免运费
|
|
|
|
+ if (couponVo.getSend_type() == 7 && couponVo.getMin_goods_amount().compareTo(goodsTotalPrice) <= 0) {
|
|
|
|
+ freightPrice = couponVo.getType_money();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //todo 获取优惠信息 满减,暂时不用
|
|
CouponVo fullCutCoupon = apiCouponMapper.queryObject(fullCutCouponId);
|
|
CouponVo fullCutCoupon = apiCouponMapper.queryObject(fullCutCouponId);
|
|
if (null != fullCutCoupon) {
|
|
if (null != fullCutCoupon) {
|
|
fullCutCouponDec = fullCutCoupon.getType_money();
|
|
fullCutCouponDec = fullCutCoupon.getType_money();
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
- //订单价格计算
|
|
|
|
- BigDecimal orderTotalPrice = goodsTotalPrice.add(freightPrice); //订单的总价+运费
|
|
|
|
|
|
+ //订单价格计算:订单的总价+运费
|
|
|
|
+ BigDecimal orderTotalPrice = goodsTotalPrice.add(freightPrice);
|
|
|
|
|
|
- BigDecimal actualPrice = orderTotalPrice.subtract(fullCutCouponDec).subtract(couponPrice); //减去其它支付的金额后,要实际支付的金额
|
|
|
|
|
|
+ //减去其它支付的金额后,要实际支付的金额 订单的总价+运费-优惠券金额
|
|
|
|
+ BigDecimal actualPrice = orderTotalPrice.subtract(couponPrice);
|
|
|
|
+// BigDecimal actualPrice = orderTotalPrice.subtract(fullCutCouponDec).subtract(couponPrice);
|
|
|
|
+
|
|
|
|
+ //商户(拼音首字母)+业务类型+编号
|
|
|
|
+ String merchSn = OmsMerchPropertiesBuilder.instance().getMerchSn();
|
|
|
|
+ String merchShortName = OmsMerchPropertiesBuilder.instance().getMerchShortName();
|
|
|
|
+ String orderSn = merchShortName + bizType + CommonUtil.generateOrderNumber();
|
|
|
|
+ orderInfo.setOrder_sn(orderSn);
|
|
|
|
+ orderInfo.setMerchSn(merchSn);
|
|
|
|
|
|
- OrderVo orderInfo = new OrderVo();
|
|
|
|
- orderInfo.setOrder_sn(CommonUtil.generateOrderNumber());
|
|
|
|
orderInfo.setUser_id(loginUser.getId());
|
|
orderInfo.setUser_id(loginUser.getId());
|
|
//收货地址和运费
|
|
//收货地址和运费
|
|
orderInfo.setConsignee(addressVo.getUserName());
|
|
orderInfo.setConsignee(addressVo.getUserName());
|
|
@@ -361,12 +390,15 @@ public class ApiOrderService {
|
|
orderInfo.setStore_id(storeId);
|
|
orderInfo.setStore_id(storeId);
|
|
//
|
|
//
|
|
orderInfo.setFreight_price(freightPrice.intValue());
|
|
orderInfo.setFreight_price(freightPrice.intValue());
|
|
|
|
+
|
|
|
|
+ orderInfo.setCoupon_id(userCouponId);
|
|
|
|
+ orderInfo.setCoupon_price(couponPrice);
|
|
|
|
+ orderInfo.setCoupon_name(couponName);
|
|
|
|
+
|
|
//留言
|
|
//留言
|
|
orderInfo.setPostscript(postscript);
|
|
orderInfo.setPostscript(postscript);
|
|
//使用的优惠券
|
|
//使用的优惠券
|
|
orderInfo.setFull_cut_price(fullCutCouponDec);
|
|
orderInfo.setFull_cut_price(fullCutCouponDec);
|
|
- orderInfo.setCoupon_id(userCouponId);
|
|
|
|
- orderInfo.setCoupon_price(couponPrice);
|
|
|
|
orderInfo.setAdd_time(new Date());
|
|
orderInfo.setAdd_time(new Date());
|
|
orderInfo.setGoods_price(goodsTotalPrice);
|
|
orderInfo.setGoods_price(goodsTotalPrice);
|
|
orderInfo.setOrder_price(orderTotalPrice);
|
|
orderInfo.setOrder_price(orderTotalPrice);
|
|
@@ -379,13 +411,19 @@ public class ApiOrderService {
|
|
orderInfo.setShipping_id(0L);
|
|
orderInfo.setShipping_id(0L);
|
|
orderInfo.setShipping_fee(new BigDecimal(0));
|
|
orderInfo.setShipping_fee(new BigDecimal(0));
|
|
orderInfo.setIntegral(0);
|
|
orderInfo.setIntegral(0);
|
|
- orderInfo.setCoupon_name(couponName);
|
|
|
|
orderInfo.setIntegral_money(new BigDecimal(0));
|
|
orderInfo.setIntegral_money(new BigDecimal(0));
|
|
orderInfo.setCreateTime(new Date());
|
|
orderInfo.setCreateTime(new Date());
|
|
orderInfo.setModTime(new Date());
|
|
orderInfo.setModTime(new Date());
|
|
orderInfo.setPayMobile(loginUser.getMobile());
|
|
orderInfo.setPayMobile(loginUser.getMobile());
|
|
orderInfo.setPayTransactionId("");
|
|
orderInfo.setPayTransactionId("");
|
|
orderInfo.setIsScan("0");//默认未扫描
|
|
orderInfo.setIsScan("0");//默认未扫描
|
|
|
|
+
|
|
|
|
+ //标记该订单已使用优惠券
|
|
|
|
+ if(couponVo != null){
|
|
|
|
+ couponVo.setUsed_time(new Date());
|
|
|
|
+ couponVo.setIsUsed(Dict.isUsed.item_1.getItem());
|
|
|
|
+ apiUserCouponMapper.update(couponVo);
|
|
|
|
+ }
|
|
return orderInfo;
|
|
return orderInfo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -408,7 +446,41 @@ public class ApiOrderService {
|
|
orderGoodsVo.setModTime(new Date());
|
|
orderGoodsVo.setModTime(new Date());
|
|
|
|
|
|
orderGoodsVo.setGoodsRate(goodsVo.getGoodsRate());
|
|
orderGoodsVo.setGoodsRate(goodsVo.getGoodsRate());
|
|
- orderGoodsVo.setSettlePrice(new BigDecimal("0"));//商品结算平摊价格=(零售价格*数量)/订单结算总金额
|
|
|
|
|
|
+
|
|
|
|
+ BigDecimal number = new BigDecimal(Long.valueOf(goodsItem.getNumber()));
|
|
|
|
+ BigDecimal goodsTotal = goodsItem.getRetail_price().multiply(number);//单商品总价
|
|
|
|
+ BigDecimal rate = goodsTotal.divide(orderInfo.getGoods_price(),2, BigDecimal.ROUND_HALF_UP);//单商品总价/订单总价(不含运费、不含优惠券)
|
|
|
|
+ BigDecimal freightPrice = BigDecimal.valueOf(orderInfo.getFreight_price());
|
|
|
|
+ BigDecimal settlePrice = new BigDecimal(0);
|
|
|
|
+ if(orderInfo.getFreight_price()!=0 && !"0".equalsIgnoreCase(orderInfo.getCoupon_price()+"")){
|
|
|
|
+ //运费-优惠券
|
|
|
|
+ BigDecimal rateTotal = freightPrice.subtract(orderInfo.getCoupon_price());
|
|
|
|
+
|
|
|
|
+ //商品结算平摊价格(含优惠券、运费金额) = 单商品总价 + 单商品总价/订单总价(不含运费、不含优惠券) * 运费与优惠券合计税率
|
|
|
|
+ settlePrice = goodsTotal.add(rate.multiply(rateTotal));
|
|
|
|
+ }else{
|
|
|
|
+ if(orderInfo.getFreight_price()!=0){
|
|
|
|
+ //运费税率 = 单商品总价/订单总价(不含运费)* 运费金额
|
|
|
|
+ BigDecimal freightRate = rate.multiply(freightPrice);
|
|
|
|
+
|
|
|
|
+ //商品结算平摊价格(含运费金额) = 单商品总价+运费税率
|
|
|
|
+ settlePrice = goodsTotal.add(freightRate);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(!"0".equalsIgnoreCase(orderInfo.getCoupon_price()+"")){
|
|
|
|
+
|
|
|
|
+ //优惠券税率 = 单商品总价/订单总价(不含优惠券)* 优惠券金额
|
|
|
|
+ BigDecimal couponRate = rate.multiply(orderInfo.getCoupon_price());
|
|
|
|
+
|
|
|
|
+ //商品结算平摊价格(含优惠券金额) = 单商品总价-优惠券税率
|
|
|
|
+ settlePrice = goodsTotal.subtract(couponRate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(settlePrice.compareTo(BigDecimal.valueOf(0)) == 0){
|
|
|
|
+ orderGoodsVo.setSettlePrice(goodsTotal);//商品结算平摊价格
|
|
|
|
+ }else{
|
|
|
|
+ orderGoodsVo.setSettlePrice(settlePrice);//商品结算平摊价格
|
|
|
|
+ }
|
|
return orderGoodsVo;
|
|
return orderGoodsVo;
|
|
}
|
|
}
|
|
/**
|
|
/**
|