diff --git a/fuintAdmin/src/views/integral/settings/index.vue b/fuintAdmin/src/views/integral/settings/index.vue index bf5177aee..b8c93b57e 100644 --- a/fuintAdmin/src/views/integral/settings/index.vue +++ b/fuintAdmin/src/views/integral/settings/index.vue @@ -76,15 +76,15 @@ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/controller/LJGoodsController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/controller/LJGoodsController.java index 84d6624cf..d820dd2c9 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/controller/LJGoodsController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/controller/LJGoodsController.java @@ -3,6 +3,7 @@ package com.fuint.business.convenienceSore.controller; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.convenienceSore.dto.LJGoodsDto; import com.fuint.business.convenienceSore.entity.LJGoods; import com.fuint.business.convenienceSore.service.LJGoodsService; import com.fuint.framework.web.BaseController; @@ -117,4 +118,15 @@ public class LJGoodsController extends BaseController { public ResponseObject edit(@Validated @RequestBody LJGoods goods){ return getSuccessResult(goodsService.updateLJGoods(goods)); } + + /** + * 修改该商品库存 + * @param goods + * @return + */ + @PostMapping("editGoodsInventory") + public ResponseObject editGoodsInventory(@RequestBody LJGoodsDto goods){ + return getSuccessResult(goodsService.editGoodsInventory(goods)); + } + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/dto/LJGoodsDto.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/dto/LJGoodsDto.java new file mode 100644 index 000000000..c3b407af4 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/dto/LJGoodsDto.java @@ -0,0 +1,16 @@ +package com.fuint.business.convenienceSore.dto; + +import com.fuint.business.convenienceSore.entity.LJGoods; +import lombok.Data; + +@Data +public class LJGoodsDto extends LJGoods { + + // 库存变动 + private Integer numberOfChanges; + private Integer stockId; + // 变动原因 + private String document; + + +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/mapper/LJGoodsMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/mapper/LJGoodsMapper.java index 3ae66bdda..874581857 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/mapper/LJGoodsMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/mapper/LJGoodsMapper.java @@ -15,4 +15,6 @@ public interface LJGoodsMapper extends BaseMapper { * @return */ public IPage selectLJGoodsList(Page page, @Param("goods") LJGoods goods); + + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/LJGoodsService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/LJGoodsService.java index d79db80ee..21a7b5683 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/LJGoodsService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/LJGoodsService.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.business.convenienceSore.dto.LJGoodsDto; import com.fuint.business.convenienceSore.entity.LJGoods; import java.util.List; @@ -70,4 +71,7 @@ public interface LJGoodsService extends IService { * @return */ public int updateLJGoods(LJGoods goods); + + + boolean editGoodsInventory(LJGoodsDto goods); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/StockStatisticService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/StockStatisticService.java index 37a15c102..a0c29486f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/StockStatisticService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/StockStatisticService.java @@ -53,4 +53,8 @@ public interface StockStatisticService extends IService { * @return */ public void deleteStock(Integer goodsId); + + public int editStock(StockStatistic stock); + + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/LJGoodsServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/LJGoodsServiceImpl.java index f89419b81..43cdaf8b5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/LJGoodsServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/LJGoodsServiceImpl.java @@ -1,11 +1,13 @@ package com.fuint.business.convenienceSore.service.impl; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.convenienceSore.dto.LJGoodsDto; import com.fuint.business.convenienceSore.entity.LJGoods; import com.fuint.business.convenienceSore.entity.StockStatistic; import com.fuint.business.convenienceSore.entity.StockTrack; @@ -14,12 +16,19 @@ import com.fuint.business.convenienceSore.service.LJGoodsService; import com.fuint.business.convenienceSore.service.StockStatisticService; import com.fuint.business.convenienceSore.service.StockTrackService; import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.StringUtils; import com.fuint.common.util.TokenUtil; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import java.math.BigDecimal; import java.util.List; import java.util.Random; +import java.util.concurrent.ExecutionException; /** * 商品信息 业务层 @@ -174,4 +183,77 @@ public class LJGoodsServiceImpl extends ServiceImpl impl int row = baseMapper.updateById(goods); return row; } + + + @Override + @Transactional + public boolean editGoodsInventory(LJGoodsDto goods) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer storeId = nowAccountInfo.getStoreId(); + goods.setStoreId(storeId); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id",goods.getId()); + queryWrapper.eq("store_id",goods.getStoreId()); + LJGoods ljGoods = baseMapper.selectOne(queryWrapper); + // 变动库存 + if (ObjectUtil.isEmpty(ljGoods)) { + return false; + } + goods.setBuyingPrice(ljGoods.getBuyingPrice()); + if (!ObjectUtil.isEmpty(ljGoods.getStock()) && !ObjectUtil.isEmpty(goods.getNumberOfChanges())) { + goods.setStock(ljGoods.getStock() + goods.getNumberOfChanges()); + if (goods.getStock()>0) { + // 修改该库存 + int i = baseMapper.updateById(goods); + if (i>0) { + // 添加统计信息 + StockStatistic stockStatistic = stockService.selectStockByGoodsId(goods.getId().intValue()); + goods.setStockId(stockStatistic.getId()); + boolean b = addStockStatistic(goods); + + if (!ObjectUtil.isEmpty(stockStatistic)) { + // 添加库存跟踪信息 + if (!ObjectUtil.isEmpty(stockStatistic.getId())){ + goods.setStockId(stockStatistic.getId()); + addStockTrack(goods); + return true; + } + } + } + } else { + try { + throw new Exception("剩余库存已小于0"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return false; + } + + // 添加统计信息 + public boolean addStockStatistic(LJGoodsDto goods) { + StockStatistic stock = new StockStatistic(); + stock.setId(goods.getId()); + BigDecimal Price = new BigDecimal(goods.getBuyingPrice()); + BigDecimal Stock = new BigDecimal(goods.getStock()); + BigDecimal multiply = Price.multiply(Stock); + stock.setCostAmount(multiply.doubleValue()); + int i = stockService.editStock(stock); + + return i>0; + } + + // 添加库存跟踪信息 + public boolean addStockTrack(LJGoodsDto goods) { + StockTrack stockTrack = new StockTrack(); + stockTrack.setStockId(goods.getStockId()); + stockTrack.setStoreId(goods.getStoreId()); + stockTrack.setDocument(goods.getDocument()); + stockTrack.setChangeNumber(goods.getNumberOfChanges()); + int i = trackService.insertStockTrack(stockTrack); + return i>0; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/StockStatisticServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/StockStatisticServiceImpl.java index ce293b0ad..813e01907 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/StockStatisticServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/convenienceSore/service/impl/StockStatisticServiceImpl.java @@ -91,4 +91,11 @@ public class StockStatisticServiceImpl extends ServiceImpl iPageList = this.integralDetailService.queryByPage(page, integralDetail); + return getSuccessResult(iPageList); + } + + + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("{id}") + public ResponseObject queryById(@PathVariable("id") Integer id) { + return getSuccessResult(this.integralDetailService.queryById(id)); + } + + /** + * 新增数据 + * + * @param integralDetail 实体 + * @return 新增结果 + */ + @PostMapping + public ResponseObject add(@RequestBody IntegralDetail integralDetail) { + return getSuccessResult(this.integralDetailService.insert(integralDetail)); + } + + /** + * 编辑数据 + * + * @param integralDetail 实体 + * @return 编辑结果 + */ + @PutMapping + public ResponseObject edit(@RequestBody IntegralDetail integralDetail) { + return getSuccessResult(this.integralDetailService.update(integralDetail)); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public ResponseObject deleteById(Integer id) { + return getSuccessResult(this.integralDetailService.deleteById(id)); + } + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/controller/IntegralOrdersController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/controller/IntegralOrdersController.java index e16ad79b7..86a208a79 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/controller/IntegralOrdersController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/controller/IntegralOrdersController.java @@ -110,5 +110,29 @@ public class IntegralOrdersController extends BaseController { public ResponseObject statistics() { return getSuccessResult(this.integralOrdersService.statistics()); } + + + /** + * + * 礼品订单 + * + * 判断积分是否足够 + * + * 增加订单之前首先判断是否还存在 库存 + * + * 增加积分订单 + * + * 减去积分商城库存 + * + * 减去商品库存 + * + * 减去用户积分 + * + */ + @PostMapping("integralOrdersProcessing") + public ResponseObject integralOrdersProcessing(@RequestBody IntegralOrders integralOrders) { + return getSuccessResult(this.integralOrdersService.integralOrdersProcessing(integralOrders)); + } + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java new file mode 100644 index 000000000..94dd8dc45 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java @@ -0,0 +1,74 @@ +package com.fuint.business.integral.entity; + +import java.util.Date; +import com.fuint.repository.model.base.BaseEntity; +import lombok.Data; + +/** + * 积分明细表(IntegralDetail)实体类 + * + * @author wangh + * @since 2023-11-10 17:52:33 + */ +@Data +public class IntegralDetail extends BaseEntity { + private static final long serialVersionUID = 263718830208700746L; + /** + * 积分明细ID + */ + private Integer id; + /** + * 用户ID,表示积分变动的用户 + */ + private Integer userId; + /** + * 积分变动的数量,可以是正数表示增加,负数表示减少 + */ + private Integer pointsChange; + /** + * 变动后用户的当前积分总数 + */ + private Integer currentPoints; + /** + * 变动类型 + */ + private String type; + /** + * 积分变动的原因,用于记录变动的具体原因或业务场景 + */ + private String changeReason; + /** + * 店铺ID + */ + private Integer storeId; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建人 + */ + private String createBy; + /** + * 更新人 + */ + private String updateBy; + + + + + + + + + + + + + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralSettings.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralSettings.java index e99cc10a0..ca3930614 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralSettings.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralSettings.java @@ -44,7 +44,7 @@ public class IntegralSettings extends BaseEntity { /** * 加油消费金额 */ - private Double refuelConsumptionAmount; + private String refuelConsumptionAmount; /** * 加油积分 */ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/IntegralDetailMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/IntegralDetailMapper.java new file mode 100644 index 000000000..822c673b4 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/IntegralDetailMapper.java @@ -0,0 +1,85 @@ +package com.fuint.business.integral.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.integral.entity.IntegralDetail; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; +import java.util.List; + +/** + * 积分明细表(IntegralDetail)表数据库访问层 + * + * @author wangh + * @since 2023-11-10 17:52:33 + */ +public interface IntegralDetailMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + IntegralDetail queryById(Integer id); + + /** + * 查询指定行数据 + * + * @param integralDetail 查询条件 + * @param page 分页对象 + * @return 对象列表 + */ + IPage queryAllByLimit(@Param("page") Page page, IntegralDetail integralDetail); + + /** + * 统计总行数 + * + * @param integralDetail 查询条件 + * @return 总行数 + */ + long count(IntegralDetail integralDetail); + + /** + * 新增数据 + * + * @param integralDetail 实例对象 + * @return 影响行数 + */ + int insert(IntegralDetail integralDetail); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param integralDetail 实例对象 + * @return 影响行数 + */ + int update(IntegralDetail integralDetail); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml new file mode 100644 index 000000000..5c7ebbc8c --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into integral_detail(user_id, points_change, current_points, type, change_reason, store_id, create_time, update_time, create_by, update_by) + values (#{userId}, #{pointsChange}, #{currentPoints}, #{type}, #{changeReason}, #{storeId}, #{createTime}, #{createTime}, #{createBy}, #{updateBy}) + + + + insert into integral_detail(user_id, points_change, current_points, type, change_reason, store_id, create_time, update_time, create_by, update_by) + values + + (#{entity.userId}, #{entity.pointsChange}, #{entity.currentPoints}, #{entity.type}, #{entity.changeReason}, #{entity.storeId}, #{entity.createTime}, #{entity.updateTime}, #{entity.createBy}, #{entity.updateBy}) + + + + + insert into integral_detail(user_id, points_change, current_points, type, change_reason, store_id, create_time, update_time, create_by, update_by) + values + + (#{entity.userId}, #{entity.pointsChange}, #{entity.currentPoints}, #{entity.type}, #{entity.changeReason}, #{entity.storeId}, #{entity.createTime}, #{entity.updateTime}, #{entity.createBy}, #{entity.updateBy}) + + on duplicate key update + user_id = values(user_id), + points_change = values(points_change), + current_points = values(current_points), + type = values(type), + change_reason = values(change_reason), + store_id = values(store_id), + create_time = values(create_time), + update_time = values(update_time), + create_by = values(create_by), + update_by = values(update_by) + + + + + update integral_detail + + + user_id = #{userId}, + + + points_change = #{pointsChange}, + + + current_points = #{currentPoints}, + + + type = #{type}, + + + change_reason = #{changeReason}, + + + store_id = #{storeId}, + + + + update_time = NOW(), + + + create_by = #{createBy}, + + + update_by = #{updateBy}, + + + where id = #{id} + + + + + delete from integral_detail where id = #{id} + + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralSettingsMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralSettingsMapper.xml index d9924a2e1..c61069ce9 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralSettingsMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralSettingsMapper.xml @@ -10,7 +10,7 @@ - + @@ -125,7 +125,7 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/OilNumberService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/OilNumberService.java index 1497854b8..f0d5d28a5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/OilNumberService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/OilNumberService.java @@ -49,9 +49,9 @@ public interface OilNumberService extends IService { public int updateOilNumber(OilNumber oilNumber); - public List getOilName(); + List getOilName(); - public OilNumber selectOilNameByStore(OilNumber oilNumber); + OilNumber selectOilNameByStore(OilNumber oilNumber); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilPresetPricesServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilPresetPricesServiceImpl.java index 4246a8816..4c80ee89d 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilPresetPricesServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilPresetPricesServiceImpl.java @@ -126,10 +126,9 @@ public class OilPresetPricesServiceImpl extends ServiceImpl