diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/controller/AccInfoController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/controller/AccInfoController.java index 73ebe0e..dd28856 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/controller/AccInfoController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/controller/AccInfoController.java @@ -4,6 +4,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit; +import com.bonus.system.api.domain.SysUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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()); + } + } + /** * 修改账户资料 */ diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccStatusEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccStatusEnum.java new file mode 100644 index 0000000..0ae15fe --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccStatusEnum.java @@ -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 sendMqStatus() { + return Arrays.asList(DEACTIVATE.getKey(), OVERDUE.getKey()); + } + + public static List 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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccWalletIdEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccWalletIdEnum.java new file mode 100644 index 0000000..3a089de --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/enums/AccWalletIdEnum.java @@ -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; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/mapper/AccWalletInfoMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/mapper/AccWalletInfoMapper.java index a5062e5..91997df 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/mapper/AccWalletInfoMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/mapper/AccWalletInfoMapper.java @@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.mapper; import java.util.List; import com.bonus.canteen.core.account.domain.AccWalletInfo; +import org.apache.ibatis.annotations.Param; /** * 钱包详情信息Mapper接口 @@ -34,6 +35,8 @@ public interface AccWalletInfoMapper { */ public int insertAccWalletInfo(AccWalletInfo accWalletInfo); + public int batchInsertAccWalletInfo(@Param("list") List accWalletInfos); + /** * 修改钱包详情信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccInfoService.java index 08d72d8..7095f9b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccInfoService.java @@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.service; import java.util.List; import com.bonus.canteen.core.account.domain.AccInfo; +import com.bonus.system.api.domain.SysUser; /** * 账户资料Service接口 @@ -57,4 +58,6 @@ public interface IAccInfoService { * @return 结果 */ public int deleteAccInfoById(Long id); + + public int syncAccInfo(SysUser sysUser); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccWalletInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccWalletInfoService.java index 1fe78a5..d172628 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccWalletInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/IAccWalletInfoService.java @@ -34,6 +34,8 @@ public interface IAccWalletInfoService { */ public int insertAccWalletInfo(AccWalletInfo accWalletInfo); + public int batchInsertAccWalletInfo(List accWalletInfos); + /** * 修改钱包详情信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccInfoServiceImpl.java index 2be372f..a910fc6 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccInfoServiceImpl.java @@ -1,13 +1,25 @@ package com.bonus.canteen.core.account.service.impl; +import java.util.ArrayList; +import java.util.Date; 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.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.stereotype.Service; import com.bonus.canteen.core.account.mapper.AccInfoMapper; import com.bonus.canteen.core.account.domain.AccInfo; import com.bonus.canteen.core.account.service.IAccInfoService; +import org.springframework.transaction.annotation.Transactional; /** * 账户资料Service业务层处理 @@ -19,6 +31,8 @@ import com.bonus.canteen.core.account.service.IAccInfoService; public class AccInfoServiceImpl implements IAccInfoService { @Autowired private AccInfoMapper accInfoMapper; + @Autowired + private IAccWalletInfoService accWalletInfoService; /** * 查询账户资料 @@ -95,4 +109,28 @@ public class AccInfoServiceImpl implements IAccInfoService { public int deleteAccInfoById(Long 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 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); + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccWalletInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccWalletInfoServiceImpl.java index 8cce7ca..938e31f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccWalletInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/account/service/impl/AccWalletInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.bonus.canteen.core.account.service.impl; import java.util.List; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper; @@ -58,6 +59,16 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService { } } + @Override + public int batchInsertAccWalletInfo(List accWalletInfos) { + accWalletInfos.stream().forEach(o -> o.setCreateBy(SecurityUtils.getUsername())); + try { + return accWalletInfoMapper.batchInsertAccWalletInfo(accWalletInfos); + } catch (Exception e) { + throw new ServiceException("错误信息描述"); + } + } + /** * 修改钱包详情信息 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccInfoMapper.xml index f19a95a..d280e48 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccInfoMapper.xml @@ -124,10 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into acc_info - acc_id, acc_name, user_id, wallet_bal, @@ -182,7 +181,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_time, - #{accId}, #{accName}, #{userId}, #{walletBal}, diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccWalletInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccWalletInfoMapper.xml index 8367406..279eca9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccWalletInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/account/AccWalletInfoMapper.xml @@ -75,6 +75,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + 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 + + (#{item.userId},#{item.accId},#{item.walletId},#{item.walletBal},#{item.limitBalance},#{item.frozenBalance}, + #{item.expiredTime},#{item.lastSubsidyAmount},#{item.lastSubsidyTime}, + #{item.createBy},NOW()) + + + update acc_wallet_info