edit
This commit is contained in:
@@ -2,12 +2,17 @@ package lingtao.net.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lingtao.net.Factory.PricingStrategy;
|
||||
import lingtao.net.Factory.PricingStrategyFactory;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.bean.Product;
|
||||
import lingtao.net.bean.SysDictSearchPro;
|
||||
import lingtao.net.bean.SysUser;
|
||||
import lingtao.net.service.PriceService;
|
||||
import lingtao.net.service.ProductService;
|
||||
import lingtao.net.service.QuoteLogService;
|
||||
import lingtao.net.vo.PricingListVo;
|
||||
import lingtao.net.vo.ProductVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -18,9 +23,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@RestController
|
||||
public class ProductController {
|
||||
@@ -31,6 +39,9 @@ public class ProductController {
|
||||
@Autowired
|
||||
private QuoteLogService quoteLogService;
|
||||
|
||||
@Autowired
|
||||
private PriceService priceService;
|
||||
|
||||
// 价格跳转页面
|
||||
@RequestMapping("/product/index")
|
||||
public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@@ -52,8 +63,6 @@ public class ProductController {
|
||||
|
||||
/**
|
||||
* 修改价格
|
||||
*
|
||||
* @param customerData
|
||||
*/
|
||||
@RequestMapping("/updatePriceById")
|
||||
public Msg updatePriceById(@RequestParam(value = "proId") int proId, @RequestParam(value = "field") String field,
|
||||
@@ -70,10 +79,10 @@ public class ProductController {
|
||||
@RequestMapping("/getThanSum")
|
||||
public Msg thanPrice(Product product, HttpServletRequest request) {
|
||||
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
|
||||
/*if (StringUtils.isEmpty(product.getWangwang().trim()) && user.getRole().contains("999")
|
||||
&& !user.getRole().contains("1049")) {
|
||||
return Msg.fail("请填写客户旺旺!");
|
||||
}*/
|
||||
/*if (StringUtils.isEmpty(product.getWangwang().trim()) && user.getRole().contains("999")
|
||||
&& !user.getRole().contains("1049")) {
|
||||
return Msg.fail("请填写客户旺旺!");
|
||||
}*/
|
||||
if ("帆布".equals(product.getProTypeValue())) {
|
||||
if ("套餐".equals(product.getStickerKind())) {
|
||||
product.setCount(1);
|
||||
@@ -113,9 +122,9 @@ public class ProductController {
|
||||
} else {
|
||||
if (product.getNumber() != null && product.getNumber() > 1) {
|
||||
// if ("专版打印".equals(product.getStickerKind()) || "少数量".equals(product.getCouponKind())) {
|
||||
if (request.getParameter("desType") != null && !"".equals(request.getParameter("desType"))) {
|
||||
product.setP(Integer.valueOf(request.getParameter("desType")));
|
||||
}
|
||||
if (request.getParameter("desType") != null && !"".equals(request.getParameter("desType"))) {
|
||||
product.setP(Integer.valueOf(request.getParameter("desType")));
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -127,19 +136,19 @@ public class ProductController {
|
||||
//银瑾单独报价
|
||||
if (user.getRole().indexOf("1010") > -1) {
|
||||
double otherPrice = 0;
|
||||
/*if("5".equals(product.getKind())) {
|
||||
for (Product list : proList) {
|
||||
list.setPrice(list.getPrice() + 30);
|
||||
}
|
||||
}else if("帆布".equals(product.getProTypeValue())) {
|
||||
for (Product list : proList) {
|
||||
otherPrice = Math.floor(list.getPrice() + 5);
|
||||
list.setPrice(otherPrice > 40 ? otherPrice : 40);
|
||||
if(product.getNumber() > 1) {
|
||||
list.setPrice(Math.floor(list.getPrice() + 2 * (product.getNumber()-1)));
|
||||
}
|
||||
}
|
||||
}else */
|
||||
/*if("5".equals(product.getKind())) {
|
||||
for (Product list : proList) {
|
||||
list.setPrice(list.getPrice() + 30);
|
||||
}
|
||||
}else if("帆布".equals(product.getProTypeValue())) {
|
||||
for (Product list : proList) {
|
||||
otherPrice = Math.floor(list.getPrice() + 5);
|
||||
list.setPrice(otherPrice > 40 ? otherPrice : 40);
|
||||
if(product.getNumber() > 1) {
|
||||
list.setPrice(Math.floor(list.getPrice() + 2 * (product.getNumber()-1)));
|
||||
}
|
||||
}
|
||||
}else */
|
||||
if ("22".equals(product.getProTypeValue())) {
|
||||
for (Product list : proList) {
|
||||
list.setPrice(list.getPrice() + 50);
|
||||
@@ -208,8 +217,8 @@ public class ProductController {
|
||||
if (StringUtils.isEmpty(product.getAotu())) {
|
||||
return Msg.fail("哑金不干胶该尺寸无法制作,最大做到 39*27 cm");
|
||||
} /*else {
|
||||
return Msg.fail("哑金不干胶带凹凸工艺该尺寸无法制作 (1*1CM至11*11CM;10*6至12*8CM;20*4以内)");
|
||||
}*/
|
||||
return Msg.fail("哑金不干胶带凹凸工艺该尺寸无法制作 (1*1CM至11*11CM;10*6至12*8CM;20*4以内)");
|
||||
}*/
|
||||
} else if ("易碎纸不干胶".equals(product.getKindValue()) && proList == null) {
|
||||
return Msg.fail("易碎纸不干胶该尺寸无法制作,最大做到 42*38 cm");
|
||||
} else if (("拉丝金".equals(product.getKindValue()) || "拉丝银".equals(product.getKindValue()))
|
||||
@@ -248,115 +257,175 @@ public class ProductController {
|
||||
}
|
||||
|
||||
if (product.getKindValue() != null) {//判断是否大店报不干胶价格
|
||||
/*if(product.getKindValue().equals("0")) {
|
||||
double width = 0, length = 0;
|
||||
if(product.getWidth() != null) {
|
||||
width = product.getWidth();
|
||||
}
|
||||
if(product.getLength() != null) {
|
||||
length = product.getLength();
|
||||
}
|
||||
String role = user.getRole();
|
||||
if(length < width) {
|
||||
length = product.getWidth();
|
||||
width = product.getLength();
|
||||
}
|
||||
if(width == 0 && length == 0) {
|
||||
}else if((length <= 5 && width <= 4)) {
|
||||
String tang = product.getCraftTang();
|
||||
if(AStickersPrice.f_getRole(role) == 1 && tang == null) {
|
||||
List<Product> price = new ArrayList<Product>();
|
||||
if(length == 1 && width == 1) {
|
||||
int priceArr[] = {30, 35, 50, 55, 65, 90, 135, 185, 235, 285};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 2 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 60, 70, 95, 140, 190, 240, 290};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 2 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 4) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 4) {
|
||||
int priceArr[] = {35, 40, 55, 70, 150, 240, 420, 600, 790, 980};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}
|
||||
|
||||
if (proList.size() >= 4) {
|
||||
proList = proList.subList(0, 4);
|
||||
}
|
||||
|
||||
for(int i = 0; i < price.size(); i ++){
|
||||
if(product.getNumber() > 1) {
|
||||
proList.get(i).setPrice(price.get(i).getPrice() * product.getNumber());
|
||||
}else {
|
||||
proList.get(i).setPrice(price.get(i).getPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(user.getRole().indexOf("1033") > 0 && product.getProTypeValue().equals("17")) {
|
||||
if(product.getKindValue().equals("6")) {
|
||||
for (Product products : proList) {
|
||||
products.setPrice(Math.floor(products.getPrice() * 0.88));
|
||||
}
|
||||
}
|
||||
} */
|
||||
/*if(product.getKindValue().equals("0")) {
|
||||
double width = 0, length = 0;
|
||||
if(product.getWidth() != null) {
|
||||
width = product.getWidth();
|
||||
}
|
||||
if(product.getLength() != null) {
|
||||
length = product.getLength();
|
||||
}
|
||||
String role = user.getRole();
|
||||
if(length < width) {
|
||||
length = product.getWidth();
|
||||
width = product.getLength();
|
||||
}
|
||||
if(width == 0 && length == 0) {
|
||||
}else if((length <= 5 && width <= 4)) {
|
||||
String tang = product.getCraftTang();
|
||||
if(AStickersPrice.f_getRole(role) == 1 && tang == null) {
|
||||
List<Product> price = new ArrayList<Product>();
|
||||
if(length == 1 && width == 1) {
|
||||
int priceArr[] = {30, 35, 50, 55, 65, 90, 135, 185, 235, 285};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 2 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 60, 70, 95, 140, 190, 240, 290};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 1) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 2 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 2) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 3 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 3) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 4 && width == 4) {
|
||||
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}else if(length == 5 && width == 4) {
|
||||
int priceArr[] = {35, 40, 55, 70, 150, 240, 420, 600, 790, 980};
|
||||
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
|
||||
}
|
||||
|
||||
if (proList.size() >= 4) {
|
||||
proList = proList.subList(0, 4);
|
||||
}
|
||||
|
||||
for(int i = 0; i < price.size(); i ++){
|
||||
if(product.getNumber() > 1) {
|
||||
proList.get(i).setPrice(price.get(i).getPrice() * product.getNumber());
|
||||
}else {
|
||||
proList.get(i).setPrice(price.get(i).getPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(user.getRole().indexOf("1033") > 0 && product.getProTypeValue().equals("17")) {
|
||||
if(product.getKindValue().equals("6")) {
|
||||
for (Product products : proList) {
|
||||
products.setPrice(Math.floor(products.getPrice() * 0.88));
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
return Msg.success().add("proList", proList);
|
||||
}
|
||||
|
||||
/*public List<Product> f_getPrice( int priceArr[], int count, String craftMo) {
|
||||
List<Product> list = new ArrayList<Product>();
|
||||
Product p = new Product();
|
||||
int countArr[] = { 500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000 };
|
||||
for(int i = 0; i < countArr.length; i++) {
|
||||
if(countArr[i] < count || list.size() > 3) {
|
||||
continue;
|
||||
}
|
||||
p = new Product();
|
||||
p.setCount(countArr[i]);
|
||||
if(craftMo.equals("覆哑膜")) {
|
||||
p.setPrice(Math.ceil(Double.valueOf(priceArr[i]) * 1.2));
|
||||
}else {
|
||||
p.setPrice(Double.valueOf(priceArr[i]));
|
||||
}
|
||||
|
||||
list.add(p);
|
||||
}
|
||||
|
||||
return list;
|
||||
}*/
|
||||
|
||||
@RequestMapping("/getProductPrice")
|
||||
public Msg getProductPrice(Product product, HttpServletRequest request) {
|
||||
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
|
||||
|
||||
|
||||
if (StringUtils.isEmpty(product.getCount()) || product.getCount() <= 0) {
|
||||
return Msg.fail("数量必须大于0");
|
||||
}
|
||||
String size = product.getSize();
|
||||
|
||||
if (("17".equals(product.getProTypeValue()) && "6".equals(product.getKindValue())) || "手拉旗".equals(product.getProTypeValue())) {
|
||||
if (!StringUtils.isEmpty(size)) {
|
||||
String sizeList[] = size.split(",");
|
||||
size = sizeList[0];
|
||||
}
|
||||
product.setLength(Double.valueOf(size));
|
||||
} else if (!StringUtils.isEmpty(size)) {
|
||||
product.setLength(Double.valueOf(size.substring(0, size.indexOf("*"))));
|
||||
String other_size = size;
|
||||
if (size.contains(",")) {
|
||||
size = size.split(",")[0];
|
||||
}
|
||||
if (size.indexOf(("*"), size.indexOf("*") + 1) == -1) {
|
||||
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1)));
|
||||
} else {
|
||||
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1, size.indexOf(("*"), size.indexOf("*") + 1))));
|
||||
product.setLength(Math.abs(Double.parseDouble(size.substring(size.indexOf(("*"), size.indexOf("*") + 1) + 1))));
|
||||
}
|
||||
}
|
||||
product.setRole(user.getRole());
|
||||
PricingStrategy pricingStrategy = PricingStrategyFactory.getStrategy(product.getProTypeValue());
|
||||
PricingListVo listvo = pricingStrategy.calculatePrice(product, user.getRole());
|
||||
if (listvo.getCode() != 0) {
|
||||
return Msg.fail(listvo.getMsg());
|
||||
}
|
||||
List<ProductVo> proList = listvo.getProList();
|
||||
if (proList == null || proList.size() == 0 || proList.get(0).getPrice() == 0) {
|
||||
return Msg.fail("暂无报价");
|
||||
}
|
||||
PricingListVo result = priceService.getAddressPrice(product, proList);
|
||||
|
||||
if (result.getCode() != 0) {
|
||||
return Msg.fail(result.getMsg());
|
||||
}
|
||||
proList = result.getProList();
|
||||
|
||||
String log = quoteLogService.log(product, request, new ArrayList<>());
|
||||
|
||||
if ("登陆失效".equals(log)) {
|
||||
return Msg.fail("登录信息失效~请刷新页面!");
|
||||
}
|
||||
|
||||
// 把角色存入,前台判断,区分不同价格
|
||||
for (ProductVo p : proList) {
|
||||
p.setRole(user.getRole());
|
||||
}
|
||||
|
||||
return Msg.success().add("proList", proList);
|
||||
}
|
||||
|
||||
/*public List<Product> f_getPrice( int priceArr[], int count, String craftMo) {
|
||||
List<Product> list = new ArrayList<Product>();
|
||||
Product p = new Product();
|
||||
int countArr[] = { 500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000 };
|
||||
for(int i = 0; i < countArr.length; i++) {
|
||||
if(countArr[i] < count || list.size() > 3) {
|
||||
continue;
|
||||
}
|
||||
p = new Product();
|
||||
p.setCount(countArr[i]);
|
||||
if(craftMo.equals("覆哑膜")) {
|
||||
p.setPrice(Math.ceil(Double.valueOf(priceArr[i]) * 1.2));
|
||||
}else {
|
||||
p.setPrice(Double.valueOf(priceArr[i]));
|
||||
}
|
||||
|
||||
list.add(p);
|
||||
}
|
||||
|
||||
return list;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 根据产品种类获取材质
|
||||
|
||||
Reference in New Issue
Block a user