同步建立账户
This commit is contained in:
parent
37cfbac708
commit
09f1423d82
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
|
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
|
||||||
|
import com.bonus.system.api.domain.SysUser;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -89,6 +90,22 @@ public class AccInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增账户资料
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增账户资料")
|
||||||
|
//@PreventRepeatSubmit
|
||||||
|
//@RequiresPermissions("account:info:add")
|
||||||
|
@SysLog(title = "账户资料", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增账户资料")
|
||||||
|
@PostMapping("sync")
|
||||||
|
public AjaxResult syncAccInfo(@RequestBody SysUser sysUser) {
|
||||||
|
try {
|
||||||
|
return toAjax(accInfoService.syncAccInfo(sysUser));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改账户资料
|
* 修改账户资料
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.bonus.canteen.core.account.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum AccStatusEnum {
|
||||||
|
NORMAL(1, "正常"),
|
||||||
|
DEACTIVATE(2, "停用"),
|
||||||
|
CANCEL(3, "注销"),
|
||||||
|
OVERDUE(4, "过期");
|
||||||
|
|
||||||
|
private final Integer key;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
private AccStatusEnum(Integer key, String desc) {
|
||||||
|
this.key = key;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDesc(Integer key) {
|
||||||
|
AccStatusEnum[] var1 = values();
|
||||||
|
int var2 = var1.length;
|
||||||
|
|
||||||
|
for(int var3 = 0; var3 < var2; ++var3) {
|
||||||
|
AccStatusEnum temp = var1[var3];
|
||||||
|
if (temp.getKey().equals(key)) {
|
||||||
|
return temp.getDesc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccStatusEnum getEnum(Integer key) {
|
||||||
|
AccStatusEnum[] var1 = values();
|
||||||
|
int var2 = var1.length;
|
||||||
|
|
||||||
|
for(int var3 = 0; var3 < var2; ++var3) {
|
||||||
|
AccStatusEnum temp = var1[var3];
|
||||||
|
if (temp.getKey().equals(key)) {
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Integer> sendMqStatus() {
|
||||||
|
return Arrays.asList(DEACTIVATE.getKey(), OVERDUE.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Integer> accStatusForAppWork() {
|
||||||
|
return ListUtil.toList(new Integer[]{NORMAL.getKey(), DEACTIVATE.getKey(), OVERDUE.getKey()});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean ifNotAllowRechargeRepeal(Integer key) {
|
||||||
|
return ListUtil.toList(new Integer[]{CANCEL.getKey()}).contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getKey() {
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return this.desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.bonus.canteen.core.account.enums;
|
||||||
|
|
||||||
|
public enum AccWalletIdEnum {
|
||||||
|
WALLET(1, "个人钱包"),
|
||||||
|
SUBSIDY(2, "补贴钱包");
|
||||||
|
//LUCK_MONEY(4, "红包");
|
||||||
|
|
||||||
|
private final Integer key;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
private AccWalletIdEnum(Integer key, String desc) {
|
||||||
|
this.key = key;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getKey() {
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return this.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 钱包详情信息Mapper接口
|
* 钱包详情信息Mapper接口
|
||||||
|
|
@ -34,6 +35,8 @@ public interface AccWalletInfoMapper {
|
||||||
*/
|
*/
|
||||||
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
|
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
|
||||||
|
|
||||||
|
public int batchInsertAccWalletInfo(@Param("list") List<AccWalletInfo> accWalletInfos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改钱包详情信息
|
* 修改钱包详情信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.account.domain.AccInfo;
|
import com.bonus.canteen.core.account.domain.AccInfo;
|
||||||
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户资料Service接口
|
* 账户资料Service接口
|
||||||
|
|
@ -57,4 +58,6 @@ public interface IAccInfoService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteAccInfoById(Long id);
|
public int deleteAccInfoById(Long id);
|
||||||
|
|
||||||
|
public int syncAccInfo(SysUser sysUser);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ public interface IAccWalletInfoService {
|
||||||
*/
|
*/
|
||||||
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
|
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
|
||||||
|
|
||||||
|
public int batchInsertAccWalletInfo(List<AccWalletInfo> accWalletInfos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改钱包详情信息
|
* 修改钱包详情信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,25 @@
|
||||||
package com.bonus.canteen.core.account.service.impl;
|
package com.bonus.canteen.core.account.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
||||||
|
import com.bonus.canteen.core.account.enums.AccStatusEnum;
|
||||||
|
import com.bonus.canteen.core.account.enums.AccWalletIdEnum;
|
||||||
|
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
||||||
|
import com.bonus.common.houqin.mq.util.MqUtil;
|
||||||
|
import com.bonus.common.houqin.utils.id.Id;
|
||||||
|
import com.bonus.system.api.domain.SysUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.bonus.canteen.core.account.mapper.AccInfoMapper;
|
import com.bonus.canteen.core.account.mapper.AccInfoMapper;
|
||||||
import com.bonus.canteen.core.account.domain.AccInfo;
|
import com.bonus.canteen.core.account.domain.AccInfo;
|
||||||
import com.bonus.canteen.core.account.service.IAccInfoService;
|
import com.bonus.canteen.core.account.service.IAccInfoService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户资料Service业务层处理
|
* 账户资料Service业务层处理
|
||||||
|
|
@ -19,6 +31,8 @@ import com.bonus.canteen.core.account.service.IAccInfoService;
|
||||||
public class AccInfoServiceImpl implements IAccInfoService {
|
public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccInfoMapper accInfoMapper;
|
private AccInfoMapper accInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private IAccWalletInfoService accWalletInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询账户资料
|
* 查询账户资料
|
||||||
|
|
@ -95,4 +109,28 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
public int deleteAccInfoById(Long id) {
|
public int deleteAccInfoById(Long id) {
|
||||||
return accInfoMapper.deleteAccInfoById(id);
|
return accInfoMapper.deleteAccInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(
|
||||||
|
rollbackFor = {Exception.class}
|
||||||
|
)
|
||||||
|
public int syncAccInfo(SysUser sysUser) {
|
||||||
|
AccInfo accInfo = new AccInfo();
|
||||||
|
accInfo.setAccStatus(AccStatusEnum.NORMAL.getKey().longValue());
|
||||||
|
accInfo.setUserId(sysUser.getUserId());
|
||||||
|
accInfoMapper.insertAccInfo(accInfo);
|
||||||
|
List<AccWalletInfo> accWalletInfos = new ArrayList();
|
||||||
|
AccWalletIdEnum[] accWalletIdEnums = AccWalletIdEnum.values();
|
||||||
|
|
||||||
|
for(int i = 0; i < accWalletIdEnums.length; ++i) {
|
||||||
|
AccWalletIdEnum accWalletIdEnum = accWalletIdEnums[i];
|
||||||
|
AccWalletInfo accWalletInfo = new AccWalletInfo();
|
||||||
|
accWalletInfo.setAccId(accInfo.getAccId());
|
||||||
|
accWalletInfo.setUserId(sysUser.getUserId());
|
||||||
|
accWalletInfo.setWalletId(accWalletIdEnum.getKey().longValue());
|
||||||
|
accWalletInfos.add(accWalletInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//MqUtil.sendDataChange(sysUser.getUserId(), LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
|
||||||
|
return this.accWalletInfoService.batchInsertAccWalletInfo(accWalletInfos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.account.service.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper;
|
import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper;
|
||||||
|
|
@ -58,6 +59,16 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchInsertAccWalletInfo(List<AccWalletInfo> accWalletInfos) {
|
||||||
|
accWalletInfos.stream().forEach(o -> o.setCreateBy(SecurityUtils.getUsername()));
|
||||||
|
try {
|
||||||
|
return accWalletInfoMapper.batchInsertAccWalletInfo(accWalletInfos);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("错误信息描述");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改钱包详情信息
|
* 修改钱包详情信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -124,10 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertAccInfo" parameterType="com.bonus.canteen.core.account.domain.AccInfo" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertAccInfo" parameterType="com.bonus.canteen.core.account.domain.AccInfo" useGeneratedKeys="true" keyProperty="accId">
|
||||||
insert into acc_info
|
insert into acc_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="accId != null">acc_id,</if>
|
|
||||||
<if test="accName != null and accName != ''">acc_name,</if>
|
<if test="accName != null and accName != ''">acc_name,</if>
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
<if test="walletBal != null">wallet_bal,</if>
|
<if test="walletBal != null">wallet_bal,</if>
|
||||||
|
|
@ -182,7 +181,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="accId != null">#{accId},</if>
|
|
||||||
<if test="accName != null and accName != ''">#{accName},</if>
|
<if test="accName != null and accName != ''">#{accName},</if>
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
<if test="walletBal != null">#{walletBal},</if>
|
<if test="walletBal != null">#{walletBal},</if>
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="batchInsertAccWalletInfo" parameterType="com.bonus.canteen.core.account.domain.AccWalletInfo">
|
||||||
|
insert into acc_wallet_info(user_id,acc_id,wallet_id,wallet_bal,limit_balance,frozen_balance,
|
||||||
|
expired_time,last_subsidy_amount,last_subsidy_time,
|
||||||
|
create_by,create_time) values
|
||||||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
|
(#{item.userId},#{item.accId},#{item.walletId},#{item.walletBal},#{item.limitBalance},#{item.frozenBalance},
|
||||||
|
#{item.expiredTime},#{item.lastSubsidyAmount},#{item.lastSubsidyTime},
|
||||||
|
#{item.createBy},NOW())
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateAccWalletInfo" parameterType="com.bonus.canteen.core.account.domain.AccWalletInfo">
|
<update id="updateAccWalletInfo" parameterType="com.bonus.canteen.core.account.domain.AccWalletInfo">
|
||||||
update acc_wallet_info
|
update acc_wallet_info
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue