@ -25,6 +25,9 @@ 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 com.yxt.yythmall.mallplus.biz.pms.service.IPmsBrandService ;
import com.yxt.yythmall.mallplus.biz.pms.service.impl.PmsBrandServiceImpl ;
import com.yxt.yythmall.mallplus.mbg.pms.entity.PmsBrand ;
import com.yxt.yythmall.utils.DoubleUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -46,6 +49,8 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
LpkCustomerService lpkCustomerService ;
@Autowired
private LpkGoodsService lpkGoodsService ;
@Autowired
PmsBrandServiceImpl pmsBrandService ;
public ResultBean save ( ShoppingCartDto dto ) {
ResultBean rb = ResultBean . fireFail ( ) ;
@ -110,6 +115,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
ResultBean rb = new ResultBean ( ) . fail ( ) ;
List < ShoppingCartVo > list = baseMapper . ShoppingCartList ( query . getCustomerSid ( ) , query . getBrandId ( ) ) ;
double price = 0 ;
double standbyPrice = 0 ;
double weight = 0 ;
for ( ShoppingCartVo vo : list ) {
LpkGoods lpkGoods = lpkGoodsService . fetchBySid ( vo . getGoodsSid ( ) ) ;
@ -124,9 +130,6 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
} else {
stepPrice = DoubleUtils . removeZeros ( String . valueOf ( Double . valueOf ( stepPrice ) * Double . valueOf ( vo . getWeight ( ) ) ) ) ; ///份价格
}
// if (new BigDecimal(stepPrice).compareTo(BigDecimal.ZERO) == 0) {
// stepPrice = vo.getJPrice();
// }
} else {
stepPrice = DoubleUtils . removeZeros ( String . valueOf ( Double . valueOf ( vo . getJPrice ( ) ) * Double . valueOf ( vo . getWeight ( ) ) ) ) ;
}
@ -135,25 +138,26 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
| | "玲珑黄白菜" . equals ( vo . getGoodsName ( ) )
| | "V7土豆" . equals ( vo . getGoodsName ( ) )
| | "黄金薯土豆" . equals ( vo . getGoodsName ( ) ) ) {
// BigDecimal weightW = new BigDecimal(vo.getWeight());
// if (weightW.compareTo(new BigDecimal(stepWeight)) == -1) {
price = Double . valueOf ( stepPrice ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + price ;
standbyPrice = Double . valueOf ( vo . getPrice ( ) ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + standbyPrice ;
weight = Double . valueOf ( vo . getWeight ( ) ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + weight ;
// }
} else {
price = Double . valueOf ( vo . getPrice ( ) ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + price ;
standbyPrice = Double . valueOf ( vo . getPrice ( ) ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + standbyPrice ;
weight = Double . valueOf ( vo . getWeight ( ) ) * Double . valueOf ( vo . getGoodsNumber ( ) ) + weight ;
}
}
ShoppingCartVo vo = new ShoppingCartVo ( ) ;
// vo.setText("1.20斤起订量。\n" +
// "2.新用户正好20斤5折。\n" +
// "3.20-100斤加10%附加额。\n" +
// "4.101斤-200斤加5%附加额。");
// 1.20斤起订量。
// 2.0-99斤加10%附加额。
// 3.100斤-199斤加5%附加额。
vo . setCustomerSid ( query . getCustomerSid ( ) ) ;
vo . setTotalPrice ( removeZeros ( String . valueOf ( aa ( price ) ) ) ) ;
vo . setStandbyPrice ( removeZeros ( String . valueOf ( aa ( standbyPrice ) ) ) ) ;
vo . setTotalWeight ( removeZeros ( String . valueOf ( aa ( weight ) ) ) ) ;
vo . setAffiliation ( query . getBrandId ( ) ) ;
vo = price ( vo ) ;
return rb . success ( ) . setData ( vo ) ;
}
@ -161,9 +165,23 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
private ShoppingCartVo price ( ShoppingCartVo vo ) {
double weight = Double . valueOf ( vo . getTotalWeight ( ) ) ;
LpkCustomer lpkCustomer = lpkCustomerService . getOne ( new QueryWrapper < LpkCustomer > ( ) . eq ( "sid" , vo . getCustomerSid ( ) ) ) ;
PmsBrand one = pmsBrandService . getOne ( new QueryWrapper < PmsBrand > ( ) . eq ( "id" , vo . getAffiliation ( ) ) ) ;
if ( vo . getAffiliation ( ) . equals ( "1001045" ) ) {
if ( weight < one . getQssl ( ) ) {
vo . setRemarks ( "不足" + one . getQssl ( ) + "斤" ) ;
} else {
String c = String . valueOf ( Double . valueOf ( vo . getStandbyPrice ( ) ) - Double . valueOf ( vo . getTotalPrice ( ) ) ) ;
if ( DoubleUtils . removeZeros ( c ) . equals ( "0" ) ) {
vo . setRemarks ( "" ) ;
} else {
vo . setRemarks ( "优惠" + removeZeros ( c ) + "元" ) ;
}
}
return vo ;
} ;
vo . setRemarks ( "已减免附加额" ) ;
if ( weight < = 99 ) {
if ( weight < 20 ) {
if ( weight < one . getQssl ( ) ) {
double a = 1 . 1 ;
double d = Double . valueOf ( vo . getTotalPrice ( ) ) ;
double t = Double . valueOf ( vo . getTotalPrice ( ) ) * a ;
@ -173,7 +191,7 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
double f = Double . valueOf ( vo . getTotalPrice ( ) ) - d ;
BigDecimal bgd = new BigDecimal ( f ) ;
String c = String . valueOf ( bgd . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) . doubleValue ( ) ) ;
vo . setRemarks ( "不足20 斤" ) ;
vo . setRemarks ( "不足" + one . getQssl ( ) + " 斤" ) ;
} else {
double a = 1 . 1 ;
double d = Double . valueOf ( vo . getTotalPrice ( ) ) ;
@ -186,37 +204,6 @@ public class ShoppingCartService extends MybatisBaseService<ShoppingCartMapper,
String c = String . valueOf ( bgd . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) . doubleValue ( ) ) ;
vo . setRemarks ( "含附加额" + removeZeros ( c ) + "元" ) ;
}
// if(weight==20){
// if(lpkCustomer.getIsPurchase().equals("1")){
// double a =0.5;
// double t=Double.valueOf(vo.getTotalPrice())*a;
// BigDecimal bg = new BigDecimal(t);
// vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
// vo.setRemarks("已享受新人专享5折优惠");
// }else{
// double a =1.1;
// double d=Double.valueOf(vo.getTotalPrice());
// double t=Double.valueOf(vo.getTotalPrice())*a;
// BigDecimal bg = new BigDecimal(t);
// vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
// double f=Double.valueOf(vo.getTotalPrice())-d;
// BigDecimal bgd = new BigDecimal(f);
// String c =String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
// vo.setRemarks("包含附加费"+removeZeros(c)+"元");
// }
// }else{
// double a =1.1;
// double d=Double.valueOf(vo.getTotalPrice());
// double t=Double.valueOf(vo.getTotalPrice())*a;
// BigDecimal bg = new BigDecimal(t);
// vo.setTotalPrice(String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
//// String c =String.valueOf(Double.valueOf(vo.getTotalPrice())-d);
// double f=Double.valueOf(vo.getTotalPrice())-d;
// BigDecimal bgd = new BigDecimal(f);
// String c =String.valueOf(bgd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
// vo.setRemarks("包含附加费"+removeZeros(c)+"元");
// }
} else if ( weight > = 100 & & weight < = 199 ) {
double a = 1 . 05 ;
double d = Double . valueOf ( vo . getTotalPrice ( ) ) ;