四种商品价格及阶梯价格
This commit is contained in:
@@ -3,6 +3,7 @@ package com.yxt.yythmall.api.lpkgoods;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -41,4 +42,8 @@ public class LpkGoods {
|
|||||||
private String brandName; // 品牌名称';
|
private String brandName; // 品牌名称';
|
||||||
private Long categoryId; // 类别ID';
|
private Long categoryId; // 类别ID';
|
||||||
private String categoryName; // 类别名称';
|
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.empcardbuildrecord.EmpCardBuildRecordVo;
|
||||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomer;
|
import com.yxt.yythmall.api.lpkcustomer.LpkCustomer;
|
||||||
import com.yxt.yythmall.api.lpkgiftcard.LpkGiftCardQuery;
|
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.ordorder.OrdOrderDto;
|
||||||
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetailVo;
|
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetailVo;
|
||||||
import com.yxt.yythmall.api.shoppingcart.ShoppingCart;
|
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.api.shoppingcart.ShoppingCartVo;
|
||||||
import com.yxt.yythmall.biz.empcard.EmpCardService;
|
import com.yxt.yythmall.biz.empcard.EmpCardService;
|
||||||
import com.yxt.yythmall.biz.lpkcustomer.LpkCustomerService;
|
import com.yxt.yythmall.biz.lpkcustomer.LpkCustomerService;
|
||||||
|
import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -41,20 +43,22 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
private FileUploadComponent fileUploadComponent;
|
private FileUploadComponent fileUploadComponent;
|
||||||
@Autowired
|
@Autowired
|
||||||
LpkCustomerService lpkCustomerService;
|
LpkCustomerService lpkCustomerService;
|
||||||
|
@Autowired
|
||||||
|
private LpkGoodsService lpkGoodsService;
|
||||||
|
|
||||||
public ResultBean save(ShoppingCartDto dto) {
|
public ResultBean save(ShoppingCartDto dto) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
ShoppingCart entity=new ShoppingCart();
|
ShoppingCart entity = new ShoppingCart();
|
||||||
List<ShoppingCart> list= baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("customerSid",dto.getCustomerSid())
|
List<ShoppingCart> list = baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("customerSid", dto.getCustomerSid())
|
||||||
.eq("goodsSid",dto.getGoodsSid())
|
.eq("goodsSid", dto.getGoodsSid())
|
||||||
.eq("affiliation",dto.getAffiliation()));
|
.eq("affiliation", dto.getAffiliation()));
|
||||||
if(list.size()>0){
|
if (list.size() > 0) {
|
||||||
// list.get(0).setGoodsNumber(String.valueOf(Double.valueOf(dto.getGoodsNumber())+Double.valueOf(list.get(0).getGoodsNumber())));
|
// list.get(0).setGoodsNumber(String.valueOf(Double.valueOf(dto.getGoodsNumber())+Double.valueOf(list.get(0).getGoodsNumber())));
|
||||||
if(dto.getGoodsNumber().equals("0")){
|
if (dto.getGoodsNumber().equals("0")) {
|
||||||
baseMapper.delete(new QueryWrapper<ShoppingCart>().eq("customerSid",dto.getCustomerSid())
|
baseMapper.delete(new QueryWrapper<ShoppingCart>().eq("customerSid", dto.getCustomerSid())
|
||||||
.eq("goodsSid",dto.getGoodsSid())
|
.eq("goodsSid", dto.getGoodsSid())
|
||||||
.eq("affiliation",dto.getAffiliation()));
|
.eq("affiliation", dto.getAffiliation()));
|
||||||
}else{
|
} else {
|
||||||
list.get(0).setGoodsNumber(dto.getGoodsNumber());
|
list.get(0).setGoodsNumber(dto.getGoodsNumber());
|
||||||
baseMapper.updateById(list.get(0));
|
baseMapper.updateById(list.get(0));
|
||||||
}
|
}
|
||||||
@@ -64,26 +68,28 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
baseMapper.insert(entity);
|
baseMapper.insert(entity);
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean<List<ShoppingCartVo>> shoppingCartList(ShoppingCartQuery query) {
|
public ResultBean<List<ShoppingCartVo>> shoppingCartList(ShoppingCartQuery query) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
ShoppingCart entity=new ShoppingCart();
|
ShoppingCart entity = new ShoppingCart();
|
||||||
List<ShoppingCartVo> list= baseMapper.ShoppingCartList(query.getCustomerSid(),query.getBrandId());
|
List<ShoppingCartVo> list = baseMapper.ShoppingCartList(query.getCustomerSid(), query.getBrandId());
|
||||||
list.forEach(s->{
|
list.forEach(s -> {
|
||||||
s.setTotalPrice(removeZeros(String.valueOf((Double.valueOf(s.getJPrice())* Double.valueOf(s.getGoodsNumber())))));
|
s.setTotalPrice(removeZeros(String.valueOf((Double.valueOf(s.getJPrice()) * Double.valueOf(s.getGoodsNumber())))));
|
||||||
s.setIconUrl(fileUploadComponent.getUrlPrefix() +s.getIconUrl());
|
s.setIconUrl(fileUploadComponent.getUrlPrefix() + s.getIconUrl());
|
||||||
});
|
});
|
||||||
|
|
||||||
return rb.success().setData(list).setMsg("成功");
|
return rb.success().setData(list).setMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean minusShoppingCart(ShoppingCartDto dto) {
|
public ResultBean minusShoppingCart(ShoppingCartDto dto) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
ShoppingCart entity=new ShoppingCart();
|
ShoppingCart entity = new ShoppingCart();
|
||||||
// List<ShoppingCart> list= baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("sid",dto.getSid()));
|
// List<ShoppingCart> list= baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("sid",dto.getSid()));
|
||||||
List<ShoppingCart> list= baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("customerSid",dto.getCustomerSid())
|
List<ShoppingCart> list = baseMapper.selectList(new QueryWrapper<ShoppingCart>().eq("customerSid", dto.getCustomerSid())
|
||||||
.eq("goodsSid",dto.getGoodsSid())
|
.eq("goodsSid", dto.getGoodsSid())
|
||||||
.eq("affiliation",dto.getAffiliation()));
|
.eq("affiliation", dto.getAffiliation()));
|
||||||
if(list.size()>0){
|
if (list.size() > 0) {
|
||||||
list.get(0).setGoodsNumber(String.valueOf(Double.valueOf(list.get(0).getGoodsNumber())-Double.valueOf(dto.getGoodsNumber())));
|
list.get(0).setGoodsNumber(String.valueOf(Double.valueOf(list.get(0).getGoodsNumber()) - Double.valueOf(dto.getGoodsNumber())));
|
||||||
baseMapper.updateById(list.get(0));
|
baseMapper.updateById(list.get(0));
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
@@ -91,22 +97,42 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
// baseMapper.insert(entity);
|
// baseMapper.insert(entity);
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean delShoppingCart(String sid) {
|
public ResultBean delShoppingCart(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
ShoppingCart entity=new ShoppingCart();
|
ShoppingCart entity = new ShoppingCart();
|
||||||
baseMapper.delete(new QueryWrapper<ShoppingCart>().eq("sid ",sid));
|
baseMapper.delete(new QueryWrapper<ShoppingCart>().eq("sid ", sid));
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean getGoodsWeight(ShoppingCartQuery query) {
|
public ResultBean getGoodsWeight(ShoppingCartQuery query) {
|
||||||
ResultBean rb=new ResultBean().fail();
|
ResultBean rb = new ResultBean().fail();
|
||||||
List<ShoppingCartVo> list= baseMapper.ShoppingCartList(query.getCustomerSid(),query.getBrandId());
|
List<ShoppingCartVo> list = baseMapper.ShoppingCartList(query.getCustomerSid(), query.getBrandId());
|
||||||
double price =0;
|
double price = 0;
|
||||||
double weight =0;
|
double weight = 0;
|
||||||
for(ShoppingCartVo vo:list){
|
for (ShoppingCartVo vo : list) {
|
||||||
price=Double.valueOf(vo.getPrice())*Double.valueOf(vo.getGoodsNumber())+price;
|
LpkGoods lpkGoods = lpkGoodsService.fetchBySid(vo.getGoodsSid());
|
||||||
weight=Double.valueOf(vo.getWeight())*Double.valueOf(vo.getGoodsNumber())+weight;
|
String stepWeight = lpkGoods.getStepWeight();
|
||||||
|
String stepPrice = lpkGoods.getStepPrice();
|
||||||
|
if (new BigDecimal(stepPrice).compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
stepPrice = vo.getJPrice();
|
||||||
}
|
}
|
||||||
ShoppingCartVo vo =new ShoppingCartVo();
|
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" +
|
// vo.setText("1.20斤起订量。\n" +
|
||||||
// "2.新用户正好20斤5折。\n" +
|
// "2.新用户正好20斤5折。\n" +
|
||||||
// "3.20-100斤加10%附加额。\n" +
|
// "3.20-100斤加10%附加额。\n" +
|
||||||
@@ -114,27 +140,28 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
vo.setCustomerSid(query.getCustomerSid());
|
vo.setCustomerSid(query.getCustomerSid());
|
||||||
vo.setTotalPrice(removeZeros(String.valueOf(price)));
|
vo.setTotalPrice(removeZeros(String.valueOf(price)));
|
||||||
vo.setTotalWeight(removeZeros(String.valueOf(weight)));
|
vo.setTotalWeight(removeZeros(String.valueOf(weight)));
|
||||||
vo=price(vo);
|
vo = price(vo);
|
||||||
return rb.success().setData(vo);
|
return rb.success().setData(vo);
|
||||||
}
|
}
|
||||||
private ShoppingCartVo price(ShoppingCartVo vo){
|
|
||||||
int weight=Integer.parseInt(vo.getTotalWeight());
|
private ShoppingCartVo price(ShoppingCartVo vo) {
|
||||||
LpkCustomer lpkCustomer=lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid",vo.getCustomerSid()));
|
int weight = Integer.parseInt(vo.getTotalWeight());
|
||||||
|
LpkCustomer lpkCustomer = lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid", vo.getCustomerSid()));
|
||||||
vo.setRemarks("已减免附加额");
|
vo.setRemarks("已减免附加额");
|
||||||
if(weight<=99){
|
if (weight <= 99) {
|
||||||
if(weight<20){
|
if (weight < 20) {
|
||||||
vo.setRemarks("不足20斤");
|
vo.setRemarks("不足20斤");
|
||||||
}else{
|
} else {
|
||||||
double a =1.1;
|
double a = 1.1;
|
||||||
double d=Double.valueOf(vo.getTotalPrice());
|
double d = Double.valueOf(vo.getTotalPrice());
|
||||||
double t=Double.valueOf(vo.getTotalPrice())*a;
|
double t = Double.valueOf(vo.getTotalPrice()) * a;
|
||||||
BigDecimal bg = new BigDecimal(t);
|
BigDecimal bg = new BigDecimal(t);
|
||||||
vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
||||||
// String c =String.valueOf(Double.valueOf(vo.getTotalPrice())-d);
|
// String c =String.valueOf(Double.valueOf(vo.getTotalPrice())-d);
|
||||||
double f=Double.valueOf(vo.getTotalPrice())-d;
|
double f = Double.valueOf(vo.getTotalPrice()) - d;
|
||||||
BigDecimal bgd = new BigDecimal(f);
|
BigDecimal bgd = new BigDecimal(f);
|
||||||
String c =String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
String c = String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||||
vo.setRemarks("含附加额"+removeZeros(c)+"元");
|
vo.setRemarks("含附加额" + removeZeros(c) + "元");
|
||||||
}
|
}
|
||||||
// if(weight==20){
|
// if(weight==20){
|
||||||
// if(lpkCustomer.getIsPurchase().equals("1")){
|
// if(lpkCustomer.getIsPurchase().equals("1")){
|
||||||
@@ -167,22 +194,24 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
|
|||||||
// vo.setRemarks("包含附加费"+removeZeros(c)+"元");
|
// vo.setRemarks("包含附加费"+removeZeros(c)+"元");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}else if(weight>=100 && weight<=199){
|
} else if (weight >= 100 && weight <= 199) {
|
||||||
double a =1.05;
|
double a = 1.05;
|
||||||
double d=Double.valueOf(vo.getTotalPrice());
|
double d = Double.valueOf(vo.getTotalPrice());
|
||||||
double t=Double.valueOf(vo.getTotalPrice())*a;
|
double t = Double.valueOf(vo.getTotalPrice()) * a;
|
||||||
BigDecimal bg = new BigDecimal(t);
|
BigDecimal bg = new BigDecimal(t);
|
||||||
vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
||||||
// String c =String.valueOf(Double.valueOf(vo.getTotalPrice())-d);
|
// String c =String.valueOf(Double.valueOf(vo.getTotalPrice())-d);
|
||||||
double f=Double.valueOf(vo.getTotalPrice())-d;
|
double f = Double.valueOf(vo.getTotalPrice()) - d;
|
||||||
BigDecimal bgd = new BigDecimal(f);
|
BigDecimal bgd = new BigDecimal(f);
|
||||||
String c =String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
String c = String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||||
vo.setRemarks("含附加额"+removeZeros(c)+"元");
|
vo.setRemarks("含附加额" + removeZeros(c) + "元");
|
||||||
}
|
}
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去除多余.0
|
* 去除多余.0
|
||||||
|
*
|
||||||
* @param num
|
* @param num
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user