diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/GrowthValueChangeController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/GrowthValueChangeController.java new file mode 100644 index 000000000..f466a09ff --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/GrowthValueChangeController.java @@ -0,0 +1,37 @@ +package com.fuint.business.order.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.order.entity.GrowthValueChange; +import com.fuint.business.order.entity.LJOrder; +import com.fuint.business.order.service.GrowthValueChangeService; +import com.fuint.framework.web.BaseController; +import com.fuint.framework.web.ResponseObject; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@RestController +@RequestMapping("/business/growthValueChange") +public class GrowthValueChangeController extends BaseController { + @Autowired + private GrowthValueChangeService growthValueChangeService; + + /** + * 根据条件分页查询会员信息 + * @param growthValueChange + * @param pageNo + * @param pageSize + * @return + */ + @GetMapping("/list") + public ResponseObject list(GrowthValueChange growthValueChange, + @RequestParam(value = "page",defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){ + Page page =new Page(pageNo,pageSize); + IPage list = growthValueChangeService.selectGrowthValueChangeList(page,growthValueChange); + return getSuccessResult(list); + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/GrowthValueChange.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/GrowthValueChange.java new file mode 100644 index 000000000..addb64bf7 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/GrowthValueChange.java @@ -0,0 +1,63 @@ +package com.fuint.business.order.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fuint.framework.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * 成长值变化记录表(GrowthValueChange)实体类 + */ +@Data +@TableName("growth_value_change") +@ApiModel(value = "GrowthValueChange对象", description = "成长值变化记录表") +public class GrowthValueChange extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 自增ID + */ + @ApiModelProperty("自增ID") + @TableId(value = "ID", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + private Integer userId; + /** + * 连锁店id + */ + private Integer chainStoreId; + /** + * 油站id + */ + private Integer storeId; + /** + * 余额变化类型 0:-减少 1:增加 + */ + private String changeType; + /** + * 消费来源 + */ + private String fromType; + /** + * 成长值变化值 + */ + private Double growthValue; + /** + * 变化之后的成长值 + */ + private Double afterTheChange; + /** + * 订单号 + */ + private String orderNo; + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/GrowthValueChangeMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/GrowthValueChangeMapper.java new file mode 100644 index 000000000..933b422bd --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/GrowthValueChangeMapper.java @@ -0,0 +1,17 @@ +package com.fuint.business.order.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.order.entity.GrowthValueChange; +import org.apache.ibatis.annotations.Param; + +public interface GrowthValueChangeMapper extends BaseMapper { + /** + * 根据条件分页查询成长值变化记录信息 + * @param page + * @param growthValueChange + * @return + */ + public IPage selectGrowthValueChangeList(@Param("page") Page page,@Param("growthValueChange") GrowthValueChange growthValueChange); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/GrowthValueChangeMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/GrowthValueChangeMapper.xml new file mode 100644 index 000000000..08a41b378 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/GrowthValueChangeMapper.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/GrowthValueChangeService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/GrowthValueChangeService.java new file mode 100644 index 000000000..4bcf65c63 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/GrowthValueChangeService.java @@ -0,0 +1,36 @@ +package com.fuint.business.order.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.order.entity.GrowthValueChange; + +public interface GrowthValueChangeService { + /** + * 根据条件分页查询成长值变化记录信息 + * @param page + * @param growthValueChange + * @return + */ + public IPage selectGrowthValueChangeList(Page page, GrowthValueChange growthValueChange); + + /** + * 根据id查询成长值变化记录信息 + * @param id + * @return + */ + public GrowthValueChange selectGrowthValueChangeById(int id); + + /** + * 添加成长值变化记录信息 + * @param growthValueChange + * @return + */ + public int insertGrowthValueChange(GrowthValueChange growthValueChange); + + /** + * 修改成长值变化记录信息 + * @param growthValueChange + * @return + */ + public int updateGrowthValueChange(GrowthValueChange growthValueChange); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/GrowthValueChangeServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/GrowthValueChangeServiceImpl.java new file mode 100644 index 000000000..54e6c6154 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/GrowthValueChangeServiceImpl.java @@ -0,0 +1,36 @@ +package com.fuint.business.order.service.impl; + +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.order.entity.GrowthValueChange; +import com.fuint.business.order.mapper.GrowthValueChangeMapper; +import com.fuint.business.order.service.GrowthValueChangeService; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; +import org.springframework.stereotype.Service; + +@Service +public class GrowthValueChangeServiceImpl extends ServiceImpl implements GrowthValueChangeService { + @Override + public IPage selectGrowthValueChangeList(Page page, GrowthValueChange growthValueChange) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + growthValueChange.setStoreId(nowAccountInfo.getStoreId()); + return baseMapper.selectGrowthValueChangeList(page,growthValueChange); + } + + @Override + public GrowthValueChange selectGrowthValueChangeById(int id) { + return baseMapper.selectById(id); + } + + @Override + public int insertGrowthValueChange(GrowthValueChange growthValueChange) { + return baseMapper.insert(growthValueChange); + } + + @Override + public int updateGrowthValueChange(GrowthValueChange growthValueChange) { + return baseMapper.updateById(growthValueChange); + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index 71d4fce0c..c4509a762 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -339,7 +339,7 @@ public class OilOrderServiceImpl extends ServiceImpl i } if (userId!=null){ - this.updateGrowthValue(oilActualPay, userId, Integer.valueOf(jsonObjects.get(i).get("oilName").toString()),refuelMoney,storeId,orderNo); + this.updateGrowthValue(oilAmount,oilActualPay, userId, Integer.valueOf(jsonObjects.get(i).get("oilName").toString()),refuelMoney,storeId,orderNo); } order.setStoreId(storeId); order.setUserId(userId); @@ -807,8 +807,15 @@ public class OilOrderServiceImpl extends ServiceImpl i * @param refuelMoney 扣除的囤油卡升数 */ private void updateGrowthValue1(Double oilActualPay,Integer userid,Integer oilId,Double refuelMoney,Integer storeId,String orderNo){ + OilName oilName = oilNameService.selectOilNameById(oilId); +// 获取成长值增长数值 + Integer gasGrowthValue = null; + Integer dieselGrowthValue = null; + Integer naturalGrowthValue = null; + LJStore store = storeService.selectStoreByStoreId(storeId); UserBalance balance = userBalanceService.selectUserBalance(userid,store.getChainStoreId()); + int growth = balance.getGrowthValue(); JSONArray refuelMoneys = JSONArray.parseArray(balance.getRefuelMoney()); if (ObjectUtil.isNotEmpty(refuelMoneys)){ List list = new ArrayList<>(); @@ -827,6 +834,53 @@ public class OilOrderServiceImpl extends ServiceImpl i } balance.setRefuelMoney(JSONObject.toJSONString(list)); } + // 查询会员等级列表信息 + Page page = new Page(1,20); + LJUserGrade ljUserGrade1 = new LJUserGrade(); + List records = userGradeService.selectUserGradeAll(storeId); + if (oilName.getOilType().equals("汽油")){ + gasGrowthValue = Integer.valueOf(sysConfigService.getValueByKey("gas_growth_value")); + Integer addVal = (int) (gasGrowthValue * oilActualPay); + Integer growthAfter = growth + addVal; +// 如果会员成长值达到会员等级成长值,则修改会员的会员等级信息 + for (int i = 0; i < records.size(); i++){ + if ((growthAfter-records.get(i).getGrowthValue())<100){ + balance.setGradeId(records.get(i).getId()); + } + if (growthAfter>records.get(records.size()-1).getGrowthValue()){ + balance.setGradeId(records.get(records.size()-1).getId()); + } + } + balance.setGrowthValue(growthAfter); + }else if(oilName.getOilType().equals("柴油")){ + dieselGrowthValue = Integer.valueOf(sysConfigService.getValueByKey("diesel_growth_value")); + Integer addVal = (int) (dieselGrowthValue * oilActualPay); + Integer growthAfter = growth + addVal; +// 如果会员成长值达到会员等级成长值,则修改会员的会员等级信息 + for (int i = 0; i < records.size(); i++){ + if ((growthAfter-records.get(i).getGrowthValue())<100 && (growthAfter-records.get(i).getGrowthValue())>0){ + balance.setGradeId(records.get(i).getId()); + } + if (growthAfter > records.get(records.size()-1).getGrowthValue()){ + balance.setGradeId(records.get(records.size()-1).getId()); + } + } + balance.setGrowthValue(growthAfter); + }else{ + naturalGrowthValue = Integer.valueOf(sysConfigService.getValueByKey("natural_growth_value")); + Integer addVal = (int) (naturalGrowthValue * oilActualPay); + Integer growthAfter = growth + addVal; +// 如果会员成长值达到会员等级成长值,则修改会员的会员等级信息 + for (int i = 0; i < records.size(); i++){ + if ((growthAfter-records.get(i).getGrowthValue())<100){ + balance.setGradeId(records.get(i).getId()); + } + if (growthAfter>records.get(records.size()-1).getGrowthValue()){ + balance.setGradeId(records.get(records.size()-1).getId()); + } + } + balance.setGrowthValue(growthAfter); + } // balance.setCardBalance(balance.getCardBalance()-oilActualPay); userBalanceService.updateUserBalance(balance); this.insertCardBalance(oilActualPay,userid,storeId,orderNo); @@ -1009,7 +1063,7 @@ public class OilOrderServiceImpl extends ServiceImpl i e.printStackTrace(); } }else { - this.updateGrowthValue(payAmount,userId, Integer.valueOf(oilOrder.getOils()),oilCardAmount,oilOrder.getStoreId(),orderNo); + this.updateGrowthValue(oilOrder.getOrderAmount(),payAmount,userId, Integer.valueOf(oilOrder.getOils()),oilCardAmount,oilOrder.getStoreId(),orderNo); this.addOilTracks(oilOrder,oilOrder.getStoreId()); this.insertCardOrder(oilOrder.getUserId(),oilOrder.getStoreId(),orderNo,oilOrder.getOrderAmount(),"paid", Double.valueOf(balanceAmount),payAmount); staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getOrderAmount(),oilOrder.getOilNum(),"1",orderNo); @@ -1081,7 +1135,7 @@ public class OilOrderServiceImpl extends ServiceImpl i CardValudChildrens cardValudChildrens = cardValudChildrensService.selectCardValueChildrenByMobileAndStoreId(user.getMobile(), oilOrder.getStoreId()); userId = cardValudChildrens.getUserId(); } - this.updateGrowthValue(oilOrder.getPayAmount(),userId, Integer.valueOf(oilOrder.getOils()),null,oilOrder.getStoreId(),orderNo); + this.updateGrowthValue(oilOrder.getOrderAmount(),oilOrder.getPayAmount(),userId, Integer.valueOf(oilOrder.getOils()),null,oilOrder.getStoreId(),orderNo); this.addOilTracks(oilOrder,oilOrder.getStoreId()); staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"1",orderNo); @@ -1185,7 +1239,7 @@ public class OilOrderServiceImpl extends ServiceImpl i * @param refuelMoney 消费后的加油金信息 * @param storeId 店铺id */ - private void updateGrowthValue(Double oilActualPay,Integer userid,Integer oilId,String refuelMoney,Integer storeId,String orderNo){ + private void updateGrowthValue(Double oilAmount,Double oilActualPay,Integer userid,Integer oilId,String refuelMoney,Integer storeId,String orderNo){ if (oilId!=null){ OilName oilName = oilNameService.selectOilNameById(oilId); // 获取成长值增长数值 @@ -1270,7 +1324,19 @@ public class OilOrderServiceImpl extends ServiceImpl i balance.setGrowthValue(growthAfter); } // 修改用户成长值 + Integer consumeNum = balance.getConsumeNum(); + balance.setConsumeNum(consumeNum+1); userBalanceService.updateUserBalance(balance); + + CardBalanceChange cardBalanceChange = new CardBalanceChange(); +// 添加余额记录信息 + cardBalanceChange.setUserId(userid); + cardBalanceChange.setChangeType("0"); + cardBalanceChange.setFromType("油品订单消费"); + cardBalanceChange.setBalance(oilAmount - oilActualPay); + cardBalanceChange.setOrderNo(orderNo); + + cardBalanceChangeService.insertCardBalance(cardBalanceChange); } }