This commit is contained in:
cun-nan 2024-01-22 10:09:43 +08:00
parent 1d09b0b4c2
commit 196d7f41ad
7 changed files with 271 additions and 4 deletions

View File

@ -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<GrowthValueChange> list = growthValueChangeService.selectGrowthValueChangeList(page,growthValueChange);
return getSuccessResult(list);
}
}

View File

@ -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;
}

View File

@ -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<GrowthValueChange> {
/**
* 根据条件分页查询成长值变化记录信息
* @param page
* @param growthValueChange
* @return
*/
public IPage<GrowthValueChange> selectGrowthValueChangeList(@Param("page") Page page,@Param("growthValueChange") GrowthValueChange growthValueChange);
}

View File

@ -0,0 +1,12 @@
<?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="com.fuint.business.order.mapper.GrowthValueChangeMapper">
<select id="selectGrowthValueChangeList" resultType="com.fuint.business.order.entity.GrowthValueChange">
select * from growth_value_change
<where>
<if test="growthValueChange.storeId != null and growthValueChange.storeId != ''">
and store_id = #{growthValueChange.storeId}
</if>
</where>
</select>
</mapper>

View File

@ -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<GrowthValueChange> 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);
}

View File

@ -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<GrowthValueChangeMapper, GrowthValueChange> implements GrowthValueChangeService {
@Override
public IPage<GrowthValueChange> 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);
}
}

View File

@ -339,7 +339,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> 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<OilOrderMapper, OilOrder> 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<RefuelMoney> list = new ArrayList<>();
@ -827,6 +834,53 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
}
balance.setRefuelMoney(JSONObject.toJSONString(list));
}
// 查询会员等级列表信息
Page page = new Page(1,20);
LJUserGrade ljUserGrade1 = new LJUserGrade();
List<LJUserGrade> 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<OilOrderMapper, OilOrder> 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<OilOrderMapper, OilOrder> 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<OilOrderMapper, OilOrder> 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<OilOrderMapper, OilOrder> 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);
}
}