'提交代码'

dev-discount
胡锐 4 years ago
parent cee34088e1
commit ace727f752
  1. 13
      hai-bweb/src/main/java/com/bweb/controller/BsCompanyController.java
  2. 80
      hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java
  3. 110
      hai-bweb/src/main/java/com/bweb/model/AddGoodsPriceModel.java
  4. 3
      hai-service/src/main/java/com/hai/common/exception/ErrorCode.java
  5. 2
      hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java

@ -101,13 +101,18 @@ public class BsCompanyController {
}
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
if(sessionObject == null){
log.error("SecCompanyController --> updateCompany() error!", "");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
}
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
// 校验该区域是否存在公司
if (bsCompanyService.selectCompanyByRegion(secCompanyModel.getCompany().getRegionId()) != null) {
log.error("BsCompanyController --> addCompanyAndUser() error!", "该区域分公司已存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "");
}
// 校验公司名称
BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName());
if (secCompany != null) {
@ -193,6 +198,12 @@ public class BsCompanyController {
}
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
// 校验该区域是否存在公司
if (bsCompanyService.selectCompanyByRegion(secCompanyModel.getCompany().getRegionId()) != null) {
log.error("BsCompanyController --> addCompanyAndUser() error!", "该区域分公司已存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "");
}
// 校验公司名称
BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName());
if (secCompany != null && !secCompany.getId().equals(company.getId())) {

@ -1,5 +1,6 @@
package com.bweb.controller;
import com.bweb.model.AddGoodsPriceModel;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -27,9 +28,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
/**
* @Auther: 胡锐
@ -55,58 +55,84 @@ public class HighGoodsPriceReferController {
@RequestMapping(value="/insertGoodsPriceRefer",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加产品销售价格")
public ResponseData insertGoodsPriceRefer(@RequestBody HighGoodsPriceRefer highGoodsPriceRefer, HttpServletRequest request) {
public ResponseData insertGoodsPriceRefer(@RequestBody AddGoodsPriceModel addGoodsPriceModel, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (highGoodsPriceRefer.getObjectType() == null
|| highGoodsPriceRefer.getObjectId() == null
|| highGoodsPriceRefer.getPriceType() == null
|| highGoodsPriceRefer.getNewSalePrice() == null
|| highGoodsPriceRefer.getPromptlyType() == null
if (addGoodsPriceModel.getObjectType() == null
|| addGoodsPriceModel.getPriceType() == null
|| addGoodsPriceModel.getPromptlyType() == null
|| addGoodsPriceModel.getObjectIdList() == null
|| addGoodsPriceModel.getObjectIdList().size() == 0
) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 是否及时生效 否:需要填写生效时间
if (highGoodsPriceRefer.getPromptlyType() == false && highGoodsPriceRefer.getEffectiveTime() == null) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// 价格类型 1:原价 2:折扣
// 原价需要填写新价格
if (addGoodsPriceModel.getPriceType() == 1 && addGoodsPriceModel.getNewSalePrice() == null) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","请填写正确的新销售价格");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NEED_WRITE_NEW_SALE_PRICE, "");
}
// 折扣需要填写折扣数(几折)
if (addGoodsPriceModel.getPriceType() == 2
&& addGoodsPriceModel.getDiscountNum() == null
&& addGoodsPriceModel.getDiscountNum().compareTo(new BigDecimal("0")) == - 1
&& addGoodsPriceModel.getDiscountNum().compareTo(new BigDecimal("10")) == 1) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","请填写正确的折扣数,折扣数范围【0】 ~ 【10】");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NEED_WRITE_DISCOUNT_PRICE, "");
}
// 失效时间 大于 生效时间
if (highGoodsPriceRefer.getInvalidTime() != null
&& highGoodsPriceRefer.getEffectiveTime() != null
&& highGoodsPriceRefer.getInvalidTime().after(highGoodsPriceRefer.getEffectiveTime())) {
if (addGoodsPriceModel.getInvalidTime() != null
&& addGoodsPriceModel.getEffectiveTime() != null
&& addGoodsPriceModel.getInvalidTime().after(addGoodsPriceModel.getEffectiveTime())) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","失效时间不能大于生效时间");
throw ErrorHelp.genException(SysCode.System, ErrorCode.INVALID_TIME_BIG_EFFECTIVE_TIME_ERROR, "");
}
HighGoodsPriceRefer highGoodsPriceRefer;
List<HighGoodsPriceRefer> list = new ArrayList<>();
for (Long objectId : addGoodsPriceModel.getObjectIdList()) {
highGoodsPriceRefer = new HighGoodsPriceRefer();
// 卡卷
if (addGoodsPriceModel.getObjectType() == 1) {
HighCouponModel coupon = highCouponService.getCouponById(objectId);
if (coupon == null) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 是否满足增加条件
if (highGoodsPriceReferService.isAddCondition(highGoodsPriceRefer.getObjectType(),highGoodsPriceRefer.getObjectId(),highGoodsPriceRefer.getPriceType()) == false) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","暂时无法增加,有处于在待编辑、待生效、审批中的价格");
if (highGoodsPriceReferService.isAddCondition(addGoodsPriceModel.getObjectType(),coupon.getId(),addGoodsPriceModel.getPriceType()) == false) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!", "【" + coupon.getCouponName() + "】,暂时无法增加,有处于在待编辑、待生效、审批中的价格");
throw ErrorHelp.genException(SysCode.System, ErrorCode.PRICE_REFER_STATUS_ERROR, "");
}
// 获取旧价格 类型 1.卡卷
if (highGoodsPriceRefer.getObjectType() == 1) {
HighCouponModel coupon = highCouponService.getCouponById(highGoodsPriceRefer.getId());
if (coupon != null && highGoodsPriceRefer.getPriceType() == 1) {
// 价格类型 1:原价 2:折扣
// 获取旧价格
if (addGoodsPriceModel.getPriceType() == 1) {
highGoodsPriceRefer.setOldSalePrice(coupon.getSalesPrice());
highGoodsPriceRefer.setNewSalePrice(addGoodsPriceModel.getNewSalePrice());
}
if (coupon != null && highGoodsPriceRefer.getPriceType() == 2) {
if (addGoodsPriceModel.getPriceType() == 2) {
highGoodsPriceRefer.setOldSalePrice(coupon.getDiscountPrice());
// 卡卷原价 * (折扣 ÷ 10)
BigDecimal newSalePrice = coupon.getSalesPrice().multiply(new BigDecimal(addGoodsPriceModel.getDiscountNum().toString()).divide(new BigDecimal("10")));
highGoodsPriceRefer.setNewSalePrice(newSalePrice);
}
}
highGoodsPriceRefer.setCreateTime(new Date());
highGoodsPriceRefer.setStatus(101); // 状态: 0:删除 1:待编辑 2:待生效 3:已生效 4:已失效 101.审批中 102.审批驳回
highGoodsPriceRefer.setOperatorId(userInfoModel.getSecUser().getId());
highGoodsPriceRefer.setOperatorName(userInfoModel.getSecUser().getUserName());
list.add(highGoodsPriceRefer);
}
highGoodsPriceReferService.submitApprove(highGoodsPriceRefer);
}
highGoodsPriceReferService.submitApprove(null);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {

@ -0,0 +1,110 @@
package com.bweb.model;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 增加产品价格
*/
public class AddGoodsPriceModel {
// 类型 1.卡卷
private Integer objectType;
// 价格类型 1:原价 2:折扣
private Integer priceType;
// 折扣数(几折)
private BigDecimal discountNum;
// 及时生效 0:否 1:是
private Boolean promptlyType;
// 新销售价格
private BigDecimal newSalePrice;
// 产品id
private List<Long> objectIdList;
// 新销售价格 生效时间
private Date effectiveTime;
// 新销售价格 失效时间
private Date invalidTime;
// 备注
private String remark;
public Integer getObjectType() {
return objectType;
}
public void setObjectType(Integer objectType) {
this.objectType = objectType;
}
public Integer getPriceType() {
return priceType;
}
public void setPriceType(Integer priceType) {
this.priceType = priceType;
}
public BigDecimal getDiscountNum() {
return discountNum;
}
public void setDiscountNum(BigDecimal discountNum) {
this.discountNum = discountNum;
}
public Boolean getPromptlyType() {
return promptlyType;
}
public void setPromptlyType(Boolean promptlyType) {
this.promptlyType = promptlyType;
}
public BigDecimal getNewSalePrice() {
return newSalePrice;
}
public void setNewSalePrice(BigDecimal newSalePrice) {
this.newSalePrice = newSalePrice;
}
public List<Long> getObjectIdList() {
return objectIdList;
}
public void setObjectIdList(List<Long> objectIdList) {
this.objectIdList = objectIdList;
}
public Date getEffectiveTime() {
return effectiveTime;
}
public void setEffectiveTime(Date effectiveTime) {
this.effectiveTime = effectiveTime;
}
public Date getInvalidTime() {
return invalidTime;
}
public void setInvalidTime(Date invalidTime) {
this.invalidTime = invalidTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

@ -92,6 +92,9 @@ public enum ErrorCode {
DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR("2120","折扣价格不能大于原价"),
INVALID_TIME_BIG_EFFECTIVE_TIME_ERROR("2121","失效时间不能大于生效时间"),
PRICE_REFER_STATUS_ERROR("2122","暂时无法增加,有处于在待编辑、待生效、审批中的价格"),
NEED_WRITE_NEW_SALE_PRICE("2123","请填写正确的新销售价格"),
NEED_WRITE_DISCOUNT_PRICE("2124","请填写正确的折扣数,折扣数范围【0】 ~ 【10】"),
DISCOUNT_PRICE_RANGE("2125","请输入正确的"),
STATUS_ERROR("3000","状态错误"),
ADD_DATA_ERROR("3001","增加数据失败"),

@ -50,7 +50,6 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic
public void submitApprove(HighGoodsPriceRefer highGoodsPriceRefer) throws Exception {
insertPriceRefer(highGoodsPriceRefer);
HighApprove approve = new HighApprove();
approve.setObjectType(ApproveType.UP_SHELF_APPROVE.getType());
approve.setObjectId(highGoodsPriceRefer.getId());
@ -64,6 +63,7 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic
highApproveService.insertApprove(approve);
}
@Override
public HighGoodsPriceRefer getPriceReferById(Long id) {
return highGoodsPriceReferMapper.selectByPrimaryKey(id);

Loading…
Cancel
Save