Commit 049bcd39 authored by hezhen's avatar hezhen

修改商品模块

parent 774183d3
......@@ -8,6 +8,7 @@ import org.springframework.beans.FatalBeanException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
public abstract class BeanUtils extends org.springframework.beans.BeanUtils {
......@@ -37,9 +38,17 @@ public abstract class BeanUtils extends org.springframework.beans.BeanUtils {
readMethod1.setAccessible(true);
}
Object targetValue = readMethod1.invoke(target);
if (value != null && targetValue != null && value.equals(targetValue) ){
if (value != null && targetValue != null ){
if (targetValue instanceof BigDecimal && value instanceof BigDecimal){
BigDecimal a1 = (BigDecimal) targetValue;
BigDecimal a2 = (BigDecimal) value;
if (a1.compareTo(a2) == 0){
writeMethod.invoke(target, (String)null);
}
}else if ( value.equals(targetValue)){
writeMethod.invoke(target, (String)null);
}
}
}
} catch (Throwable ex) {
......
package com.xxfc.platform.vehicle.entity;
import com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.List;
@Data
@Table(name = "vehicle_apply")
......@@ -160,6 +163,10 @@ public class VehicleApply {
@ApiModelProperty("是否删除:0-正常;1-删除")
private Integer isDel;
@Transient
@ApiModelProperty("扩展信息list")
private List<VehicleExtensionVO> extensionVOS;
......
......@@ -18,6 +18,10 @@ import java.util.List;
public class VehicleFindDTO extends PageParam implements DataInter {
@ApiModelProperty("商品Id")
private String vehicleId;
@ApiModelProperty("商品名称")
private String name;
......
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.VehicleExtension;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class VehicleExtensionVO extends VehicleExtension {
@ApiModelProperty("父扩展名称")
private String parentCataName;
@ApiModelProperty("扩展名称")
private String cataName;
public List<VehicleExtensionVO> children;
}
\ No newline at end of file
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleApply;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -22,4 +23,8 @@ public class VehicleVO extends Vehicle {
@ApiModelProperty("店铺名称")
private String companyName;
private VehicleApply vehicleApply;
private List<VehicleExtensionVO> extensionVOS;
}
\ No newline at end of file
......@@ -20,7 +20,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
......@@ -46,25 +49,21 @@ public class VehicleApplyBiz extends BaseBiz<VehicleApplyMapper, VehicleApply>{
if (list.size() > 0){
throw new BaseException("公司名称不能重复",ResultCode.FAILED_CODE);
}
Vehicle vehicle1=null;
VehicleApply vehicleApply=new VehicleApply();
BeanUtils.copyProperties(vehicle,vehicleApply);
Integer formType=2;
String detailJson=null;
String detailJson;
if (StringUtils.isNotBlank(vehicleId)){
if (checkStatus(vehicleId) > 0L){
throw new BaseException("已存在待审核记录",ResultCode.FAILED_CODE);
}
vehicle1=vehicleBiz.selectById(vehicleId);
Vehicle vehicle2=vehicle;
BeanUtils.copyPropertiesTargetIsEquals(vehicle1,vehicle2);
detailJson= JSONObject.toJSONString(vehicle2);
Vehicle vehicle1=vehicleBiz.selectById(vehicleId);
BeanUtils.copyPropertiesTargetIsEquals(vehicle1,vehicle);
detailJson= JSONObject.toJSONString(vehicle);
}else {
formType=1;
detailJson= JSONObject.toJSONString(vehicle);
}
VehicleApply vehicleApply=new VehicleApply();
BeanUtils.copyProperties(vehicle,vehicleApply);
vehicleApply.setChangeJson(detailJson);
vehicleApply.setFormType(formType);
vehicleApply.setVehicleId(vehicleId);
......
......@@ -103,6 +103,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Autowired
private ThirdFeign thirdFeign;
@Autowired
VehicleApplyBiz vehicleApplyBiz;
@Autowired
VehicleExtensionBiz extensionBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -1617,5 +1624,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return ObjectRestResponse.succ(PageDataVO.pageInfo(pageInfo));
}
public VehicleVO info(VehicleFindDTO vehicleFindDTO){
List<VehicleVO> vehicleVOS=getList(vehicleFindDTO);
if (vehicleVOS != null && vehicleVOS.size() > 0){
VehicleVO vehicleVO=vehicleVOS.get(0);
vehicleVO.setVehicleApply(vehicleApplyBiz.getVehicleInfo(vehicleFindDTO.getVehicleId()));
return vehicleVO;
}
return null;
}
}
package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.BeanUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleApply;
import com.xxfc.platform.vehicle.entity.VehicleExtension;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import com.xxfc.platform.vehicle.mapper.VehicleApplyMapper;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;;
import com.xxfc.platform.vehicle.mapper.VehicleEextensionMapper;
import com.xxfc.platform.vehicle.pojo.dto.VehicleApplyFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleApplyVo;
import com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -70,9 +60,42 @@ public class VehicleExtensionBiz extends BaseBiz<VehicleEextensionMapper, Vehicl
}
}
mapper.delByIds(ids,vehicleId);
}
public List<VehicleExtensionVO> selectList(String vehicleId){
return mapper.selectList(vehicleId);
}
public List<VehicleExtensionVO> selectListByApply(List<Integer> cataIds){
return mapper.selectListByApply(cataIds);
}
public List<VehicleExtensionVO> getTree(String vehicleId){
List<VehicleExtensionVO> vehicleExtensionVOS = mapper.selectListByParent(vehicleId);
if (vehicleExtensionVOS.size() > 0){
for (VehicleExtensionVO extensionVO:vehicleExtensionVOS) {
extensionVO.setChildren(selectList(vehicleId));
}
}
return vehicleExtensionVOS;
}
public List<VehicleExtensionVO> getTreeByApply(List<Integer> cataIds){
List<VehicleExtensionVO> vehicleExtensionVOS = mapper.selectListByApplyParent(cataIds);
if (vehicleExtensionVOS.size() > 0){
for (VehicleExtensionVO extensionVO:vehicleExtensionVOS) {
extensionVO.setChildren(selectListByApply(cataIds));
}
}
return vehicleExtensionVOS;
}
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehicleExtension;
import com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;
......@@ -14,4 +15,13 @@ public interface VehicleEextensionMapper extends Mapper<VehicleExtension>, Selec
void delByIds(@Param("ids") List<Integer> ids,@Param("vehicleId")String vehicleId);
List<VehicleExtensionVO> selectList(@Param("vehicleId")String vehicleId);
List<VehicleExtensionVO> selectListByApply(@Param("cataIds")List<Integer> cataIds);
List<VehicleExtensionVO> selectListByParent(@Param("vehicleId")String vehicleId);
List<VehicleExtensionVO> selectListByApplyParent(@Param("cataIds")List<Integer> cataIds);
}
\ No newline at end of file
......@@ -40,4 +40,10 @@ public class AppVehicleApplyController extends BaseController<VehicleApplyBiz> {
}
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleApplyBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("app/vehicle")
@Api(tags = {"商家入驻"})
public class AppVehicleController extends BaseController<VehicleBiz> {
@GetMapping("selectList")
@ApiModelProperty("商品列表")
public ObjectRestResponse selectList(VehicleFindDTO vehicleFindDTO) {
if (vehicleFindDTO.getBranchId() == null || vehicleFindDTO.getBranchId() == 0){
List<Integer> companyIds = getCompanyIds();
if (companyIds != null && companyIds.size() > 0){
vehicleFindDTO.setBranchId(companyIds.get(0));
}
}
return baseBiz.selectList(vehicleFindDTO);
}
@PostMapping("updVehicle")
@ApiModelProperty("更新商品信息")
public ObjectRestResponse updVehicle(@RequestBody Vehicle vehicle) {
baseBiz.updateSelectiveById(vehicle);
return ObjectRestResponse.succ();
}
@GetMapping("info")
@ApiModelProperty("商品详情")
public ObjectRestResponse info(VehicleFindDTO vehicleFindDTO) {
return ObjectRestResponse.succ(baseBiz.info(vehicleFindDTO));
}
}
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleExtensionBiz;
import com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("app/vehicleEextension")
@Api(tags = {"商家入驻"})
public class AppVehicleExtensionController extends BaseController<VehicleExtensionBiz> {
@GetMapping("tree")
@ApiModelProperty("商品详情")
public ObjectRestResponse info(@RequestParam(value = "vehicleId",defaultValue = "")String vehicleId,@RequestParam(value = "extensionList",defaultValue = "")String extensionList) {
List<VehicleExtensionVO> list=null;
if (StringUtils.isNotBlank(vehicleId)){
list=baseBiz.getTree(vehicleId);
}else if (StringUtils.isNotBlank(extensionList)){
list=baseBiz.getTreeByApply(Arrays.asList(extensionList.split(",")).parallelStream().map(s -> Integer.valueOf(s)).collect(Collectors.toList()));
}
return ObjectRestResponse.succ(list);
}
}
......@@ -28,9 +28,11 @@ import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.jobhandler.VehicleJobHandler;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
......@@ -682,6 +684,16 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
}
}
@GetMapping("app/unauth/selectList")
@ApiModelProperty("全网最低价")
@IgnoreUserToken
public ObjectRestResponse selectList(VehicleFindDTO vehicleFindDTO) {
vehicleFindDTO.setState(1);
vehicleFindDTO.setIsMinPrice(1);
return baseBiz.selectList(vehicleFindDTO);
}
@Data
static public class VehicleVO extends Vehicle {
private VehicleModel vehicleModel;
......
......@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import com.xxfc.platform.vehicle.rest.BaseController;
import io.swagger.annotations.Api;
......@@ -53,6 +54,30 @@ public class AdminVehicleController extends BaseController<VehicleBiz> implement
@PostMapping("updVehicle")
@ApiModelProperty("更新商品信息")
public ObjectRestResponse updVehicle(@RequestBody Vehicle vehicle) {
baseBiz.updateSelectiveById(vehicle);
return ObjectRestResponse.succ();
}
@PostMapping("delVehicle")
@ApiModelProperty("更新商品信息")
public ObjectRestResponse delVehicle(@RequestBody Vehicle vehicle) {
vehicle.setIsDel(1);
baseBiz.updateSelectiveById(vehicle);
return ObjectRestResponse.succ();
}
@GetMapping("info")
@ApiModelProperty("商品详情")
public ObjectRestResponse info(VehicleFindDTO vehicleFindDTO) {
return ObjectRestResponse.succ(baseBiz.info(vehicleFindDTO));
}
......
......@@ -15,4 +15,64 @@
</if>
</where>
</update>
<select id="selectList" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO">
SELECT
e.*,
c.`name` as parentCataName,
c1.`name` as cataName
FROM vehicle_extension e
LEFT JOIN vehicle_plat_cata c ON e.parent_cata_id=c.id
LEFT JOIN vehicle_plat_cata c1 ON e.cata_id=c1.id
<where>
e.is_del =0 and e.vehicle_id =#{vehicleId}
</where>
ORDER BY e.parent_cata_id
</select>
<select id="selectListByParent" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO">
SELECT
e.parent_cata_id as parentCataId,
c.`name` as parentCataName
FROM vehicle_extension e
LEFT JOIN vehicle_plat_cata c ON e.parent_cata_id=c.id
<where>
e.is_del =0 and e.vehicle_id =#{vehicleId}
</where>
GROUP BY e.parent_cata_id
ORDER BY e.parent_cata_id
</select>
<select id="selectListByApply" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO">
SELECT
c.id as cataId,
c.`name` as cataName ,
c1.id as parentCataId,
c1.`name` as parentCataName
FROM vehicle_plat_cata c
LEFT JOIN vehicle_plat_cata c1 ON c.parent_id=c1.id
WHERE c.id in
<foreach collection="cataIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
ORDER BY c1.id
</select>
<select id="selectListByApplyParent" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleExtensionVO">
SELECT
c1.id as parentCataId,
c1.`name` as parentCataName
FROM vehicle_plat_cata c
LEFT JOIN vehicle_plat_cata c1 ON c.parent_id=c1.id
WHERE c.id in
<foreach collection="cataIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY c.parent_id
ORDER BY c1.id
</select>
</mapper>
\ No newline at end of file
......@@ -1284,12 +1284,16 @@
LEFT JOIN vehicle_category c ON v.category_id=c.id
LEFT JOIN branch_company bc ON v.subordinate_branch=bc.id
<where>
v.is_del = 0
<if test="name != null and name != ''">
AND ( v.`name` like concat('%',#{name},'%') or v.`number_plate` like concat('%',#{name},'%') )
</if>
<if test="brandId != null and brandId > 0">
AND v.`brand_id`= #{brandId}
</if>
<if test="vehicleId != null and vehicleId != '' ">
AND v.`id`= #{vehicleId}
</if>
<if test="categoryId != null and categoryId > 0">
AND v.`category_id`= #{categoryId}
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment