|
|
@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description: 产品报价表 |
|
|
@ -80,7 +81,7 @@ public class ProductServiceImpl extends ServiceImpl<TbProductMapper, TbProduct> |
|
|
|
product.setUserId(hanHaiMember.getId()); |
|
|
|
product.setCompanyName(one1.getCompanyName()); |
|
|
|
product.setAuditStatus(0); |
|
|
|
product.setAddress(byId.getAddress()+byId.getAddressDetail()); |
|
|
|
product.setAddress(byId.getAddress() + byId.getAddressDetail()); |
|
|
|
product.setShowStatus(2); |
|
|
|
//默认图片 |
|
|
|
product.setProductType(2); |
|
|
@ -89,6 +90,43 @@ public class ProductServiceImpl extends ServiceImpl<TbProductMapper, TbProduct> |
|
|
|
return Result.OK("添加成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Result updateProduct(ProductReq productReq, String token) { |
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
|
LambdaQueryWrapper<TbUserRole> objectLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
objectLambdaQueryWrapper.eq(TbUserRole::getUserId, hanHaiMember.getId()). |
|
|
|
eq(TbUserRole::getRole, 1).eq(TbUserRole::getAuditStatus, 1); |
|
|
|
TbUserRole one1 = tbUserRoleService.getOne(objectLambdaQueryWrapper); |
|
|
|
if (ValidateTool.isNull(one1)) { |
|
|
|
return Result.error("身份审核未通过"); |
|
|
|
} |
|
|
|
TbAddress byId = addressService.getById(productReq.getAddressId()); |
|
|
|
if (ValidateTool.isNull(byId)) { |
|
|
|
return Result.error("请选择地址"); |
|
|
|
} |
|
|
|
// Object productPic = redisUtil.get("productPic"); |
|
|
|
TbSpecs specs = tbSpecsService.getById(productReq.getSpecsId()); |
|
|
|
if (ValidateTool.isNull(specs)) { |
|
|
|
return Result.error("请选择规格"); |
|
|
|
} |
|
|
|
TbProduct product1 = tbProductMapper.selectById(productReq.getId()); |
|
|
|
if (ValidateTool.isNull(product1)){ |
|
|
|
return Result.error("参数错误,报价ID不正确"); |
|
|
|
} |
|
|
|
TbProduct product = new TbProduct(); |
|
|
|
BeanUtils.copyProperties(productReq, product); |
|
|
|
product.setUserId(hanHaiMember.getId()); |
|
|
|
product.setId(productReq.getId()); |
|
|
|
product.setCompanyName(one1.getCompanyName()); |
|
|
|
product.setAuditStatus(0); |
|
|
|
product.setAddress(byId.getAddress() + byId.getAddressDetail()); |
|
|
|
product.setShowStatus(2); |
|
|
|
//默认图片 |
|
|
|
product.setSpecsName(specs.getSpecsName()); |
|
|
|
tbProductService.updateById(product); |
|
|
|
return Result.OK("修改成功!"); } |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Result addProductOrder(ProductOrderReq productReq, String token) { |
|
|
@ -102,6 +140,12 @@ public class ProductServiceImpl extends ServiceImpl<TbProductMapper, TbProduct> |
|
|
|
if (product.getAuditStatus() != 1 || product.getShowStatus() != 0) { |
|
|
|
return Result.error("订单状态异常,请刷新"); |
|
|
|
} |
|
|
|
QueryWrapper<TbProductOrder> orderQueryWrapper = new QueryWrapper<>(); |
|
|
|
orderQueryWrapper.eq("buy_userId", hanHaiMember.getId()).eq("product_id", productReq.getProductId()).eq("audit_status", 0).eq("del_flag", 0); |
|
|
|
List<TbProductOrder> list = tbProductOrderService.list(orderQueryWrapper); |
|
|
|
if (list.size() > 0) { |
|
|
|
return Result.error("有订单未审核通过,不可重复下单"); |
|
|
|
} |
|
|
|
QueryWrapper<TbUserRole> objectQueryWrapper = new QueryWrapper<>(); |
|
|
|
objectQueryWrapper.eq("user_id", hanHaiMember.getId()).eq("role", 0); |
|
|
|
TbUserRole one2 = tbUserRoleService.getOne(objectQueryWrapper); |
|
|
@ -153,6 +197,9 @@ public class ProductServiceImpl extends ServiceImpl<TbProductMapper, TbProduct> |
|
|
|
@Override |
|
|
|
public Result updateOrder(UpdateOrderReq updateOrderReq, String token) { |
|
|
|
TbProductOrder order = tbProductOrderService.getById(updateOrderReq.getOrderId()); |
|
|
|
if (order.getAuditStatus() == 1) { |
|
|
|
return Result.error("订单已审核通过,不可修改"); |
|
|
|
} |
|
|
|
if (ValidateTool.isNull(order)) { |
|
|
|
return Result.error("订单信息错误"); |
|
|
|
} |
|
|
|