四种商品价格及阶梯价格
This commit is contained in:
@@ -3,6 +3,7 @@ package com.yxt.yythmall.api.lpkgoods;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -41,4 +42,8 @@ public class LpkGoods {
|
||||
private String brandName; // 品牌名称';
|
||||
private Long categoryId; // 类别ID';
|
||||
private String categoryName; // 类别名称';
|
||||
@ApiModelProperty("阶梯重量")
|
||||
private String stepWeight;
|
||||
@ApiModelProperty("阶梯价格")
|
||||
private String stepPrice;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.yxt.yythmall.api.empcardbuildrecord.EmpCardBuildRecordQuery;
|
||||
import com.yxt.yythmall.api.empcardbuildrecord.EmpCardBuildRecordVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomer;
|
||||
import com.yxt.yythmall.api.lpkgiftcard.LpkGiftCardQuery;
|
||||
import com.yxt.yythmall.api.lpkgoods.LpkGoods;
|
||||
import com.yxt.yythmall.api.ordorder.OrdOrderDto;
|
||||
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetailVo;
|
||||
import com.yxt.yythmall.api.shoppingcart.ShoppingCart;
|
||||
@@ -23,6 +24,7 @@ import com.yxt.yythmall.api.shoppingcart.ShoppingCartQuery;
|
||||
import com.yxt.yythmall.api.shoppingcart.ShoppingCartVo;
|
||||
import com.yxt.yythmall.biz.empcard.EmpCardService;
|
||||
import com.yxt.yythmall.biz.lpkcustomer.LpkCustomerService;
|
||||
import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -41,6 +43,8 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
private FileUploadComponent fileUploadComponent;
|
||||
@Autowired
|
||||
LpkCustomerService lpkCustomerService;
|
||||
@Autowired
|
||||
private LpkGoodsService lpkGoodsService;
|
||||
|
||||
public ResultBean save(ShoppingCartDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
@@ -64,6 +68,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
baseMapper.insert(entity);
|
||||
return rb.success().setMsg("成功");
|
||||
}
|
||||
|
||||
public ResultBean<List<ShoppingCartVo>> shoppingCartList(ShoppingCartQuery query) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
ShoppingCart entity = new ShoppingCart();
|
||||
@@ -75,6 +80,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
|
||||
return rb.success().setData(list).setMsg("成功");
|
||||
}
|
||||
|
||||
public ResultBean minusShoppingCart(ShoppingCartDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
ShoppingCart entity = new ShoppingCart();
|
||||
@@ -91,21 +97,41 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
// baseMapper.insert(entity);
|
||||
return rb.success().setMsg("成功");
|
||||
}
|
||||
|
||||
public ResultBean delShoppingCart(String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
ShoppingCart entity = new ShoppingCart();
|
||||
baseMapper.delete(new QueryWrapper<ShoppingCart>().eq("sid ", sid));
|
||||
return rb.success().setMsg("成功");
|
||||
}
|
||||
|
||||
public ResultBean getGoodsWeight(ShoppingCartQuery query) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
List<ShoppingCartVo> list = baseMapper.ShoppingCartList(query.getCustomerSid(), query.getBrandId());
|
||||
double price = 0;
|
||||
double weight = 0;
|
||||
for (ShoppingCartVo vo : list) {
|
||||
LpkGoods lpkGoods = lpkGoodsService.fetchBySid(vo.getGoodsSid());
|
||||
String stepWeight = lpkGoods.getStepWeight();
|
||||
String stepPrice = lpkGoods.getStepPrice();
|
||||
if (new BigDecimal(stepPrice).compareTo(BigDecimal.ZERO) == 0) {
|
||||
stepPrice = vo.getJPrice();
|
||||
}
|
||||
if ("北京3号白菜".equals(vo.getGoodsName())
|
||||
|| "玲珑黄白菜".equals(vo.getGoodsName())
|
||||
|| "V7土豆".equals(vo.getGoodsName())
|
||||
|| "黄金薯土豆".equals(vo.getGoodsName())) {
|
||||
BigDecimal weightW = new BigDecimal(vo.getWeight());
|
||||
if (weightW.compareTo(new BigDecimal(stepWeight)) >= 0) {
|
||||
price = Double.valueOf(stepPrice) * Double.valueOf(vo.getGoodsNumber()) + price;
|
||||
weight = Double.valueOf(vo.getWeight()) * Double.valueOf(vo.getGoodsNumber()) + price;
|
||||
}
|
||||
} else {
|
||||
price = Double.valueOf(vo.getPrice()) * Double.valueOf(vo.getGoodsNumber()) + price;
|
||||
weight = Double.valueOf(vo.getWeight()) * Double.valueOf(vo.getGoodsNumber()) + weight;
|
||||
}
|
||||
|
||||
}
|
||||
ShoppingCartVo vo = new ShoppingCartVo();
|
||||
// vo.setText("1.20斤起订量。\n" +
|
||||
// "2.新用户正好20斤5折。\n" +
|
||||
@@ -117,6 +143,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
vo = price(vo);
|
||||
return rb.success().setData(vo);
|
||||
}
|
||||
|
||||
private ShoppingCartVo price(ShoppingCartVo vo) {
|
||||
int weight = Integer.parseInt(vo.getTotalWeight());
|
||||
LpkCustomer lpkCustomer = lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid", vo.getCustomerSid()));
|
||||
@@ -181,8 +208,10 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除多余.0
|
||||
*
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user