73 changed files with 2548 additions and 386 deletions
@ -0,0 +1,25 @@ |
|||
package cc.hiver.mall.pojo.vo; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class TotalAmountDetailByCustomerVo { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
@ApiModelProperty(value = " 客户id") |
|||
private String userId; |
|||
|
|||
@ApiModelProperty(value = " 客户名称") |
|||
private String userName; |
|||
|
|||
@ApiModelProperty(value = "利润") |
|||
private BigDecimal profit; |
|||
|
|||
@ApiModelProperty(value = "利润占比") |
|||
private BigDecimal profitProportion; |
|||
|
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package cc.hiver.mall.pojo.vo; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class TotalAmountDetailByProductVo { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
@ApiModelProperty(value = " 商品id") |
|||
private String productId; |
|||
|
|||
@ApiModelProperty(value = " 商品名称") |
|||
private String productName; |
|||
|
|||
@ApiModelProperty(value = " 商品货号") |
|||
private String productSn; |
|||
|
|||
@ApiModelProperty(value = "利润") |
|||
private BigDecimal profit; |
|||
|
|||
@ApiModelProperty(value = "利润占比") |
|||
private BigDecimal profitProportion; |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package cc.hiver.mall.purchasereturn.constant; |
|||
|
|||
public interface PurchaseReturnConstant { |
|||
|
|||
// 订单类型:0:新增入库退货; 1:撤销入库退货
|
|||
String[] TYPE = {"0","1"}; |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
package cc.hiver.mall.purchasereturn.controller; |
|||
|
|||
import cc.hiver.core.common.utils.ResultUtil; |
|||
import cc.hiver.core.common.vo.Result; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.service.PurchaseReturnService; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 采购退货接口 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@Api(tags = "采购退货接口") |
|||
@RequestMapping("/hiver/app/purchaseReturn/") |
|||
@Transactional |
|||
public class PurchaseReturnController { |
|||
|
|||
@Autowired |
|||
private PurchaseReturnService purchaseReturnService; |
|||
|
|||
/** |
|||
* 分页获取采购退货列表 |
|||
* |
|||
* @param purchaseReturnQueryVo |
|||
* @return Result<IPage < PurchaseReturn>> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@RequestMapping(value = "/getPurchaseReturnList", method = RequestMethod.POST) |
|||
@ApiOperation(value = "分页获取采购退货列表") |
|||
public Result<IPage<PurchaseReturn>> getPurchaseReturnList(@RequestBody PurchaseReturnQueryVo purchaseReturnQueryVo) { |
|||
final IPage<PurchaseReturn> result = purchaseReturnService.getPurchaseReturnList(purchaseReturnQueryVo); |
|||
return new ResultUtil<IPage<PurchaseReturn>>().setData(result); |
|||
} |
|||
|
|||
/** |
|||
* 根据id获取采购退货 |
|||
* |
|||
* @param id |
|||
* @return Result<PurchaseReturnDataVo> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@RequestMapping(value = "/getPurchaseReturnById", method = RequestMethod.POST) |
|||
@ApiOperation(value = "根据id获取采购退货") |
|||
public Result<PurchaseReturnDataVo> getPurchaseReturnById(String id) { |
|||
if (StringUtils.isEmpty(id)) { |
|||
return ResultUtil.error("id不能为空"); |
|||
} |
|||
final PurchaseReturnDataVo result = purchaseReturnService.getPurchaseReturnById(id); |
|||
return new ResultUtil<PurchaseReturnDataVo>().setData(result); |
|||
} |
|||
|
|||
/** |
|||
* 撤销采购单退货 |
|||
* |
|||
* @param id |
|||
* @return Result<String> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@RequestMapping(value = "/cancelPurchaseReturn", method = RequestMethod.POST) |
|||
@ApiOperation(value = "撤销采购单退货") |
|||
public Result<String> cancelPurchaseReturn(String id) { |
|||
if (StringUtils.isEmpty(id)) { |
|||
return ResultUtil.error("id不能为空"); |
|||
} |
|||
try { |
|||
purchaseReturnService.cancelPurchaseReturn(id); |
|||
return ResultUtil.success("撤销采购单退货成功"); |
|||
} catch (Exception e) { |
|||
log.error("撤销采购单退货失败", e); |
|||
return ResultUtil.error("撤销采购单退货失败"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package cc.hiver.mall.purchasereturn.controller; |
|||
|
|||
import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; |
|||
import io.swagger.annotations.Api; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 采购退货明细接口 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@Api(tags = "采购退货明细接口") |
|||
@RequestMapping("/hiver/app/purchaseReturnDetail/") |
|||
@Transactional |
|||
public class PurchaseReturnDetailController { |
|||
|
|||
@Autowired |
|||
private PurchaseReturnDetailService purchaseReturnDetailService; |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
package cc.hiver.mall.purchasereturn.entity; |
|||
|
|||
import cc.hiver.core.base.HiverBaseEntity; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import javax.persistence.Transient; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购退货表 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "采购退货") |
|||
@TableName(value = "t_purchase_return", autoResultMap = true) |
|||
public class PurchaseReturn extends HiverBaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "供应商ID") |
|||
private String createByName; |
|||
|
|||
@ApiModelProperty(value = "供应商ID") |
|||
private String supplierId; |
|||
|
|||
@ApiModelProperty(value = "供应商名称") |
|||
private String supplierName; |
|||
|
|||
@ApiModelProperty(value = "店铺ID") |
|||
private String shopId; |
|||
|
|||
@ApiModelProperty(value = "订单金额") |
|||
private BigDecimal totalAmount; |
|||
|
|||
@ApiModelProperty(value = "应付") |
|||
private BigDecimal shouldPay; |
|||
|
|||
@ApiModelProperty(value = "已付") |
|||
private BigDecimal alreadyPay; |
|||
|
|||
@ApiModelProperty(value = "未付") |
|||
private BigDecimal noPay; |
|||
|
|||
@ApiModelProperty(value = "其他费用") |
|||
private BigDecimal otherPay; |
|||
|
|||
@ApiModelProperty(value = "入库状态:0:待入库(未维护对应的采购价信息);1:已入库;") |
|||
private Integer inStorageStatus; |
|||
|
|||
@ApiModelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
@ApiModelProperty(value = "余额抵扣") |
|||
private BigDecimal balanceDeductionAmount; |
|||
|
|||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@ApiModelProperty(value = "入库时间,20240727重新定义为入库单的创建时间,createTime为前台传递的入库单") |
|||
private Date purchaseTime; |
|||
|
|||
@Transient |
|||
@TableField(exist = false) |
|||
@ApiModelProperty(value = "退货单详情") |
|||
private List<PurchaseReturnDetail> purchaseReturnDetails; |
|||
|
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
package cc.hiver.mall.purchasereturn.entity; |
|||
|
|||
import cc.hiver.core.base.HiverBaseEntity; |
|||
import cc.hiver.mall.entity.StockLog; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import javax.persistence.Transient; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购退货详情表 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "采购退货详情") |
|||
@TableName(value = "t_purchase_return_detail", autoResultMap = true) |
|||
public class PurchaseReturnDetail extends HiverBaseEntity { |
|||
|
|||
|
|||
@ApiModelProperty(value = "采购单ID") |
|||
private String purchaseId; |
|||
|
|||
@ApiModelProperty(value = "商品ID") |
|||
private String productId; |
|||
|
|||
@ApiModelProperty(value = "商品名称") |
|||
private String productName; |
|||
|
|||
@ApiModelProperty(value = "单位") |
|||
private String unit; |
|||
|
|||
@ApiModelProperty(value = "店铺ID") |
|||
private String shopId; |
|||
|
|||
@ApiModelProperty(value = "商品分类") |
|||
private String categoryId; |
|||
|
|||
@ApiModelProperty(value = "商品分类") |
|||
private String attrId; |
|||
|
|||
@Transient |
|||
@TableField(exist = false) |
|||
@ApiModelProperty(value = "分类名称") |
|||
private String categoryName; |
|||
|
|||
@ApiModelProperty(value = "商品属性列表") |
|||
private String attributeList; |
|||
|
|||
@ApiModelProperty(value = "供应商") |
|||
private String supplierId; |
|||
|
|||
@ApiModelProperty(value = "供应商名称") |
|||
private String supplierName; |
|||
|
|||
@ApiModelProperty(value = "货号") |
|||
private String productSn; |
|||
|
|||
@ApiModelProperty(value = "条码") |
|||
private String barcode; |
|||
|
|||
@ApiModelProperty(value = "零售价") |
|||
private BigDecimal price; |
|||
|
|||
@Transient |
|||
@TableField(exist = false) |
|||
@ApiModelProperty(value = "零售价(单纯用于接收前台传参)") |
|||
private BigDecimal lsPrice; |
|||
|
|||
@ApiModelProperty(value = "采购价") |
|||
private BigDecimal purchasePrice; |
|||
|
|||
@ApiModelProperty(value = "批发价") |
|||
private BigDecimal wholesalePrice; |
|||
|
|||
@ApiModelProperty(value = "货品图片") |
|||
private String productPicture; |
|||
|
|||
@ApiModelProperty(value = "货品视频") |
|||
private String productVideo; |
|||
|
|||
@ApiModelProperty(value = "货品简介") |
|||
private String productIntro; |
|||
|
|||
@ApiModelProperty(value = "销售周期") |
|||
private Date salesWeek; |
|||
|
|||
@ApiModelProperty(value = "尾货预警") |
|||
private Integer tailWarn; |
|||
|
|||
@ApiModelProperty(value = "打印条码(自己制作的)") |
|||
private String printBarcode; |
|||
|
|||
@ApiModelProperty(value = "采购数量") |
|||
private Integer productCount; |
|||
|
|||
@ApiModelProperty(value = "识别图片id") |
|||
private String ocrPicturePath; |
|||
|
|||
|
|||
@ApiModelProperty(value = "排序") |
|||
private Integer sort; |
|||
|
|||
@Transient |
|||
@TableField(exist = false) |
|||
@ApiModelProperty(value = "入库商品规格明细表") |
|||
private List<StockLog> stockLogList1; |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package cc.hiver.mall.purchasereturn.mapper; |
|||
|
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购退货明细Mapper |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
public interface PurchaseReturnDetailMapper extends BaseMapper<PurchaseReturnDetail> { |
|||
List<PurchaseReturnDetail> getByPurchaseReturnId(@Param("id") String id); |
|||
|
|||
/** |
|||
* 撤销入库明细 |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
* @param purchaseId |
|||
*/ |
|||
void cancelByPurchaseReturnId(@Param("purchaseId") String purchaseId); |
|||
|
|||
List<PurchaseReturnDetail> getPurchaseReturnDetails(@Param("purchaseIdList") List<String> purchaseIdList); |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package cc.hiver.mall.purchasereturn.mapper; |
|||
|
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 采购退货Mapper |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
public interface PurchaseReturnMapper extends BaseMapper<PurchaseReturn> { |
|||
|
|||
/** |
|||
* 分页获取采购退货列表 |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
* @param page |
|||
* @param purchaseReturnQueryVo |
|||
* @return IPage<PurchaseReturn> |
|||
*/ |
|||
IPage<PurchaseReturn> getPurchaseReturnList(Page<PurchaseReturn> page, @Param("queryParams") PurchaseReturnQueryVo purchaseReturnQueryVo); |
|||
|
|||
void cancelPurchaseReturnById(@Param("id") String id); |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package cc.hiver.mall.purchasereturn.service; |
|||
|
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购退货明细 Service |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
public interface PurchaseReturnDetailService extends IService<PurchaseReturnDetail> { |
|||
|
|||
/** |
|||
* 根据入库退货id获取商品信息 |
|||
* |
|||
* @param id |
|||
* @return List<PurchaseReturnDetail> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
List<PurchaseReturnDetail> getByPurchaseReturnId(String id); |
|||
|
|||
/** |
|||
* 撤销入库明细 |
|||
* |
|||
* @param id |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
void cancelByPurchaseReturnId(String id); |
|||
|
|||
List<PurchaseReturnDetail> getPurchaseReturnDetails(List<String> purchaseIdList); |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package cc.hiver.mall.purchasereturn.service; |
|||
|
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
|
|||
/** |
|||
* 采购退货 Service |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
public interface PurchaseReturnService extends IService<PurchaseReturn> { |
|||
|
|||
/** |
|||
* 分页获取采购退货列表 |
|||
* |
|||
* @param purchaseReturnQueryVo |
|||
* @return IPage<PurchaseReturn> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
IPage<PurchaseReturn> getPurchaseReturnList(PurchaseReturnQueryVo purchaseReturnQueryVo); |
|||
|
|||
/** |
|||
* 根据id获取采购退货 |
|||
* |
|||
* @param id |
|||
* @return PurchaseReturnDataVo |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
PurchaseReturnDataVo getPurchaseReturnById(String id); |
|||
|
|||
/** |
|||
* 撤销采购单退货 |
|||
* |
|||
* @param id |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
void cancelPurchaseReturn(String id); |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package cc.hiver.mall.purchasereturn.service.impl; |
|||
|
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import cc.hiver.mall.purchasereturn.mapper.PurchaseReturnDetailMapper; |
|||
import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购退货明细服务实现类 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Service |
|||
public class PurchaseReturnDetailServiceImpl extends ServiceImpl<PurchaseReturnDetailMapper, PurchaseReturnDetail> implements PurchaseReturnDetailService { |
|||
|
|||
@Autowired |
|||
private PurchaseReturnDetailMapper purchaseReturnDetailMapper; |
|||
|
|||
/** |
|||
* 根据入库退货id获取商品信息 |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
* @param id |
|||
* @return List<PurchaseReturnDetail> |
|||
*/ |
|||
@Override |
|||
public List<PurchaseReturnDetail> getByPurchaseReturnId(String id) { |
|||
return purchaseReturnDetailMapper.getByPurchaseReturnId(id); |
|||
} |
|||
|
|||
/** |
|||
* 撤销入库明细 |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
* @param purchaseId |
|||
*/ |
|||
@Override |
|||
public void cancelByPurchaseReturnId(String purchaseId) { |
|||
purchaseReturnDetailMapper.cancelByPurchaseReturnId(purchaseId); |
|||
} |
|||
|
|||
@Override |
|||
public List<PurchaseReturnDetail> getPurchaseReturnDetails(List<String> purchaseIdList) { |
|||
return purchaseReturnDetailMapper.getPurchaseReturnDetails(purchaseIdList); |
|||
} |
|||
} |
|||
@ -0,0 +1,234 @@ |
|||
package cc.hiver.mall.purchasereturn.service.impl; |
|||
|
|||
import cc.hiver.core.common.exception.HiverException; |
|||
import cc.hiver.core.common.utils.SecurityUtil; |
|||
import cc.hiver.mall.common.constant.StockLogConstant; |
|||
import cc.hiver.mall.debt.service.DebtService; |
|||
import cc.hiver.mall.entity.Product; |
|||
import cc.hiver.mall.entity.Stock; |
|||
import cc.hiver.mall.entity.StockLog; |
|||
import cc.hiver.mall.entity.Supplier; |
|||
import cc.hiver.mall.purchasereturn.constant.PurchaseReturnConstant; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import cc.hiver.mall.purchasereturn.mapper.PurchaseReturnMapper; |
|||
import cc.hiver.mall.purchasereturn.service.PurchaseReturnDetailService; |
|||
import cc.hiver.mall.purchasereturn.service.PurchaseReturnService; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnDataVo; |
|||
import cc.hiver.mall.purchasereturn.vo.PurchaseReturnQueryVo; |
|||
import cc.hiver.mall.service.SupplierService; |
|||
import cc.hiver.mall.service.mybatis.DealingsRecordService; |
|||
import cc.hiver.mall.service.mybatis.ProductService; |
|||
import cc.hiver.mall.service.mybatis.StockLogService; |
|||
import cc.hiver.mall.service.mybatis.StockService; |
|||
import cc.hiver.mall.utils.DateUtil; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 采购退货 服务实现类 |
|||
* |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Service |
|||
public class PurchaseReturnServiceImpl extends ServiceImpl<PurchaseReturnMapper, PurchaseReturn> implements PurchaseReturnService { |
|||
|
|||
@Autowired |
|||
private PurchaseReturnMapper purchaseReturnMapper; |
|||
|
|||
@Autowired |
|||
private SupplierService supplierService; |
|||
|
|||
@Autowired |
|||
private PurchaseReturnDetailService purchaseReturnDetailService; |
|||
|
|||
@Autowired |
|||
private StockLogService stockLogService; |
|||
|
|||
@Autowired |
|||
ProductService productService; |
|||
|
|||
@Autowired |
|||
private DealingsRecordService dealingsRecordService; |
|||
|
|||
@Autowired |
|||
private StockService stockService; |
|||
|
|||
@Autowired |
|||
private SecurityUtil securityUtil; |
|||
|
|||
@Autowired |
|||
private DebtService debtService; |
|||
|
|||
/** |
|||
* 分页获取采购退货列表 |
|||
* |
|||
* @param purchaseReturnQueryVo |
|||
* @return IPage<PurchaseReturn> |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Override |
|||
public IPage<PurchaseReturn> getPurchaseReturnList(PurchaseReturnQueryVo purchaseReturnQueryVo) { |
|||
//解释时间加1天
|
|||
if (StringUtils.isNotEmpty(purchaseReturnQueryVo.getEndDate())) { |
|||
purchaseReturnQueryVo.setEndDate(DateUtil.addDay(purchaseReturnQueryVo.getEndDate(), 1)); |
|||
} |
|||
final String shopId = securityUtil.getShopId(); |
|||
purchaseReturnQueryVo.setShopId(shopId); |
|||
final Page<PurchaseReturn> page = new Page<>(purchaseReturnQueryVo.getPageNum(), purchaseReturnQueryVo.getPageSize()); |
|||
return purchaseReturnMapper.getPurchaseReturnList(page, purchaseReturnQueryVo); |
|||
} |
|||
|
|||
/** |
|||
* 根据id获取采购退货 |
|||
* |
|||
* @param id |
|||
* @return PurchaseReturnDataVo |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Override |
|||
public PurchaseReturnDataVo getPurchaseReturnById(String id) { |
|||
final PurchaseReturnDataVo purchaseReturnDataVo = new PurchaseReturnDataVo(); |
|||
// 获取采购单信息
|
|||
final PurchaseReturn purchaseReturn = purchaseReturnMapper.selectById(id); |
|||
purchaseReturnDataVo.setPurchaseReturn(purchaseReturn); |
|||
// 获取供应商信息
|
|||
final String supplierId = purchaseReturn.getSupplierId(); |
|||
if (StringUtils.isNotEmpty(supplierId)) { |
|||
final Supplier supplier = supplierService.findById(supplierId); |
|||
purchaseReturnDataVo.setSupplier(supplier); |
|||
} |
|||
// 获取商品信息
|
|||
final List<PurchaseReturnDetail> purchaseReturnDetails = purchaseReturnDetailService.getByPurchaseReturnId(id); |
|||
// 获取规格信息
|
|||
final List<StockLog> stockLogList = stockLogService.getByPurchaseId(id); |
|||
final Map<String, List<StockLog>> stockLogMap = new HashMap<>(); |
|||
// 封装规格属性
|
|||
for (StockLog stockLog : stockLogList) { |
|||
final String productId = stockLog.getProductId(); |
|||
if (stockLogMap.containsKey(productId)) { |
|||
stockLogMap.get(productId).add(stockLog); |
|||
} else { |
|||
final List<StockLog> stockLogs = new ArrayList<>(); |
|||
stockLogs.add(stockLog); |
|||
stockLogMap.put(productId, stockLogs); |
|||
} |
|||
} |
|||
final List<String> productIdList = new ArrayList<>(); |
|||
for (PurchaseReturnDetail returnDetail : purchaseReturnDetails) { |
|||
final String productId = returnDetail.getProductId(); |
|||
returnDetail.setStockLogList1(stockLogMap.get(productId)); |
|||
productIdList.add(productId); |
|||
} |
|||
if (!productIdList.isEmpty()) { |
|||
// 20240602 将商品的采购价、零售价、批发价回填回来
|
|||
// 获取商品
|
|||
final List<Product> productList = productService.getProductList(productIdList); |
|||
// 将商品封装为map,key为商品id,value为商品信息
|
|||
final Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, product -> product)); |
|||
for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { |
|||
final String productId = purchaseReturnDetail.getProductId(); |
|||
if (productMap.containsKey(productId)) { |
|||
final Product product = productMap.get(productId); |
|||
purchaseReturnDetail.setPrice(product.getPrice()); |
|||
purchaseReturnDetail.setWholesalePrice(product.getWholesalePrice()); |
|||
purchaseReturnDetail.setPurchasePrice(product.getPurchasePrice()); |
|||
} |
|||
} |
|||
purchaseReturnDataVo.setPurchaseReturnDetails(purchaseReturnDetails); |
|||
} |
|||
|
|||
// 获取该入库单的欠款更新记录
|
|||
purchaseReturnDataVo.setDealingsRecords(dealingsRecordService.getDealingsRecordList(id)); |
|||
return purchaseReturnDataVo; |
|||
} |
|||
|
|||
/** |
|||
* 撤销采购单退货 |
|||
* |
|||
* @param id |
|||
* @author 王富康 |
|||
* @date 2024/8/17 |
|||
*/ |
|||
@Override |
|||
public void cancelPurchaseReturn(String id) { |
|||
PurchaseReturnDataVo purchaseReturnById = getPurchaseReturnById(id); |
|||
|
|||
// 1. 删除入库单主表信息
|
|||
purchaseReturnMapper.cancelPurchaseReturnById(id); |
|||
// 2. 删除退货明细
|
|||
purchaseReturnDetailService.cancelByPurchaseReturnId(id); |
|||
// 需要新增的履历集合
|
|||
final List<StockLog> stockLogAddList = new ArrayList<>(); |
|||
// 2. 回退库存
|
|||
// 获取前台入库商品信息
|
|||
final List<PurchaseReturnDetail> purchaseReturnDetails = purchaseReturnById.getPurchaseReturnDetails(); |
|||
// 需要修改的商品信息集合,商品中的平均采购价需要计算
|
|||
final List<String> productIdList = new ArrayList<>(); |
|||
for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { |
|||
productIdList.add(purchaseReturnDetail.getProductId()); |
|||
} |
|||
// 根据商品id集合获取库存信息
|
|||
final List<Stock> productStock = stockService.getProductStock(productIdList); |
|||
// 封装为商品id+商品属性为key ,Stock为value的map
|
|||
final Map<String, Stock> stockMap = new HashMap<>(); |
|||
for (Stock stock : productStock) { |
|||
stockMap.put(stock.getProductId() + stock.getAttributeList(), stock); |
|||
} |
|||
for (PurchaseReturnDetail purchaseReturnDetail : purchaseReturnDetails) { |
|||
final List<StockLog> changeStockLogs = purchaseReturnDetail.getStockLogList1(); |
|||
for (StockLog changeStockLog : changeStockLogs) { |
|||
StockLog returnStockLog = new StockLog(); |
|||
// 获取商品id+商品属性为key ,Stock为value的map
|
|||
final String changeProductId = changeStockLog.getProductId(); |
|||
final String changeAttributeList = changeStockLog.getAttributeList(); |
|||
final String getKey = changeProductId + changeAttributeList; |
|||
if (stockMap.containsKey(getKey)) { |
|||
final Stock stock = stockMap.get(getKey); |
|||
//撤销前数量
|
|||
returnStockLog.setStock(stock.getStockCount()); |
|||
} else { |
|||
// 不存在库存?应该没有吧
|
|||
throw new HiverException("商品id为" + changeProductId + "的商品属性为" + changeAttributeList + "的商品库存不存在"); |
|||
} |
|||
// shopId从缓存中设置
|
|||
final String shopId = securityUtil.getShopId(); |
|||
// 整理入库商品规格明细表数据
|
|||
// 记录库存履历
|
|||
returnStockLog.setProductId(changeProductId); |
|||
returnStockLog.setOrderId(id); |
|||
returnStockLog.setDetailId(purchaseReturnDetail.getId()); |
|||
//入库
|
|||
returnStockLog.setChangeType(StockLogConstant.CHANGE_TYPE[0]); |
|||
returnStockLog.setShopId(shopId); |
|||
returnStockLog.setPurchasePrice(purchaseReturnDetail.getPurchasePrice()); |
|||
returnStockLog.setProductCount(changeStockLog.getProductCount()); |
|||
returnStockLog.setAttributeList(changeStockLog.getAttributeList()); |
|||
stockLogAddList.add(returnStockLog); |
|||
} |
|||
} |
|||
// 批量更新库存数
|
|||
stockService.batchIncreaseStockByLog(stockLogAddList); |
|||
// 库存记录
|
|||
stockLogService.saveBatch(stockLogAddList); |
|||
// 3. 回退供应商欠款
|
|||
// 异步更新供应商欠款信息机欠款记录
|
|||
debtService.purchaseReturnToDebt(purchaseReturnById.getPurchaseReturn(), PurchaseReturnConstant.TYPE[1]); |
|||
// 作废当前订单的欠款记录
|
|||
dealingsRecordService.cancelRecord(id); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package cc.hiver.mall.purchasereturn.vo; |
|||
|
|||
import cc.hiver.mall.entity.DealingsRecord; |
|||
import cc.hiver.mall.entity.Supplier; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
public class PurchaseReturnDataVo { |
|||
|
|||
@ApiModelProperty(value = "供应商信息") |
|||
private Supplier supplier; |
|||
|
|||
@ApiModelProperty(value = "采购单主表") |
|||
private PurchaseReturn purchaseReturn; |
|||
|
|||
@ApiModelProperty(value = "采购单子表") |
|||
private List<PurchaseReturnDetail> purchaseReturnDetails; |
|||
|
|||
@ApiModelProperty(value = "欠款信息") |
|||
private List<DealingsRecord> dealingsRecords; |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package cc.hiver.mall.purchasereturn.vo; |
|||
|
|||
import cc.hiver.core.base.HiverBasePageQuery; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class PurchaseReturnQueryVo extends HiverBasePageQuery implements Serializable { |
|||
|
|||
private String shopId; |
|||
|
|||
private String queryStr; |
|||
|
|||
private String startDate; |
|||
|
|||
private String endDate; |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package cc.hiver.mall.purchasereturn.vo; |
|||
|
|||
import cc.hiver.mall.entity.DealingsRecord; |
|||
import cc.hiver.mall.entity.Supplier; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturn; |
|||
import cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
public class PurchaseReturnVo { |
|||
|
|||
@ApiModelProperty(value = "供应商信息") |
|||
private Supplier supplier; |
|||
|
|||
@ApiModelProperty(value = "采购单退货主表") |
|||
private PurchaseReturn purchase; |
|||
|
|||
@ApiModelProperty(value = "采购单退货子表") |
|||
private List<PurchaseReturnDetail> purchaseDetails; |
|||
|
|||
@ApiModelProperty(value = "欠款信息") |
|||
private List<DealingsRecord> dealingsRecords; |
|||
|
|||
} |
|||
@ -0,0 +1,239 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="cc.hiver.mall.purchasereturn.mapper.PurchaseReturnDetailMapper"> |
|||
<resultMap id="BaseResultMap" type="cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="purchase_id" jdbcType="VARCHAR" property="purchaseId" /> |
|||
<result column="product_id" jdbcType="VARCHAR" property="productId" /> |
|||
<result column="product_name" jdbcType="VARCHAR" property="productName" /> |
|||
<result column="unit" jdbcType="VARCHAR" property="unit" /> |
|||
<result column="shop_id" jdbcType="VARCHAR" property="shopId" /> |
|||
<result column="category_id" jdbcType="VARCHAR" property="categoryId" /> |
|||
<result column="attribute_list" jdbcType="VARCHAR" property="attributeList" /> |
|||
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" /> |
|||
<result column="supplier_name" jdbcType="VARCHAR" property="supplierName" /> |
|||
<result column="product_sn" jdbcType="VARCHAR" property="productSn" /> |
|||
<result column="barcode" jdbcType="VARCHAR" property="barcode" /> |
|||
<result column="price" jdbcType="DECIMAL" property="price" /> |
|||
<result column="purchase_price" jdbcType="DECIMAL" property="purchasePrice" /> |
|||
<result column="wholesale_price" jdbcType="DECIMAL" property="wholesalePrice" /> |
|||
<result column="product_picture" jdbcType="VARCHAR" property="productPicture" /> |
|||
<result column="product_video" jdbcType="VARCHAR" property="productVideo" /> |
|||
<result column="product_intro" jdbcType="VARCHAR" property="productIntro" /> |
|||
<result column="sales_week" jdbcType="TIMESTAMP" property="salesWeek" /> |
|||
<result column="tail_warn" jdbcType="INTEGER" property="tailWarn" /> |
|||
<result column="print_barcode" jdbcType="VARCHAR" property="printBarcode" /> |
|||
<result column="product_count" jdbcType="INTEGER" property="productCount" /> |
|||
<result column="ocr_picture_path" jdbcType="VARCHAR" property="ocrPicturePath" /> |
|||
<result column="sort" jdbcType="INTEGER" property="sort" /> |
|||
</resultMap> |
|||
<sql id="Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Update_By_Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="example.oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Base_Column_List"> |
|||
id, create_by, create_time, del_flag, update_by, update_time, purchase_id, product_id, |
|||
product_name, unit, shop_id, category_id, attribute_list, supplier_id,supplier_name, product_sn, |
|||
barcode, price, purchase_price, wholesale_price, product_picture, product_video, |
|||
product_intro, sales_week, tail_warn, print_barcode, product_count,ocr_picture_path,sort |
|||
</sql> |
|||
|
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return_detail |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from t_purchase_return_detail |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
|
|||
<insert id="insert" parameterType="cc.hiver.mall.purchasereturn.entity.PurchaseReturnDetail"> |
|||
insert into t_purchase_return_detail (id, create_by, create_time, |
|||
del_flag, update_by, update_time, |
|||
purchase_id, product_id, product_name, |
|||
unit, shop_id, category_id, |
|||
attribute_list, supplier_id,supplier_name, product_sn, |
|||
barcode, price, purchase_price, |
|||
wholesale_price, product_picture, product_video, |
|||
product_intro, sales_week, tail_warn, |
|||
print_barcode, product_count,ocr_picture_path,sort) |
|||
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
|||
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, |
|||
#{purchaseId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, |
|||
#{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, |
|||
#{attributeList,jdbcType=VARCHAR}, #{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR}, |
|||
#{barcode,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL}, |
|||
#{wholesalePrice,jdbcType=DECIMAL}, #{productPicture,jdbcType=VARCHAR}, #{productVideo,jdbcType=VARCHAR}, |
|||
#{productIntro,jdbcType=VARCHAR}, #{salesWeek,jdbcType=TIMESTAMP}, #{tailWarn,jdbcType=INTEGER}, |
|||
#{printBarcode,jdbcType=VARCHAR}, #{productCount,jdbcType=INTEGER},#{ocrPicturePath,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER}) |
|||
</insert> |
|||
|
|||
<!--getByPurchaseId--> |
|||
<select id="getByPurchaseReturnId" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return_detail |
|||
where purchase_id = #{id,jdbcType=VARCHAR} |
|||
order by create_time desc ,sort asc |
|||
</select> |
|||
|
|||
<select id="getByPurchaseIdList" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return_detail |
|||
where del_flag ='0' |
|||
<if test='productId != null and productId.trim() neq "" '> |
|||
and product_id = #{productId,jdbcType=VARCHAR} |
|||
</if> |
|||
and purchase_id in |
|||
<foreach close=")" collection="purchaseIds" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</select> |
|||
|
|||
<insert id="batchSavePurchaseList" parameterType="java.util.List"> |
|||
insert into t_purchase_return_detail (id, create_by, create_time, del_flag, update_by, update_time, purchase_id, product_id, |
|||
product_name, unit, shop_id, category_id, attribute_list, supplier_id,supplier_name, product_sn, |
|||
barcode, price, purchase_price, wholesale_price, product_picture, product_video, |
|||
product_intro, sales_week, tail_warn, print_barcode, product_count, ocr_picture_path,sort) values |
|||
<foreach item="purchaseDetail" collection="purchaseDetails" index="index" separator=","> |
|||
(#{purchaseDetail.id}, #{purchaseDetail.createBy}, #{purchaseDetail.createTime}, #{purchaseDetail.delFlag}, |
|||
#{purchaseDetail.updateBy}, #{purchaseDetail.updateTime}, #{purchaseDetail.purchaseId}, #{purchaseDetail.productId}, |
|||
#{purchaseDetail.productName}, #{purchaseDetail.unit}, #{purchaseDetail.shopId}, #{purchaseDetail.categoryId}, |
|||
#{purchaseDetail.attributeList}, #{purchaseDetail.supplierId}, #{purchaseDetail.supplierName}, #{purchaseDetail.productSn}, |
|||
#{purchaseDetail.barcode}, #{purchaseDetail.price}, #{purchaseDetail.purchasePrice}, #{purchaseDetail.wholesalePrice}, |
|||
#{purchaseDetail.productPicture}, #{purchaseDetail.productVideo}, #{purchaseDetail.productIntro}, |
|||
#{purchaseDetail.salesWeek}, #{purchaseDetail.tailWarn}, #{purchaseDetail.printBarcode}, #{purchaseDetail.productCount}, |
|||
#{purchaseDetail.ocrPicturePath},#{purchaseDetail.sort}) |
|||
</foreach> |
|||
|
|||
</insert> |
|||
|
|||
<select id="selectByProductSn" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return_detail |
|||
where purchase_id = #{purchaseId,jdbcType=VARCHAR} |
|||
and del_flag ='0' |
|||
and product_sn = #{productSn,jdbcType=VARCHAR} and product_name = #{productName,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
<update id="batchUpdatePurchaseList"> |
|||
<foreach collection="purchaseDetails" item="item" separator=";" open="" close=""> |
|||
update t_purchase_return_detail set product_count = #{item.productCount} WHERE id = #{item.id} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<update id="cancelByPurchaseReturnId" parameterType="java.lang.String"> |
|||
update t_purchase_return_detail set del_flag = '1' where purchase_id = #{purchaseId,jdbcType=VARCHAR} |
|||
</update> |
|||
|
|||
<!--根据入库单id真删除--> |
|||
<delete id="realDeleteByPurchaseId" parameterType="java.lang.String"> |
|||
delete from t_purchase_return_detail |
|||
where purchase_id = #{purchaseId,jdbcType=VARCHAR} |
|||
</delete> |
|||
|
|||
<select id="getPurchaseDetails" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from t_purchase_return_detail |
|||
where purchase_id in |
|||
<foreach close=")" collection="purchaseIdList" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</select> |
|||
|
|||
<select id="getPurchaseDetailListByProductIds" resultMap="BaseResultMap"> |
|||
select |
|||
tpd.id, tpd.create_by, tpd.create_time, tpd.del_flag, tpd.update_by, tpd.update_time, tpd.purchase_id, tpd.product_id, |
|||
tpd.product_name, tpd.unit, tpd.shop_id, tpd.category_id, tpd.attribute_list, tpd.supplier_id, tpd.supplier_name, tpd.product_sn, |
|||
tpd.barcode, tpd.price, tpd.purchase_price, tpd.wholesale_price, tpd.product_picture, tpd.product_video, |
|||
tpd.product_intro, tpd.sales_week, tpd.tail_warn, tpd.print_barcode, tpd.product_count,tpd.ocr_picture_path,tpd.sort |
|||
from t_purchase_return_detail tpd |
|||
left join t_purchase_return tp on tpd.purchase_id = tp.id |
|||
where |
|||
<!-- 已入库的--> |
|||
tp.in_storage_status = '1' |
|||
and tpd.purchase_id != #{id,jdbcType=VARCHAR} |
|||
and tpd.del_flag = '0' |
|||
and tpd.product_id in |
|||
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</select> |
|||
|
|||
<select id="getPurchaseReturnDetails" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from t_purchase_return_detail |
|||
where purchase_id in |
|||
<foreach close=")" collection="purchaseIdList" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
|||
@ -0,0 +1,73 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="cc.hiver.mall.purchasereturn.mapper.PurchaseReturnMapper"> |
|||
<resultMap id="BaseResultMap" type="cc.hiver.mall.purchasereturn.entity.PurchaseReturn"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" /> |
|||
<result column="supplier_name" jdbcType="VARCHAR" property="supplierName" /> |
|||
<result column="shop_id" jdbcType="VARCHAR" property="shopId" /> |
|||
<result column="total_amount" jdbcType="DECIMAL" property="totalAmount" /> |
|||
<result column="should_pay" jdbcType="DECIMAL" property="shouldPay" /> |
|||
<result column="already_pay" jdbcType="DECIMAL" property="alreadyPay" /> |
|||
<result column="no_pay" jdbcType="DECIMAL" property="noPay" /> |
|||
<result column="other_pay" jdbcType="DECIMAL" property="otherPay" /> |
|||
<result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus" /> |
|||
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
|||
<result column="balance_deduction_amount" jdbcType="DECIMAL" property="balanceDeductionAmount" /> |
|||
<result column="purchase_time" jdbcType="TIMESTAMP" property="purchaseTime" /> |
|||
</resultMap> |
|||
|
|||
<sql id="Base_Column_List"> |
|||
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, supplier_id,supplier_name, shop_id, |
|||
total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark, balance_deduction_amount, |
|||
purchase_time |
|||
</sql> |
|||
|
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from t_purchase_return |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
|
|||
<select id="getPurchaseReturnList" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_purchase_return t |
|||
<where> |
|||
and shop_id = #{queryParams.shopId} |
|||
<!--反馈内容--> |
|||
<if test='queryParams.startDate != null and queryParams.startDate.trim() neq ""'> |
|||
AND t.create_time between #{queryParams.startDate} and #{queryParams.endDate} |
|||
</if> |
|||
<!-- 模糊查询 --> |
|||
<if test='queryParams.queryStr != null and queryParams.queryStr neq "" '> |
|||
and (t.create_by_name like concat('%',#{queryParams.queryStr,jdbcType=VARCHAR},'%') |
|||
or t.supplier_name like concat('%',#{queryParams.queryStr,jdbcType=VARCHAR},'%') |
|||
) |
|||
</if> |
|||
</where> |
|||
ORDER BY |
|||
t.create_time desc |
|||
</select> |
|||
|
|||
<!--撤销入库退货--> |
|||
<update id="cancelPurchaseReturnById"> |
|||
update t_purchase_return |
|||
set del_flag = '1' |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue