Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2025-04-08 18:14:08 +08:00
commit 3f099d8951
60 changed files with 2004 additions and 261 deletions

View File

@ -6,6 +6,8 @@ package com.bonus.common.houqin.constant;
*/
public class GlobalConstants {
public static final Long TENANT_ID = 99999999L;
public static final String PERSONAL_RECHARGE = "PERSONAL_RECHARGE";
/**
* 字符串 MSIE
*/

View File

@ -0,0 +1,37 @@
package com.bonus.canteen.core.account.constants;
import java.util.*;
import java.util.stream.Collectors;
public enum AccStatusEnum {
NORMAL(0, "正常"),
DEACTIVATE(1, "停用");
private final Integer key;
private final String desc;
private static final Map<Integer, AccStatusEnum> ENUM_MAP = Arrays.stream(values())
.collect(Collectors.toMap(AccStatusEnum::getKey, e -> e));
private AccStatusEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public static String getDesc(Integer key) {
AccStatusEnum enumValue = ENUM_MAP.get(key);
return enumValue != null ? enumValue.getDesc() : "";
}
public static AccStatusEnum getEnum(Integer key) {
return ENUM_MAP.get(key);
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,26 @@
package com.bonus.canteen.core.account.constants;
import cn.hutool.core.collection.ListUtil;
public enum AccTradeStateEnum {
CREATE(1, "待生效"),
TAKE_EFFECT(2, "生效"),
CANCELED(3, "已撤销"),
CLOSE(4, "关闭");
private final Integer key;
private final String desc;
private AccTradeStateEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,36 @@
package com.bonus.canteen.core.account.constants;
public enum AccTradeTypeEnum {
RECHARGE(10, "充值"),
RECHARGE_GIFT(11, "赠送"),
REVOKE_RECHARGE_GIFT(12, "撤销赠送"),
REVOKE_RECHARGE(40, "撤销充值"),
SUBSIDY(20, "补贴"),
REVOKE_SUBSIDY(50, "撤销补贴"),
CLEAR(100, "清空"),
LUCK_MONEY(140, "红包发放"),
WITHDRAW(30, "提现"),
TRANSFER_OUT(60, "转出"),
TRANSFER_IN(70, "转入"),
FREEZE(80, "冻结"),
UN_FREEZE(90, "解冻"),
CONSUME(110, "消费"),
CONSUME_REPAIR(120, "消费补扣"),
CONSUME_REFUND(130, "消费退款");
private final Integer key;
private final String desc;
private AccTradeTypeEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,59 @@
package com.bonus.canteen.core.account.constants;
import cn.hutool.core.collection.ListUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum AccWalletIdEnum {
WALLET(1, "个人钱包"),
SUBSIDY(2, "补贴钱包");
private final Integer key;
private final String desc;
// 使用 Map 提升查找效率
private static final Map<Integer, AccWalletIdEnum> ENUM_MAP = Arrays.stream(values())
.collect(Collectors.toMap(AccWalletIdEnum::getKey, Function.identity()));
private AccWalletIdEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public static String getDesc(Integer key) {
AccWalletIdEnum enumValue = ENUM_MAP.get(key);
return enumValue != null ? enumValue.getDesc() : "";
}
public static AccWalletIdEnum getEnum(Integer key) {
return ENUM_MAP.get(key);
}
public static Map<Integer, AccWalletIdEnum> getEnumMap() {
return ENUM_MAP;
}
public static List<Integer> checkAccCancelWallet() {
return Arrays.asList(WALLET.getKey(), SUBSIDY.getKey());
}
public static String getAllWalletId() {
return StringUtils.join(getAllWalletIdList(), ",");
}
public static List<Integer> getAllWalletIdList() {
return Arrays.stream(values())
.map(AccWalletIdEnum::getKey)
.collect(Collectors.toList());
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -2,28 +2,36 @@ package com.bonus.canteen.core.account.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.bonus.canteen.core.account.domain.AccInfo;
import com.bonus.canteen.core.account.domain.param.AccOperationQueryParam;
import com.bonus.canteen.core.account.domain.param.AccountBalanceEditParam;
import com.bonus.canteen.core.account.domain.param.AccountEnableDisableParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.service.AccOperationHistoryService;
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;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.account.domain.AccInfo;
import com.bonus.canteen.core.account.service.IAccInfoService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
import static com.bonus.common.core.web.domain.AjaxResult.success;
/**
* 账户资料Controller
*
@ -36,6 +44,8 @@ import com.bonus.common.core.web.page.TableDataInfo;
public class AccInfoController extends BaseController {
@Autowired
private IAccInfoService accInfoService;
@Autowired
private AccOperationHistoryService accOperationHistoryService;
/**
* 查询账户资料列表
@ -43,10 +53,9 @@ public class AccInfoController extends BaseController {
@ApiOperation(value = "查询账户资料列表")
//@RequiresPermissions("account:info:list")
@GetMapping("/list")
public TableDataInfo list(AccInfo accInfo) {
public TableDataInfo list(AccountInfoQueryParam accountInfoQueryParam) {
startPage();
List<AccInfo> list = accInfoService.selectAccInfoList(accInfo);
return getDataTable(list);
return getDataTable(accInfoService.selectAccInfoList(accountInfoQueryParam));
}
/**
@ -57,9 +66,9 @@ public class AccInfoController extends BaseController {
//@RequiresPermissions("account:info:export")
@SysLog(title = "账户资料", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出账户资料")
@PostMapping("/export")
public void export(HttpServletResponse response, AccInfo accInfo) {
List<AccInfo> list = accInfoService.selectAccInfoList(accInfo);
ExcelUtil<AccInfo> util = new ExcelUtil<AccInfo>(AccInfo.class);
public void export(HttpServletResponse response, AccountInfoQueryParam accountInfoQueryParam) {
List<AccInfoDetailsVO> list = accInfoService.selectAccInfoList(accountInfoQueryParam);
ExcelUtil<AccInfoDetailsVO> util = new ExcelUtil<>(AccInfoDetailsVO.class);
util.exportExcel(response, list, "账户资料数据");
}
@ -90,21 +99,34 @@ public class AccInfoController extends BaseController {
}
/**
* 修改账户资料
* 新增账户资料
*/
@ApiOperation(value = "修改账户资料")
@ApiOperation(value = "新增账户资料")
//@PreventRepeatSubmit
//@RequiresPermissions("account:info:edit")
@SysLog(title = "账户资料", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改账户资料")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody AccInfo accInfo) {
//@RequiresPermissions("account:info:add")
@SysLog(title = "账户资料", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增账户资料")
@PostMapping("sync")
public AjaxResult syncAccInfo(@RequestBody SysUser sysUser) {
try {
return toAjax(accInfoService.updateAccInfo(accInfo));
return toAjax(accInfoService.syncAccInfo(sysUser));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 修改账户资料
*/
// @ApiOperation(value = "修改账户余额以及有效期")
// //@PreventRepeatSubmit
// //@RequiresPermissions("account:info:edit")
// @SysLog(title = "账户资料", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改账户资料")
// @PostMapping("/balance/edit")
// public AjaxResult edit(@RequestBody AccountBalanceEditParam accountBalanceEditParam) {
// this.accInfoService.updateAccInfo(accountBalanceEditParam);
// return AjaxResult.success();
// }
/**
* 删除账户资料
*/
@ -116,4 +138,55 @@ public class AccInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(accInfoService.deleteAccInfoByIds(ids));
}
// @ApiOperation("账户注销/过期数量")
// @PostMapping({"/invalid/sum"})
// public AjaxResult queryAccInfoExpiredCount() {
// return AjaxResult.success(this.accInfoService.queryAccInfoInvalidSum());
// }
@ApiOperation("查询账户余额统计")
@PostMapping({"/balance/sum"})
public AjaxResult queryAccInfoBalanceSum(@RequestBody AccountInfoQueryParam accountInfoQueryParam) {
return AjaxResult.success(this.accInfoService.queryAccInfoBalanceSum(accountInfoQueryParam));
}
@ApiOperation("账户启用、停用")
@PostMapping({"/status/edit"})
public AjaxResult editAccountStatus(@RequestBody @Valid AccountEnableDisableParam accountEnableDisableParam) {
this.accInfoService.editAccountStatus(accountEnableDisableParam);
return AjaxResult.success();
}
@ApiOperation("账户操作记录")
@PostMapping({"/operation/list"})
public AjaxResult queryPageAccOperationRecord(@RequestBody AccOperationQueryParam param) {
return AjaxResult.success(this.accOperationHistoryService.selectAccOperationHistory(param));
}
/**
* 删除账户资料
*/
@ApiOperation(value = "删除账户资料")
//@PreventRepeatSubmit
//@RequiresPermissions("account:info:remove")
@SysLog(title = "账户资料", businessType = OperaType.DELETE, logType = 1,module = "账户管理->删除账户资料")
@PostMapping("/deleteAccInfoByUserIds")
public AjaxResult deleteAccInfoByUserIds(@RequestBody List<SysUser> users) {
return toAjax(accInfoService.deleteAccInfoByUserIds(users));
}
@ApiOperation(value = "获取支付二维码")
@PostMapping(value = "/getOrderQRCode")
public AjaxResult getOrderQRCode() {
return success(accInfoService.getOrderQRCode());
}
@ApiOperation(
value = "查询账户(仅返回钱包余额)",
notes = "移动端查询账户(仅返回钱包余额)"
)
@PostMapping({"/wallet/balance"})
public AjaxResult queryWalletBalance(@RequestBody AccInfo accInfo) {
return success(this.accInfoService.queryWalletBalance(accInfo));
}
}

View File

@ -1,5 +1,7 @@
package com.bonus.canteen.core.account.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
@ -21,10 +23,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
public class AccInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键自增 */
private Long id;
/** 账户id */
/** 账户id 主键自增 */
@Excel(name = "账户id")
@ApiModelProperty(value = "账户id")
private Long accId;
@ -113,13 +112,13 @@ public class AccInfo extends BaseEntity {
@ApiModelProperty(value = "有效截止日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效截止日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate;
private LocalDate endDate;
/** 红包过期时间 */
@ApiModelProperty(value = "红包过期时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "红包过期时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date redValidityDate;
private LocalDate redValidityDate;
/** 账户状态 1正常 2冻结 3销户 */
@Excel(name = "账户状态 1正常 2冻结 3销户")
@ -205,17 +204,17 @@ public class AccInfo extends BaseEntity {
/** 个人钱包最低余额限制金额 */
@Excel(name = "个人钱包最低余额限制金额")
@ApiModelProperty(value = "个人钱包最低余额限制金额")
private Long minWalletBalLimit;
private BigDecimal minWalletBalLimit;
/** 补贴钱包最低余额限制金额 */
@Excel(name = "补贴钱包最低余额限制金额")
@ApiModelProperty(value = "补贴钱包最低余额限制金额")
private Long minRedBalLimit;
private BigDecimal minRedBalLimit;
/** 红包钱包最低余额限制金额 */
@Excel(name = "红包钱包最低余额限制金额")
@ApiModelProperty(value = "红包钱包最低余额限制金额")
private Long minSubBalLimit;
private BigDecimal minSubBalLimit;
/** 当月累计使用满减次数 */
@Excel(name = "当月累计使用满减次数")

View File

@ -0,0 +1,38 @@
package com.bonus.canteen.core.account.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class AccInfoVo {
/** 账户id 主键自增 */
@Excel(name = "账户id")
@ApiModelProperty(value = "账户id")
private Long accId;
/** 人员id */
@Excel(name = "人员id")
@ApiModelProperty(value = "人员id")
private Long userId;
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
private Integer accStatus;
@ApiModelProperty("账户可用总余额(不包括冻结金额)")
private Long accBalTotal;
@ApiModelProperty("账户总余额(包含冻结金额)")
private Long accAllBal;
@ApiModelProperty("个人钱包(可用)余额/分")
private Long walletBal;
@ApiModelProperty("补贴钱包(可用)余额/分")
private Long subsidyBal;
@ApiModelProperty("红包余额")
private Long redEnvelope;
@ApiModelProperty("个人钱包冻结金额")
private Long walletFreezeBal;
@ApiModelProperty("补贴钱包冻结金额")
private Long subFreezeBal;
private Long accFreezeBalTotal;
private List<AccWalletInfo> walletInfoList;
}

View File

@ -100,10 +100,10 @@ public class AccTrade extends BaseEntity {
@ApiModelProperty(value = "批量操作批次号")
private String batchNum;
/** 关联小牛订单号 */
@Excel(name = "关联小牛订单号")
@ApiModelProperty(value = "关联小牛订单号")
private Long leOrdNo;
/** 商户订单号 */
@Excel(name = "商户订单号")
@ApiModelProperty(value = "商户订单号")
private String orderNo;
/** 关联原记录交易id */
@Excel(name = "关联原记录交易id")

View File

@ -0,0 +1,42 @@
package com.bonus.canteen.core.account.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class WalletBalanceVO {
@ApiModelProperty("个人钱包余额/分")
private Long walletBal;
@ApiModelProperty("补贴钱包余额/分")
private Long subsidyBal;
@ApiModelProperty("红包余额")
private Long redEnvelope;
@ApiModelProperty("个人钱包冻结金额")
private Long walletFreezeBal;
@ApiModelProperty("补贴钱包冻结金额")
private Long subFreezeBal;
@ApiModelProperty("冻结金额")
private Long accFreezeBalTotal;
@ApiModelProperty("账户总余额(包含冻结金额)")
private Long accAllBal;
@ApiModelProperty("账户可用余额总余额(不包括冻结金额)")
private Long accBalTotal;
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
private Integer accStatus;
public static WalletBalanceVO of(AccInfoVo accInfoVo) {
WalletBalanceVO walletBalanceVO = new WalletBalanceVO();
//walletBalanceVO.setAccBalTotal(accInfoVo.getAccBalTotal());
walletBalanceVO.setAccAllBal(accInfoVo.getAccAllBal());
walletBalanceVO.setWalletBal(accInfoVo.getWalletBal());
walletBalanceVO.setSubsidyBal(accInfoVo.getSubsidyBal());
//walletBalanceVO.setRedEnvelope(accInfoVo.getRedEnvelope());
//walletBalanceVO.setWalletFreezeBal(accInfoVo.getWalletFreezeBal());
//walletBalanceVO.setSubFreezeBal(accInfoVo.getSubFreezeBal());
//walletBalanceVO.setAccFreezeBalTotal(accInfoVo.getAccFreezeBalTotal());
walletBalanceVO.setAccStatus(accInfoVo.getAccStatus());
return walletBalanceVO;
}
}

View File

@ -0,0 +1,40 @@
package com.bonus.canteen.core.account.domain.bo;
import com.alibaba.fastjson.annotation.JSONField;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class AccOperationHistory {
@ApiModelProperty("主键")
private Integer id;
@ApiModelProperty("用户编号")
private Long userId;
@ApiModelProperty("用户姓名")
@Excel(name = "用户姓名")
private String userName;
@ApiModelProperty("用户手机号")
@Excel(name = "用户手机号")
private String phone;
@ApiModelProperty("组织全称")
@Excel(name = "组织名称")
private String deptName;
@Excel(name = "组织全称")
private String deptFullName;
@ApiModelProperty("操作类型 1启用 2停用")
private Integer type;
@ApiModelProperty("操作类型")
@Excel(name = "操作类型")
private String typeName;
@ApiModelProperty("操作员")
@Excel(name = "操作员")
private String createBy;
@ApiModelProperty("操作时间")
@JSONField(
format = "yyyy-MM-dd HH:mm:ss"
)
@Excel(name = "操作时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,14 @@
package com.bonus.canteen.core.account.domain.bo;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class AccStatusChange {
private String userId;
private String nickName;
private Long merchantId;
private Integer accStatus;
private LocalDateTime updateDateTime;
}

View File

@ -0,0 +1,22 @@
package com.bonus.canteen.core.account.domain.param;
import com.bonus.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
public class AccOperationQueryParam extends BaseEntity {
@ApiModelProperty("操作事件 1启用 2停用")
private Integer type;
@ApiModelProperty("查询组织id集合")
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
private LocalDateTime endDateTime;
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.account.domain.param;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@Data
public class AccountBalanceEditParam {
@ApiModelProperty(value = "人员id")
private Long userId;
@ApiModelProperty(value = "有效截止日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
@ApiModelProperty(value = "个人钱包最低余额限制金额")
private BigDecimal minWalletBalLimit;
@ApiModelProperty(value = "红包钱包最低余额限制金额")
private BigDecimal minSubBalLimit;
@ApiModelProperty(value = "账户状态 1正常 2冻结 3销户")
private Long accStatus;
}

View File

@ -0,0 +1,16 @@
package com.bonus.canteen.core.account.domain.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
@Data
public class AccountEnableDisableParam {
@ApiModelProperty(value = "人员id")
private Long userId;
@ApiModelProperty(value = "账户状态 1正常 2冻结 3销户")
private Long accStatus;
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.account.domain.param;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class AccountInfoQueryParam extends BaseEntity {
@ApiModelProperty("账户状态 1正常 2停用")
private List<Integer> accStatusList;
@ApiModelProperty("筛选钱包类型 0-账户总余额 1-个人钱包 2-补贴钱包")
private Integer walletType;
@ApiModelProperty("查询组织id集合")
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
private LocalDateTime endDateTime;
// @ApiModelProperty("钱包最小金额")
// private BigDecimal walletMinAmount;
// @ApiModelProperty("钱包最大金额")
// private BigDecimal walletMaxAmount;
}

View File

@ -0,0 +1,72 @@
package com.bonus.canteen.core.account.domain.vo;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class AccInfoDetailsVO {
@ApiModelProperty("账户id")
private Long accId;
@ApiModelProperty("人员id")
private Long userId;
@ApiModelProperty("操作时间")
@Excel(name = "操作时间")
private LocalDateTime updateTime;
@ApiModelProperty("用户姓名")
@Excel(name = "用户姓名")
private String nickName;
@ApiModelProperty("用户手机号")
@Excel(name = "用户手机号")
private String phoneNumber;
@ApiModelProperty("所属组织")
@Excel(name = "所属组织")
private String orgFullName;
@ApiModelProperty("用户类别")
private Integer userType;
@ApiModelProperty("用户部门")
private String deptName;
@ApiModelProperty("用户类别(展示)")
@Excel(name = "用户类别(展示)")
private String userTypeName;
@ApiModelProperty("账户总余额")
@Excel(name = "账户总余额")
private BigDecimal accBalTotal;
@ApiModelProperty("账户可用总余额(不包含冻结金额)")
private BigDecimal accAvailableBal;
@ApiModelProperty("个人钱包余额/分")
@Excel(name = "个人钱包余额/分")
private BigDecimal walletBal;
@ApiModelProperty("补贴钱包余额/分")
@Excel(name = "补贴钱包余额/分")
private BigDecimal subsidyBal;
@ApiModelProperty("红包余额")
@Excel(name = "红包余额")
private BigDecimal redEnvelope;
@ApiModelProperty("冻结金额")
@Excel(name = "冻结金额")
private BigDecimal accFreezeBalTotal;
@ApiModelProperty("个人钱包允许最低余额限制")
@Excel(name = "个人钱包允许最低余额限制")
private BigDecimal minWalletBalLimit;
@ApiModelProperty("补贴钱包允许最低余额限制")
@Excel(name = "补贴钱包允许最低余额限制")
private BigDecimal minSubBalLimit;
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
private Integer accStatus;
@ApiModelProperty("账户状态名称")
@Excel(name = "账户状态名称")
private String accStatusName;
@ApiModelProperty("账户有效期")
@Excel(name = "账户有效期")
private LocalDate endDate;
@ApiModelProperty("积分")
private Long scope;
@ApiModelProperty("个人钱包冻结金额")
private BigDecimal frozenWallet;
@ApiModelProperty("补贴冻结金额")
private BigDecimal frozenSub;
}

View File

@ -0,0 +1,12 @@
package com.bonus.canteen.core.account.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AccInfoInvalidSumVO {
@ApiModelProperty("当天过期数量")
private Integer expiredCount;
@ApiModelProperty("当天注销数量")
private Integer cancelCount;
}

View File

@ -0,0 +1,35 @@
package com.bonus.canteen.core.account.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class AccTradeVo {
private Long userId;
private Long deptId;
private String orderNo;//商户订单号, 商户网站订单系统中唯一订单号必填
private String orderName;//订单名称, 必填
private BigDecimal paymentAmount;//付款金额, 必填
private String productDesc;//商品描述
private Long amount; //金额单位
private Long tradeType;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private Date tradeTime;
private Long tradeState;
private Long payType;
private Long payState; //是否付款 true - 已付 false-未付
private String thirdTradeNo; //三方支付宝交易号
private String failReason;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private Date createTime;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private Date updateTime;
}

View File

@ -0,0 +1,18 @@
package com.bonus.canteen.core.account.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class AccWalletInfoVO {
private Long userId;
private Long accId;
private Integer walletId;
private BigDecimal walletBal;
private BigDecimal limitBalance;
private BigDecimal frozenBalance;
private BigDecimal lastSubsidyAmount;
private LocalDateTime lastSubsidyTime;
}

View File

@ -1,7 +1,15 @@
package com.bonus.canteen.core.account.mapper;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.account.domain.AccInfo;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import org.apache.ibatis.annotations.Param;
import com.bonus.canteen.core.account.domain.AccInfoVo;
/**
* 账户资料Mapper接口
@ -9,7 +17,7 @@ import com.bonus.canteen.core.account.domain.AccInfo;
* @author xsheng
* @date 2025-04-05
*/
public interface AccInfoMapper {
public interface AccInfoMapper extends BaseMapper<AccInfo> {
/**
* 查询账户资料
*
@ -26,6 +34,8 @@ public interface AccInfoMapper {
*/
public List<AccInfo> selectAccInfoList(AccInfo accInfo);
public AccInfoVo selectAccInfoVo(AccInfo accInfo);
/**
* 新增账户资料
*
@ -48,7 +58,7 @@ public interface AccInfoMapper {
* @param id 账户资料主键
* @return 结果
*/
public int deleteAccInfoById(Long id);
public int deleteAccInfoByUserId(Long id);
/**
* 批量删除账户资料
@ -57,4 +67,13 @@ public interface AccInfoMapper {
* @return 结果
*/
public int deleteAccInfoByIds(Long[] ids);
Integer queryAccInfoInvalidSum(@Param("startDateTime") LocalDateTime startDateTime, @Param("endDateTime") LocalDateTime endDateTime, @Param("accStatus") Integer accStatus);
List<AccInfoDetailsVO> queryAccInfoDetails(@Param("accountInfoQueryParam") AccountInfoQueryParam accountInfoQueryParam,
@Param("encryptedSearchValue") String encryptedSearchValue);
AccInfoDetailsVO queryAccInfoBalanceSum(@Param("accountInfoQueryParam") AccountInfoQueryParam accountInfoQueryParam);
void updateAccInfoEndDateByUserId(LocalDate endDate, List<Long> userIds, String updateBy);
}

View File

@ -0,0 +1,15 @@
package com.bonus.canteen.core.account.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.account.domain.bo.AccOperationHistory;
import com.bonus.canteen.core.account.domain.param.AccOperationQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AccOperationHistoryMapper extends BaseMapper<AccOperationHistory> {
List<AccOperationHistory> queryPageAccOperationRecord(@Param("param") AccOperationQueryParam param,
@Param("encryptedSearchValue") String encryptedSearchValue);
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.mapper;
import java.util.List;
import com.bonus.canteen.core.account.domain.AccTrade;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
/**
* 账户交易记录Mapper接口
@ -34,6 +35,8 @@ public interface AccTradeMapper {
*/
public int insertAccTrade(AccTrade accTrade);
// public int insertAccTradeVo(AccTradeVo accTrade);
/**
* 修改账户交易记录
*
@ -42,6 +45,8 @@ public interface AccTradeMapper {
*/
public int updateAccTrade(AccTrade accTrade);
public int updateAccTradeVoByOrderNo(AccTradeVo accTradeVo);
/**
* 删除账户交易记录
*

View File

@ -1,7 +1,11 @@
package com.bonus.canteen.core.account.mapper;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import com.bonus.canteen.core.account.domain.AccWalletInfo;
import org.apache.ibatis.annotations.Param;
import com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO;
/**
* 钱包详情信息Mapper接口
@ -18,6 +22,8 @@ public interface AccWalletInfoMapper {
*/
public AccWalletInfo selectAccWalletInfoByUserId(Long userId);
List<AccWalletInfoVO> selectAccWalletInfoByUserIds(@Param("userIds") List<Long> userIds);
/**
* 查询钱包详情信息列表
*
@ -34,6 +40,8 @@ public interface AccWalletInfoMapper {
*/
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
public int batchInsertAccWalletInfo(@Param("list") List<AccWalletInfo> accWalletInfos);
/**
* 修改钱包详情信息
*
@ -57,4 +65,11 @@ public interface AccWalletInfoMapper {
* @return 结果
*/
public int deleteAccWalletInfoByUserIds(Long[] userIds);
void updateMinBalanceByUserId(@Param("minBalance") BigDecimal limitBalance,
@Param("walletId") Integer walletId,
@Param("userIds") List<Long> userIds,
@Param("updateBy") String updateBy,
@Param("updateTime") LocalDate updateTime);
}

View File

@ -0,0 +1,103 @@
package com.bonus.canteen.core.account.mq;
import com.bonus.canteen.core.account.constants.AccStatusEnum;
import com.bonus.canteen.core.account.domain.bo.AccStatusChange;
import com.bonus.canteen.core.common.utils.TenantContextHolder;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.houqin.mq.constant.LeMqConstant;
import com.bonus.common.houqin.mq.util.MqUtil;
import com.bonus.common.houqin.utils.JacksonUtil;
import com.bonus.system.api.RemoteUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Component
public class AccMqSender {
private static final Logger log = LoggerFactory.getLogger(AccMqSender.class);
@Resource
private RemoteUserService remoteUserService;
public void accChangeMQ(List<Long> userIds, Integer accStatus) {
// 校验输入参数
if (userIds == null || accStatus == null) {
log.warn("用户ID列表或账户状态为空无法发送MQ。userIds: {}, accStatus: {}", userIds, accStatus);
return;
}
if (!AccStatusEnum.DEACTIVATE.getKey().equals(accStatus)) {
log.warn("账户状态不在允许范围内无法发送MQ。accStatus: {}", accStatus);
return;
}
try {
log.info("账户状态变动发送mq-入参人员数量: {} 账户状态: {}", userIds.size(), accStatus);
AjaxResult resultList = remoteUserService.getUsers(userIds.toArray(EMPTY_LONG_ARRAY), SecurityConstants.INNER);
// 校验远程调用结果
if (resultList == null || resultList.get(AjaxResult.DATA_TAG) == null) {
log.error("远程用户服务返回数据为空");
return;
}
List sysUserList = resultList.getDataAs(List.class);
if (sysUserList == null || sysUserList.isEmpty()) {
log.warn("用户列表为空无需发送MQ");
return;
}
Long tenantId = TenantContextHolder.getTenantId();
if (tenantId == null) {
log.error("租户ID为空无法发送MQ");
return;
}
LocalDateTime now = LocalDateTime.now();
sysUserList.stream()
.filter(Objects::nonNull)
.map(item -> processUserItem((Map<String, Object>) item, tenantId, accStatus, now))
.filter(Objects::nonNull)
.forEach(accStatusChange -> sendMqMessage((AccStatusChange)accStatusChange));
} catch (Exception e) {
log.error("账户状态变动发送MQ失败", e);
}
}
private AccStatusChange processUserItem(Map<String, Object> map, Long tenantId, Integer accStatus, LocalDateTime now) {
if (map == null || !map.containsKey("userId") || !map.containsKey("userName")) {
log.warn("用户数据不完整跳过处理。map: {}", map);
return null;
}
AccStatusChange accStatusChange = new AccStatusChange();
accStatusChange.setUserId((String)map.get("userId"));
accStatusChange.setNickName((String) map.get("nickName"));
accStatusChange.setMerchantId(tenantId);
accStatusChange.setAccStatus(accStatus);
accStatusChange.setUpdateDateTime(now);
return accStatusChange;
}
private void sendMqMessage(AccStatusChange accStatusChange) {
String jsonString = JacksonUtil.writeValueAsString(accStatusChange);
if (jsonString == null) {
log.error("序列化账户状态变更对象失败:{}", accStatusChange);
return;
}
log.info("账户状态变动发送mq内容{}", jsonString);
try {
MqUtil.send(jsonString, LeMqConstant.Topic.ACC_STATUS_CHANGE);
} catch (Exception e) {
log.error("发送MQ消息失败{}", jsonString, e);
}
}
private static final Long[] EMPTY_LONG_ARRAY = new Long[0];
}

View File

@ -0,0 +1,12 @@
package com.bonus.canteen.core.account.service;
import com.bonus.canteen.core.account.domain.bo.AccOperationHistory;
import com.bonus.canteen.core.account.domain.param.AccOperationQueryParam;
import java.util.List;
public interface AccOperationHistoryService {
List<AccOperationHistory> selectAccOperationHistory(AccOperationQueryParam param);
void addAccOperationHistory(Long userId, Integer type);
}

View File

@ -2,6 +2,14 @@ package com.bonus.canteen.core.account.service;
import java.util.List;
import com.bonus.canteen.core.account.domain.AccInfo;
import com.bonus.canteen.core.account.domain.AccInfoVo;
import com.bonus.canteen.core.account.domain.WalletBalanceVO;
import com.bonus.canteen.core.account.domain.param.AccountBalanceEditParam;
import com.bonus.canteen.core.account.domain.param.AccountEnableDisableParam;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.account.domain.vo.AccInfoInvalidSumVO;
import com.bonus.system.api.domain.SysUser;
/**
* 账户资料Service接口
@ -24,7 +32,9 @@ public interface IAccInfoService {
* @param accInfo 账户资料
* @return 账户资料集合
*/
public List<AccInfo> selectAccInfoList(AccInfo accInfo);
public List<AccInfoDetailsVO> selectAccInfoList(AccountInfoQueryParam accountInfoQueryParam);
// public List<AccInfoVo> selectAccInfoVoList(AccInfo accInfo);
/**
* 新增账户资料
@ -40,7 +50,7 @@ public interface IAccInfoService {
* @param accInfo 账户资料
* @return 结果
*/
public int updateAccInfo(AccInfo accInfo);
public void updateAccInfo(AccountBalanceEditParam accountBalanceEditParam);
/**
* 批量删除账户资料
@ -50,11 +60,14 @@ public interface IAccInfoService {
*/
public int deleteAccInfoByIds(Long[] ids);
/**
* 删除账户资料信息
*
* @param id 账户资料主键
* @return 结果
*/
public int deleteAccInfoById(Long id);
AccInfoInvalidSumVO queryAccInfoInvalidSum();
AccInfoDetailsVO queryAccInfoBalanceSum(AccountInfoQueryParam accountInfoQueryParam);
void editAccountStatus(AccountEnableDisableParam accountEnableDisableParam);
public int deleteAccInfoByUserIds(List<SysUser> users);
public int syncAccInfo(SysUser sysUser);
public String getOrderQRCode();
public WalletBalanceVO queryWalletBalance(AccInfo accInfo);
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.account.service;
import java.util.List;
import com.bonus.canteen.core.account.domain.AccTrade;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
/**
* 账户交易记录Service接口
@ -34,6 +35,8 @@ public interface IAccTradeService {
*/
public int insertAccTrade(AccTrade accTrade);
public int insertAccTradeVo(AccTradeVo accTrade);
/**
* 修改账户交易记录
*
@ -42,6 +45,8 @@ public interface IAccTradeService {
*/
public int updateAccTrade(AccTrade accTrade);
public int updateAccTradeVoByOrderNo(AccTradeVo accTrade);
/**
* 批量删除账户交易记录
*

View File

@ -1,7 +1,11 @@
package com.bonus.canteen.core.account.service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.bonus.canteen.core.account.domain.AccWalletInfo;
import com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO;
/**
* 钱包详情信息Service接口
@ -34,6 +38,8 @@ public interface IAccWalletInfoService {
*/
public int insertAccWalletInfo(AccWalletInfo accWalletInfo);
public int batchInsertAccWalletInfo(List<AccWalletInfo> accWalletInfos);
/**
* 修改钱包详情信息
*
@ -57,4 +63,9 @@ public interface IAccWalletInfoService {
* @return 结果
*/
public int deleteAccWalletInfoByUserId(Long userId);
Map<Long, List<AccWalletInfoVO>> selectAccWalletInfoByUserIds(List<Long> userIds);
void updateMinBalance(List<Long> userIds, Integer walletId, BigDecimal minBalance);
}

View File

@ -1,13 +1,54 @@
package com.bonus.canteen.core.account.service.impl;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.canteen.core.account.constants.AccWalletIdEnum;
import com.bonus.canteen.core.account.constants.AccStatusEnum;
import com.bonus.canteen.core.account.domain.*;
import com.bonus.canteen.core.account.domain.param.AccountBalanceEditParam;
import com.bonus.canteen.core.account.domain.param.AccountEnableDisableParam;
import com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.account.domain.vo.AccInfoInvalidSumVO;
import com.bonus.canteen.core.account.mq.AccMqSender;
import com.bonus.canteen.core.account.service.AccOperationHistoryService;
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.json.JSONUtil;
import com.bonus.canteen.core.account.domain.AccInfoVo;
import com.bonus.canteen.core.account.domain.AccWalletInfo;
import com.bonus.canteen.core.account.domain.WalletBalanceVO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.LeCodeUseSceneEnum;
import com.bonus.common.houqin.constant.SourceTypeEnum;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysUser;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.task.AsyncTaskExecutor;
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;
import javax.annotation.Resource;
/**
* 账户资料Service业务层处理
@ -16,9 +57,24 @@ import com.bonus.canteen.core.account.service.IAccInfoService;
* @date 2025-04-05
*/
@Service
@Slf4j
public class AccInfoServiceImpl implements IAccInfoService {
private static final Logger log = LoggerFactory.getLogger(AccInfoServiceImpl.class);
@Autowired
private IAccWalletInfoService accWalletInfoService;
@Autowired
private AccInfoMapper accInfoMapper;
@Autowired
private AccOperationHistoryService accOperationHistoryService;
@Autowired
private AccMqSender accMqSender;
@Resource(
name = "smartCanteenTaskExecutor"
)
@Lazy
private AsyncTaskExecutor asyncTaskExecutor;
/**
* 查询账户资料
@ -33,15 +89,21 @@ public class AccInfoServiceImpl implements IAccInfoService {
/**
* 查询账户资料列表
*
* @param accInfo 账户资料
* @return 账户资料
*
*/
@Override
public List<AccInfo> selectAccInfoList(AccInfo accInfo) {
return accInfoMapper.selectAccInfoList(accInfo);
public List<AccInfoDetailsVO> selectAccInfoList(AccountInfoQueryParam accountInfoQueryParam) {
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(accountInfoQueryParam.getSearchValue());
List<AccInfoDetailsVO> list = accInfoMapper.queryAccInfoDetails(accountInfoQueryParam, encryptedSearchValue);
handleResult(list);
return list;
}
// @Override
// public List<AccInfoVo> selectAccInfoVoList(AccInfo accInfo) {
// return accInfoMapper.selectAccInfoVoList(accInfo);
// }
/**
* 新增账户资料
*
@ -60,20 +122,35 @@ public class AccInfoServiceImpl implements IAccInfoService {
/**
* 修改账户资料
*
* @param accInfo 账户资料
* @return 结果
*
*/
@Override
public int updateAccInfo(AccInfo accInfo) {
accInfo.setUpdateTime(DateUtils.getNowDate());
@Transactional(rollbackFor = Exception.class)
public void updateAccInfo(AccountBalanceEditParam accountBalanceEditParam) {
LocalDate accEndDate = accountBalanceEditParam.getEndDate();
Map<AccWalletIdEnum, BigDecimal> walletLimits = new HashMap<>();
walletLimits.put(AccWalletIdEnum.WALLET, accountBalanceEditParam.getMinWalletBalLimit());
walletLimits.put(AccWalletIdEnum.SUBSIDY, accountBalanceEditParam.getMinSubBalLimit());
for (Map.Entry<AccWalletIdEnum, BigDecimal> entry : walletLimits.entrySet()) {
accWalletInfoService.updateMinBalance(ListUtil.toList(accountBalanceEditParam.getUserId()), entry.getKey().getKey(), entry.getValue());
}
updateAccountEndDate(ListUtil.toList(accountBalanceEditParam.getUserId()), accEndDate);
}
protected void updateAccountEndDate(List<Long> userIds, LocalDate accEndDate) {
if (ObjectUtil.isEmpty(userIds)) {
log.info("更新账户有效期-账户信息为空");
return;
}
try {
return accInfoMapper.updateAccInfo(accInfo);
accInfoMapper.updateAccInfoEndDateByUserId(accEndDate, userIds, SecurityUtils.getUsername());
} catch (Exception e) {
throw new ServiceException("错误信息描述");
log.error("[更新账户有效期失败", e);
throw new ServiceException("更新账户有效期失败");
}
}
/**
* 批量删除账户资料
*
@ -88,11 +165,172 @@ public class AccInfoServiceImpl implements IAccInfoService {
/**
* 删除账户资料信息
*
* @param id 账户资料主键
* @param users 账户资料主键
* @return 结果
*/
@Transactional(
rollbackFor = {Exception.class}
)
public int deleteAccInfoByUserIds(List<SysUser> users) {
int count = 0;
for (int i = 0; i < users.size(); i++) {
accWalletInfoService.deleteAccWalletInfoByUserId(users.get(i).getUserId());
//MqUtil.sendDataChange(userId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
count += accInfoMapper.deleteAccInfoByUserId(users.get(i).getUserId());
}
return count;
}
@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);
}
@Override
public int deleteAccInfoById(Long id) {
return accInfoMapper.deleteAccInfoById(id);
public String getOrderQRCode() {
String stime = String.valueOf(System.currentTimeMillis());
String userId = SecurityUtils.getUserId().toString();
return "bns{\"s\":" + SourceTypeEnum.WECHAT_SMALL_PRO.getKey() + ",\"y\":" + LeCodeUseSceneEnum.PAY.key() + ",\"p\":\"" + userId + "\",\"t\":" + "\"" + stime + "\"}";
}
public AccInfoInvalidSumVO queryAccInfoInvalidSum() {
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime startOfDay = now.toLocalDate().atTime(LocalTime.MIN);
//
// CompletableFuture<Integer> cancelCountFuture = CompletableFuture.supplyAsync(
// () -> accInfoMapper.queryAccInfoInvalidSum(startOfDay, now, AccountStatusEnum.CANCEL.getKey()),
// this.asyncTaskExecutor
// ).exceptionally(ex -> {
// log.error("Failed to get cancel count", ex);
// return 0;
// });
//
// CompletableFuture<Integer> expiredCountFuture = CompletableFuture.supplyAsync(
// () -> accInfoMapper.queryAccInfoInvalidSum(startOfDay, now, AccountStatusEnum.OVERDUE.getKey()),
// this.asyncTaskExecutor
// ).exceptionally(ex -> {
// log.error("Failed to get expired count", ex);
// return 0;
// });
//
// return cancelCountFuture.thenCombine(expiredCountFuture, (cancel, expired) -> {
// AccInfoInvalidSumVO accInfoInvalidSumVO = new AccInfoInvalidSumVO();
// accInfoInvalidSumVO.setCancelCount(cancel);
// accInfoInvalidSumVO.setExpiredCount(expired);
// return accInfoInvalidSumVO;
// }
// ).join();
return null;
}
private void handleResult(List<AccInfoDetailsVO> list) {
if (CollUtil.isEmpty(list)) {
return;
}
List<Long> custIdList = list.stream()
.map(AccInfoDetailsVO::getUserId)
.collect(Collectors.toList());
Map<Long, List<AccWalletInfoVO>> walletMap = accWalletInfoService.selectAccWalletInfoByUserIds(custIdList);
list.forEach(item -> {
List<AccWalletInfoVO> walletInfoList = walletMap.getOrDefault(item.getUserId(), ListUtil.empty());
setWalletBalances(item, walletInfoList);
setTotalBalances(item, walletInfoList);
});
}
private void setWalletBalances(AccInfoDetailsVO item, List<AccWalletInfoVO> walletInfoList) {
for (AccWalletInfoVO wallet : walletInfoList) {
switch (AccWalletIdEnum.getEnum(wallet.getWalletId())) {
case WALLET:
item.setWalletBal(wallet.getWalletBal());
item.setFrozenWallet(wallet.getFrozenBalance());
item.setMinWalletBalLimit(wallet.getLimitBalance());
break;
case SUBSIDY:
item.setSubsidyBal(wallet.getWalletBal());
item.setFrozenSub(wallet.getFrozenBalance());
item.setMinSubBalLimit(wallet.getLimitBalance());
break;
default:
break;
}
}
}
private void setTotalBalances(AccInfoDetailsVO item, List<AccWalletInfoVO> walletInfoList) {
BigDecimal frozenBalanceAll = walletInfoList.stream()
.map(AccWalletInfoVO::getFrozenBalance)
.filter(ObjectUtil::isNotNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal accAvailableBal = walletInfoList.stream()
.map(AccWalletInfoVO::getWalletBal)
.filter(ObjectUtil::isNotNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
item.setAccBalTotal(NumberUtil.add(accAvailableBal, frozenBalanceAll));
item.setAccAvailableBal(accAvailableBal);
item.setAccFreezeBalTotal(frozenBalanceAll);
}
public AccInfoDetailsVO queryAccInfoBalanceSum(AccountInfoQueryParam accountInfoQueryParam) {
return accInfoMapper.queryAccInfoBalanceSum(accountInfoQueryParam);
}
@Transactional(rollbackFor = {Exception.class})
public void editAccountStatus(AccountEnableDisableParam accountEnableDisableParam) {
int flag = accInfoMapper.update((((Wrappers.lambdaUpdate(AccInfo.class)
.set(AccInfo::getAccStatus, accountEnableDisableParam.getAccStatus()))
.set(AccInfo::getUpdateBy, SecurityUtils.getUserId()))
.set(AccInfo::getUpdateTime, LocalDateTime.now()))
.eq(AccInfo::getUserId, accountEnableDisableParam.getUserId()));
if (flag > 0) {
this.accOperationHistoryService.addAccOperationHistory(accountEnableDisableParam.getUserId(), accountEnableDisableParam.getAccStatus().intValue());
this.accMqSender.accChangeMQ(Collections.singletonList(accountEnableDisableParam.getUserId()), accountEnableDisableParam.getAccStatus().intValue());
}
}
public WalletBalanceVO queryWalletBalance(AccInfo accInfo) {
log.info("查询账户余额入参={}", JSONUtil.toJsonStr(accInfo));
AccInfoVo accInfoVO = accInfoMapper.selectAccInfoVo(accInfo);
if (ObjectUtil.isNull(accInfoVO)) {
throw new ServiceException("账户不存在");
} else {
AccWalletInfo accWalletInfo = new AccWalletInfo();
accWalletInfo.setAccId(accInfoVO.getAccId());
List<AccWalletInfo> walletInfoList = this.accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
this.setAccInfoVODetailList(accInfoVO, walletInfoList);
log.info("获取账户(钱包)信息,出参={}", JSONUtil.toJsonStr(accInfoVO));
}
WalletBalanceVO walletBalanceVO = WalletBalanceVO.of(accInfoVO);
log.info("查询账户余额入参={}", JSONUtil.toJsonStr(walletBalanceVO));
return walletBalanceVO;
}
protected void setAccInfoVODetailList(AccInfoVo accInfoVo, List<AccWalletInfo> walletInfoList) {
if (ObjectUtil.isNotEmpty(walletInfoList)) {
accInfoVo.setWalletBal(walletInfoList.stream().filter(o -> o.getWalletId().intValue() == AccWalletIdEnum.WALLET.getKey()).mapToLong(AccWalletInfo::getWalletBal).sum());
accInfoVo.setSubsidyBal(walletInfoList.stream().filter(o -> o.getWalletId().intValue() == AccWalletIdEnum.SUBSIDY.getKey()).mapToLong(AccWalletInfo::getWalletBal).sum());
accInfoVo.setAccAllBal(accInfoVo.getWalletBal() + accInfoVo.getSubsidyBal());
}
}
}

View File

@ -0,0 +1,45 @@
package com.bonus.canteen.core.account.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.account.domain.bo.AccOperationHistory;
import com.bonus.canteen.core.account.domain.param.AccOperationQueryParam;
import com.bonus.canteen.core.account.mapper.AccOperationHistoryMapper;
import com.bonus.canteen.core.account.service.AccOperationHistoryService;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.RemoteUserService;
import com.bonus.system.api.domain.SysUser;
import com.github.pagehelper.page.PageMethod;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
@Service
public class AccOperationHistoryServiceImpl extends ServiceImpl<AccOperationHistoryMapper, AccOperationHistory> implements AccOperationHistoryService {
@Resource
private RemoteUserService remoteUserService;
public List<AccOperationHistory> selectAccOperationHistory(AccOperationQueryParam param) {
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(param.getSearchValue());
return this.baseMapper.queryPageAccOperationRecord(param, encryptedSearchValue);
}
public void addAccOperationHistory(Long userId, Integer type) {
AjaxResult userResult = remoteUserService.getInfo(userId , SecurityConstants.INNER);
if(Objects.nonNull(userResult)) {
SysUser sysUser = userResult.getDataAs(SysUser.class);
AccOperationHistory accOperationRecord = new AccOperationHistory();
accOperationRecord.setType(type);
accOperationRecord.setUserId(userId);
accOperationRecord.setUserName(sysUser.getUserName());
accOperationRecord.setPhone(sysUser.getPhonenumber());
accOperationRecord.setCreateBy(SecurityUtils.getUsername());
accOperationRecord.setCreateTime(LocalDateTime.now());
this.baseMapper.insert(accOperationRecord);
}
}
}

View File

@ -1,8 +1,10 @@
package com.bonus.canteen.core.account.service.impl;
import java.util.List;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.account.mapper.AccTradeMapper;
@ -54,7 +56,19 @@ public class AccTradeServiceImpl implements IAccTradeService {
try {
return accTradeMapper.insertAccTrade(accTrade);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
throw new ServiceException("错误信息描述" + e.getMessage());
}
}
@Override
public int insertAccTradeVo(AccTradeVo accTradeVo) {
accTradeVo.setCreateTime(DateUtils.getNowDate());
try {
AccTrade accTrade = new AccTrade();
BeanUtils.copyProperties(accTradeVo, accTrade);
return accTradeMapper.insertAccTrade(accTrade);
} catch (Exception e) {
throw new ServiceException("错误信息描述" + e.getMessage());
}
}
@ -70,7 +84,17 @@ public class AccTradeServiceImpl implements IAccTradeService {
try {
return accTradeMapper.updateAccTrade(accTrade);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
throw new ServiceException("错误信息描述" + e.getMessage());
}
}
@Override
public int updateAccTradeVoByOrderNo(AccTradeVo accTradeVo) {
accTradeVo.setUpdateTime(DateUtils.getNowDate());
try {
return accTradeMapper.updateAccTradeVoByOrderNo(accTradeVo);
} catch (Exception e) {
throw new ServiceException("错误信息描述" + e.getMessage());
}
}

View File

@ -1,8 +1,18 @@
package com.bonus.canteen.core.account.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper;
@ -17,6 +27,8 @@ import com.bonus.canteen.core.account.service.IAccWalletInfoService;
*/
@Service
public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
private static final Logger log = LoggerFactory.getLogger(AccWalletInfoServiceImpl.class);
@Autowired
private AccWalletInfoMapper accWalletInfoMapper;
@ -58,6 +70,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("错误信息描述");
}
}
/**
* 修改钱包详情信息
*
@ -67,11 +89,7 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
@Override
public int updateAccWalletInfo(AccWalletInfo accWalletInfo) {
accWalletInfo.setUpdateTime(DateUtils.getNowDate());
try {
return accWalletInfoMapper.updateAccWalletInfo(accWalletInfo);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
return accWalletInfoMapper.updateAccWalletInfo(accWalletInfo);
}
/**
@ -95,4 +113,38 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
public int deleteAccWalletInfoByUserId(Long userId) {
return accWalletInfoMapper.deleteAccWalletInfoByUserId(userId);
}
public Map<Long, List<AccWalletInfoVO>> selectAccWalletInfoByUserIds(List<Long> userIds) {
List<AccWalletInfoVO> walletInfoList = accWalletInfoMapper.selectAccWalletInfoByUserIds(userIds);
return walletInfoList.stream()
.collect(Collectors.groupingBy(AccWalletInfoVO::getUserId));
}
@Override
public void updateMinBalance(List<Long> userIds, Integer walletId, BigDecimal minBalance) {
if (ObjectUtil.isNull(minBalance)) {
log.warn("修改钱包最低余额限制-最低余额不能为空");
return;
}
if (ObjectUtil.isNull(walletId)) {
log.warn("修改钱包最低余额限制-钱包编号为空");
return;
}
if (ObjectUtil.isEmpty(userIds)) {
log.warn("修改钱包最低余额限制-用户编号为空");
return;
}
try {
accWalletInfoMapper.updateMinBalanceByUserId(minBalance, walletId, userIds,
SecurityUtils.getUserId().toString(), DateUtils.toLocalDate(new Date()));
} catch (Exception e) {
log.error("修改钱包最低余额限制失败", e);
throw new ServiceException("修改钱包最低余额限制失败");
}
}
}

View File

@ -40,7 +40,7 @@ public class AllocAreaController extends BaseController {
/**
* 获取区域树列表
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
//@RequiresPermissions("alloc:area:list")
@GetMapping("/areaTree")
public AjaxResult deptTree(AllocArea area) {
try {
@ -58,7 +58,9 @@ public class AllocAreaController extends BaseController {
//@RequiresPermissions("alloc:area:list")
@GetMapping("/list")
public TableDataInfo list(AllocArea allocArea) {
startPage();
if (allocArea.isPagenation()) {
startPage();
}
List<AllocArea> list = allocAreaService.selectAllocAreaList(allocArea);
return getDataTable(list);
}

View File

@ -40,7 +40,9 @@ public class AllocCanteenController extends BaseController {
//@RequiresPermissions("alloc:canteen:list")
@GetMapping("/list")
public TableDataInfo list(AllocCanteen allocCanteen) {
startPage();
if (allocCanteen.isPagenation()) {
startPage();
}
List<AllocCanteen> list = allocCanteenService.selectAllocCanteenList(allocCanteen);
return getDataTable(list);
}

View File

@ -40,7 +40,9 @@ public class AllocStallController extends BaseController {
//@RequiresPermissions("alloc:stall:list")
@GetMapping("/list")
public TableDataInfo list(AllocStall allocStall) {
startPage();
if (allocStall.isPagenation()) {
startPage();
}
List<AllocStall> list = allocStallService.selectAllocStallList(allocStall);
return getDataTable(list);
}

View File

@ -22,6 +22,9 @@ import java.util.List;
public class AllocArea extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 是否分页 */
private boolean pagenation;
/** 主键id */
private Long areaId;
@ -35,9 +38,9 @@ public class AllocArea extends BaseEntity {
@ApiModelProperty(value = "上级区域id")
private Long parentId;
/** 负责人id */
@Excel(name = "负责人id")
@ApiModelProperty(value = "负责人id")
/** 负责人 */
@Excel(name = "负责人")
@ApiModelProperty(value = "负责人")
private String director;
/** 联系电话 */

View File

@ -21,6 +21,9 @@ import com.bonus.common.core.web.domain.BaseEntity;
public class AllocCanteen extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 是否分页 */
private boolean pagenation;
/** 主键id */
private Long canteenId;
@ -34,14 +37,19 @@ public class AllocCanteen extends BaseEntity {
@ApiModelProperty(value = "区域id")
private Long areaId;
/** 当前区域名称 */
@Excel(name = "当前区域名称")
@ApiModelProperty(value = "当前区域名称")
private String areaName;
/** 食堂业务类型 1-食堂 2-超市 */
@Excel(name = "食堂业务类型 1-食堂 2-超市")
@ApiModelProperty(value = "食堂业务类型 1-食堂 2-超市")
private Integer canteenType;
/** 负责人id */
@Excel(name = "负责人id")
@ApiModelProperty(value = "负责人id")
/** 负责人 */
@Excel(name = "负责人")
@ApiModelProperty(value = "负责人")
private Long director;
/** 联系电话 */
@ -56,14 +64,14 @@ public class AllocCanteen extends BaseEntity {
/** 营业时间 */
@ApiModelProperty(value = "营业时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "营业时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "HH:mm:ss")
@Excel(name = "营业时间", width = 30, dateFormat = "HH:mm:ss")
private Date startBusinessTime;
/** 营业时间 */
@ApiModelProperty(value = "营业时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "营业时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "HH:mm:ss")
@Excel(name = "营业时间", width = 30, dateFormat = "HH:mm:ss")
private Date endBusinessTime;
/** 食堂图片链接 */

View File

@ -21,6 +21,9 @@ import com.bonus.common.core.web.domain.BaseEntity;
public class AllocStall extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 是否分页 */
private boolean pagenation;
/** 档口id */
private Long stallId;
@ -34,11 +37,21 @@ public class AllocStall extends BaseEntity {
@ApiModelProperty(value = "区域id")
private Long areaId;
/** 当前区域名称 */
@Excel(name = "当前区域名称")
@ApiModelProperty(value = "当前区域名称")
private String areaName;
/** 食堂id */
@Excel(name = "食堂id")
@ApiModelProperty(value = "食堂id")
private Long canteenId;
/** 食堂名称 */
@Excel(name = "食堂名称")
@ApiModelProperty(value = "食堂名称")
private String canteenName;
/** 档口业务类型 1-档口 */
@Excel(name = "档口业务类型 1-档口")
@ApiModelProperty(value = "档口业务类型 1-档口")
@ -49,9 +62,9 @@ public class AllocStall extends BaseEntity {
@ApiModelProperty(value = "第三方档口id")
private String thirdStallId;
/** 负责人id */
@Excel(name = "负责人id")
@ApiModelProperty(value = "负责人id")
/** 负责人 */
@Excel(name = "负责人")
@ApiModelProperty(value = "负责人")
private Long director;
/** 联系电话 */
@ -71,14 +84,14 @@ public class AllocStall extends BaseEntity {
/** 营业时间 */
@ApiModelProperty(value = "营业时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "营业时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "HH:mm:ss")
@Excel(name = "营业时间", width = 30, dateFormat = "HH:mm:ss")
private Date startBusinessTime;
/** 营业时间 */
@ApiModelProperty(value = "营业时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "营业时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "HH:mm:ss")
@Excel(name = "营业时间", width = 30, dateFormat = "HH:mm:ss")
private Date endBusinessTime;
/** 是否启用叫号 */

View File

@ -2,7 +2,7 @@ package com.bonus.canteen.core.alloc.service;
import java.util.List;
import com.bonus.canteen.core.alloc.domain.AllocArea;
import com.bonus.canteen.core.alloc.domain.TreeSelect;
import com.bonus.canteen.core.common.domain.TreeSelect;
/**
* 区域Service接口

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.bonus.canteen.core.alloc.domain.TreeSelect;
import com.bonus.canteen.core.common.domain.TreeSelect;
import com.bonus.canteen.core.alloc.mapper.AllocAreaMapper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
@ -110,8 +110,8 @@ public class AllocAreaServiceImpl implements IAllocAreaService {
@Override
public List<TreeSelect> buildAreaTreeSelect(List<AllocArea> areas)
{
List<AllocArea> deptTrees = buildAreaTree(areas);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
List<AllocArea> areaTrees = buildAreaTree(areas);
return areaTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
@Override

View File

@ -1,11 +1,14 @@
package com.bonus.canteen.core.alloc.service.impl;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import com.bonus.canteen.core.alloc.domain.AllocCanteen;
import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.GlobalConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.alloc.service.IAllocCanteenService;
@ -96,4 +99,11 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService {
public int deleteAllocCanteenByCanteenId(Long canteenId) {
return allocCanteenMapper.deleteAllocCanteenByCanteenId(canteenId);
}
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("123.45");
long longValue = bigDecimal.multiply(new BigDecimal(100)).longValue();
System.out.println(longValue);
System.out.println(GlobalConstants.TENANT_ID + "_" + UUID.randomUUID().toString().replaceAll("-",""));
}
}

View File

@ -1,5 +1,6 @@
package com.bonus.canteen.core.alloc.domain;
package com.bonus.canteen.core.common.domain;
import com.bonus.canteen.core.alloc.domain.AllocArea;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;

View File

@ -0,0 +1,50 @@
package com.bonus.canteen.core.common.threadPool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
public class AsyncConfig {
// 核心线程数和最大线程数的倍数
private static final int THREAD_POOL_SIZE_MULTIPLIER = 2;
// 线程池队列容量
@Value("${async.threadPool.queueCapacity:1000}")
private int queueCapacity;
// 线程池线程存活时间
@Value("${async.threadPool.keepAliveSeconds:60}")
private int keepAliveSeconds;
// 线程池关闭时等待任务完成的时间
@Value("${async.threadPool.awaitTerminationSeconds:60}")
private int awaitTerminationSeconds;
@Bean("smartCanteenTaskExecutor")
public AsyncTaskExecutor taskExecutor() {
int corePoolSize = Runtime.getRuntime().availableProcessors() * THREAD_POOL_SIZE_MULTIPLIER;
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(corePoolSize);
taskExecutor.setMaxPoolSize(corePoolSize);
taskExecutor.setThreadNamePrefix("smart-canteen-async-pool");
taskExecutor.setQueueCapacity(queueCapacity);
taskExecutor.setKeepAliveSeconds(keepAliveSeconds);
taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
taskExecutor.setAwaitTerminationSeconds(awaitTerminationSeconds);
taskExecutor.setTaskDecorator(new TenantTaskDecorator());
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
try {
taskExecutor.initialize();
} catch (Exception e) {
throw new RuntimeException("Failed to initialize ThreadPoolTaskExecutor", e);
}
return taskExecutor;
}
}

View File

@ -0,0 +1,29 @@
package com.bonus.canteen.core.common.threadPool;
import com.bonus.canteen.core.common.utils.TenantContextHolder;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.task.TaskDecorator;
public class TenantTaskDecorator implements TaskDecorator {
private static final Logger log = LoggerFactory.getLogger(TenantTaskDecorator.class);
@Override
public Runnable decorate(Runnable runnable) {
Long tenantId = TenantContextHolder.getTenantId();
return () -> {
try {
TenantContextHolder.setTenantId(tenantId);
runnable.run();
} finally {
try {
TenantContextHolder.clear();
PageHelper.clearPage();
} catch (Exception e) {
log.error("Failed to clear tenant context or page helper", e);
}
}
};
}
}

View File

@ -0,0 +1,21 @@
package com.bonus.canteen.core.common.utils;
public final class TenantContextHolder {
private static final ThreadLocal<Long> THREAD_LOCAL_TENANT = new InheritableThreadLocal();
public static Long getTenantId() {
return (Long)THREAD_LOCAL_TENANT.get();
}
public static void setTenantId(Long tenantId) {
THREAD_LOCAL_TENANT.set(tenantId);
}
public static void clear() {
THREAD_LOCAL_TENANT.remove();
}
private TenantContextHolder() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.pay.constants;
public enum PayStateEnum {
UN_PAY(1, "未支付"),
PAY_INPROCESS(2, "支付中"),
PAY_SUCC(3, "支付成功"),
PAY_FAIL(4, "支付失败"),
PAY_CLOSE(5, "支付关闭"),
PART_PAY(6, "部分支付");
private final Integer key;
private final String desc;
private PayStateEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,123 @@
package com.bonus.canteen.core.pay.constants;
public enum PayTypeEnum {
MEAL_CARD(1, "账户支付"),
CASH(2, "现金支付"),
COUPON(3, "餐券支付"),
CASH_MACHINE(4, "设备现金支付"),
SUB_GRANT(5, "补贴"),
RED_GRANT(6, "红包"),
WX_RCB_NATIVE(7, "无锡农商行原生"),
ALI_QRCODE(10, "支付宝扫码"),
ALI_FACE(11, "支付宝人脸"),
ALI_NATIVE(12, "支付宝原生"),
OFFLINE_ALI_QRCODE(13, "支付宝线下扫码"),
ALI_APP_PAY(14, "支付宝app"),
ALI_DING_ACC_PAY(15, "钉工牌账户支付"),
ALI_DING_PAY(16, "钉工牌支付宝支付"),
ALI_PAY_WITHHOLD(17, "支付宝代扣"),
ALI_H5_PAY(18, "支付宝移动网页支付"),
WECHAT_QRCODE(20, "微信扫码"),
WECHAT_FACE(21, "微信k12人脸"),
WECHAT_NATIVE(22, "微信原生"),
WECHAT_WITHHOLD(23, "微信代扣"),
OFFLINE_WECHAT_QRCODE(24, "微信线下扫码"),
WECHAT_H5(25, "微信移动网页支付"),
UNION_PAY_QRCODE(30, "银联付款码"),
CLOUD_UNION_PAY(31, "云闪付"),
JINGDONG_PAY(40, "京东支付"),
CCB_PAY(41, "建行龙支付"),
BUSINESS_UNIFY_PAY(50, "商家统一支付"),
OTHER_QRCODE(60, "小程序二维码支付"),
OTHER_PAY(61, "其他支付"),
MIXTURE_PAY_ALI_QRCODE(70, "支付宝扫码(混合支付)"),
MIXTURE_PAY_WECHAT_QRCODE(71, "微信扫码(混合支付)"),
MIXTURE_PAY_ALI_NATIVE(72, "支付宝原生(混合支付)"),
MIXTURE_PAY_WECHAT_NATIVE(73, "微信原生(混合支付)"),
SHOU_QIAN_BA_PAY(80, "收钱吧支付"),
SHOU_QIAN_BA_MOBILE_H5(81, "收钱吧移动端h5支付"),
THIRD_DEVICE(98, "第三方设备支付"),
THIRD_ACC(99, "第三方账户支付"),
ABC_PAY_CODE(100, "农行付款码支付"),
ABC_ID_CODE(101, "农行身份码支付"),
ABC_ACCOUNT_PAY(102, "农行账户支付"),
ABC_QR_CODE_PAY(103, "农行扫码支付"),
ABC_CREDIT_PAY(104, "农行信用卡支付"),
ABC_AGENT_PAY(105, "农行授权免密支付"),
ICBC_PAY_CODE(110, "工行付款码支付"),
CMB_PAY_CODE(120, "招行扫码支付"),
CIB_PAY_CODE(121, "兴业银行扫码支付"),
ABC_DCEP_CODE_PAY(122, "数字人民币扫码支付"),
ECITIC_H5_PAY(123, "中信H5支付"),
ECITIC_PAY_CODE(124, "中信付款码支付"),
BOC_ACCOUNT_PAY(125, "中国银行账户支付"),
CHINA_PAY_CODE(126, "银联线上支付"),
BOC_AREA_CODE_ACCOUNT_PAY(127, "中国银行园区码-小牛账户支付"),
BOC_LENIU_CODE_ACCOUNT_PAY(128, "中国银行-小牛二维码账户支付"),
BOC_LENIU_CARD_ACCOUNT_PAY(129, "中国银行-小牛刷卡账户支付"),
BOC_LENIU_FACE_ACCOUNT_PAY(130, "中国银行-小牛刷脸账户支付"),
CIB_DCEP_CONTRACT(131, "数字人民币协议免密支付"),
TCRCB_PAY_H5(133, "太仓农商行支付"),
FUIOU_PAY_H5(132, "富友支付"),
ACC_BNJ_PAY(134, "南京银行免密支付"),
WECHAT_CARD_QR_CODE(135, "腾讯微卡电子码"),
WECHAT_CARD_H5(136, "腾讯微卡在线支付"),
CCB_PAY_H5(137, "建设银行H5支付"),
KSRCB_PAY_CODE(138, "昆山农商行付款码支付"),
CIB_DCEP_AUTH(139, "兴业银行数币密码支付"),
SZRCB_PAY_H5(140, "苏州农商行支付"),
BNJ_WECHAT_MINI(141, "微信小程序南京银行免密支付"),
NBCB_SETTLEMENT_PAY(142, "宁波银行结算支付"),
ABC_NATIVE(143, "农行页面下单"),
ABC_POS_MACHINE_PAY(144, "农行POS机刷卡支付"),
BNJ_H5_PAY(145, "南京银行H5支付"),
ABC_PAY_H5(146, "农行H5支付"),
ALI_ENTERPRISE_FACE(147, "支付宝企业刷脸"),
ALI_ENTERPRISE_QRCODE(148, "支付宝企业扫码"),
ALI_ENTERPRISE_WITHHOLD(149, "支付宝企业免密支付"),
ACC_SCAN(150, "收款码(账户)"),
ALI_SCAN(151, "收款码(支付宝)"),
WECHAT_SCAN(152, "收款码(微信)"),
ECITIC_H5_WECHAT_PAY(153, "微信支付(中信)"),
ECITIC_H5_UNCONSCIOUS_PAY(154, "中信无感支付"),
ABC_PAY_H5_WECHAT(155, "农行H5微信支付"),
ABC_PAY_H5_ALI(156, "农行H5支付宝支付"),
DIANDI_PAY_H5(157, "点滴支付H5支付"),
HMS_CAMPUS_CODE(158, "银联园区二维码支付"),
CIB_NATIVE(159, "兴业银行客户端支付"),
UMS_ENTRUST_PAY(160, "云闪付授权支付"),
HUAGENG_WECHAT_PAY(161, "华耕微信收款"),
HUAGENG_ALI_PAY(162, "华耕支付宝收款"),
HUAGENG_SUBSIDY_PAY(163, "华耕补贴消费"),
HUAGENG_POLYMERIZE_PAY(164, "华耕聚合收款"),
HUAGENG_CASH_PAY(165, "华耕手填现金"),
HUAGENG_SIGNING_PAY(166, "华耕手填签单"),
HUAGENG_COUPON_PAY(167, "华耕手填餐券"),
SODEXO_QRCODE(168, "索迪斯二维码支付"),
TC_SSC_CARD_PAY(169, "太仓社保卡支付"),
CMB_H5_CARD_PAY(170, "招行一网通支付"),
ZY_WECHAT_PAY(171, "正元微信支付"),
ZY_ALI_PAY(172, "正元支付宝支付"),
ZY_ACC_PAY(173, "正元账户支付"),
ZY_CCB_PAY(174, "正元建行支付"),
ICBC_JFT_H5(175, "工行聚富通支付"),
ABC_WECHAT_BRIDGE(176, "微信支付(农行)");
private final Integer key;
private final String desc;
private PayTypeEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.pay.constants;
public enum TradeTypeEnum {
RECHARGE(1, "充值"),
RECHARGE_REFUND(2, "充值退款"),
CONSUME(3, "消费"),
CONSUME_REFUND(4, "消费退款");
private final Integer key;
private final String desc;
private TradeTypeEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
}

View File

@ -2,9 +2,14 @@ package com.bonus.canteen.core.pay.controller;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.bonus.canteen.core.account.constants.AccTradeStateEnum;
import com.bonus.canteen.core.account.service.IAccTradeService;
import com.bonus.canteen.core.pay.constants.PayStateEnum;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import com.bonus.canteen.core.pay.util.AlipayConfig;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@ -20,6 +25,10 @@ import java.util.Map;
@RestController
@RequestMapping("/alipay/notify")
public class NotifyCotroller {
@Autowired
IAccTradeService accTradeService;
@RequestMapping("getnotify")
public void getNotify(HttpServletRequest request, HttpServletResponse response) throws AlipayApiException, IOException {
Map<String, String> params = new HashMap<String, String>();
@ -42,11 +51,11 @@ public class NotifyCotroller {
PrintWriter out = response.getWriter();
if (singVerified) {
//商户订单号
String out_trade_no = request.getParameter("out_trade_no");
//商户订单号
String order_no = request.getParameter("out_trade_no");
//金额
String total_amount = request.getParameter("total_amount");
//支付宝交易号
String trade_no = request.getParameter("trade_no");
String third_trade_no = request.getParameter("trade_no");
//交易状态
String trade_status = request.getParameter("trade_status");
if ("TRADE_FINISHED".equals(trade_status)) {
@ -54,11 +63,34 @@ public class NotifyCotroller {
//如果没做过处理根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详情判断金额是否等于 total_amount并执行商户的业务程序
//如果做过处理不执行商户的业务程序
//注意 退款日期超过可退款期限后如三个月可退款支付宝系统发送该交易状态 TRADE_FINISHED
AccTradeVo updateTrade = new AccTradeVo();
updateTrade.setOrderNo(order_no);
updateTrade.setThirdTradeNo(third_trade_no);
updateTrade.setPayState(PayStateEnum.PAY_SUCC.getKey().longValue());
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
updateTrade.setFailReason(trade_status);
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
} else if ("TRADE_SUCCESS".equals(trade_status)) {
//判断该笔订单是否已经做过处理
//如果没做过处理根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详情判断金额是否等于 total_amount并执行商户的业务程序
//如果做过处理不执行商户的业务程序
//注意 付款完成后支付宝系统发送该交易状态 TRADE_SUCCESS
AccTradeVo updateTrade = new AccTradeVo();
updateTrade.setOrderNo(order_no);
updateTrade.setThirdTradeNo(third_trade_no);
updateTrade.setPayState(PayStateEnum.PAY_SUCC.getKey().longValue());
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
updateTrade.setFailReason(trade_status);
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
//TODO 增加用户的个人钱包 acc_wallet_info
} else {
AccTradeVo updateTrade = new AccTradeVo();
updateTrade.setOrderNo(order_no);
updateTrade.setThirdTradeNo(third_trade_no);
updateTrade.setPayState(PayStateEnum.PAY_FAIL.getKey().longValue());
updateTrade.setTradeState(AccTradeStateEnum.CLOSE.getKey().longValue());
updateTrade.setFailReason(trade_status);
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
}
out.println("success");

View File

@ -4,15 +4,28 @@ import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.bonus.canteen.core.account.constants.AccTradeStateEnum;
import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
import com.bonus.canteen.core.account.service.IAccTradeService;
import com.bonus.canteen.core.pay.constants.PayStateEnum;
import com.bonus.canteen.core.pay.constants.PayTypeEnum;
import com.bonus.canteen.core.pay.util.AlipayConfig;
import com.bonus.canteen.core.pay.dto.UpOrder;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import com.bonus.common.houqin.constant.GlobalConstants;
import com.bonus.common.security.utils.SecurityUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
@Slf4j
@Api(tags = "支付接口")
@ -23,23 +36,40 @@ public class PayCotroller {
AlipayClient alipayClient;
@Resource
AlipayTradePagePayRequest alipayRequest;
@Autowired
IAccTradeService accTradeService;
@RequestMapping("pay")
public void pay(UpOrder order, HttpServletResponse response) throws AlipayApiException, IOException {
public void pay(@RequestBody AccTradeVo accTradeVo, HttpServletResponse response) throws AlipayApiException, IOException {
// 预装数据存档
accTradeVo.setUserId(SecurityUtils.getUserId());
accTradeVo.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
accTradeVo.setTradeType(AccTradeTypeEnum.CONSUME.getKey().longValue());
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
accTradeVo.setOrderNo(GlobalConstants.TENANT_ID + "_" + UUID.randomUUID().toString().replaceAll("-","") + "_" + sdf.format(date));
accTradeVo.setOrderName(GlobalConstants.TENANT_ID + "_" + SecurityUtils.getUserId() + "_" + GlobalConstants.PERSONAL_RECHARGE + "_" + sdf.format(date));
accTradeVo.setTradeTime(new Date());
accTradeVo.setAmount(accTradeVo.getPaymentAmount().multiply(new BigDecimal(100)).longValue());
accTradeVo.setPayType(PayTypeEnum.MEAL_CARD.getKey().longValue());
accTradeVo.setPayState(PayStateEnum.PAY_INPROCESS.getKey().longValue());
accTradeVo.setTradeState(AccTradeStateEnum.CREATE.getKey().longValue());
accTradeService.insertAccTradeVo(accTradeVo);
// 调用alipay
alipayRequest.setBizContent(
"{\"out_trade_no\":\""+ accTradeVo.getOrderNo() +"\","
+ "\"total_amount\":\""+ accTradeVo.getPaymentAmount().toString() +"\","
+ "\"subject\":\""+ accTradeVo.getOrderName() +"\","
+ "\"body\":\""+ accTradeVo.getProductDesc() +"\","
+ "\"timeout_express\":\"10m\","
+ "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
alipayRequest.setReturnUrl(AlipayConfig.return_url);
alipayRequest.setNotifyUrl(AlipayConfig.notify_url);
alipayRequest.setBizContent(
"{\"out_trade_no\":\""+ order.getCode() +"\","
+ "\"total_amount\":\""+ order.getPaymentAmount().toString() +"\","
+ "\"subject\":\""+ order.getOrderName() +"\","
+ "\"body\":\""+ order.getProductDesc() +"\","
//+ "\"timeout_express\":\"10m\","
+ "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
AlipayTradePagePayResponse alipayResponse = alipayClient.pageExecute(alipayRequest);
log.info("alipay body = " + alipayResponse.getBody());
log.info("alipay msg = " + alipayResponse.getMsg());
response.setContentType("text/html;charset=UTF-8");
response.getWriter().println(alipayResponse.getBody()); //write(alipayResponse.getBody());
response.getWriter().println(alipayResponse.getBody());
response.getWriter().flush();
}
}

View File

@ -1,17 +0,0 @@
package com.bonus.canteen.core.pay.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class UpOrder {
private String code;//商户订单号, 商户网站订单系统中唯一订单号必填
private String orderName;//订单名称, 必填
private BigDecimal paymentAmount;//付款金额, 必填
private String productDesc;//商品描述
private String createBy;//创建人Code
private Long createTime;//创建时间时间戳
private Integer createByType;//创建人类型 1-专家 2-企业用户
private Boolean status;//是否付款 true - 已付 false-未付
private Long payTime;//订单支付时间-支付后才存在 时间戳
}

View File

@ -8,11 +8,11 @@ public class AlipayConfig {
// 支付宝公钥,查看地址https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥
public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqpPYMDEBTiLgH08AnVYMH1WfHlB5dZC8+/mRq/4aHmvKpGdRgeE11EylhVLsm2N5ryNYI6THgwQpL0jJ9g3lTaq4+KzR8LkJlBbyFrnaflB/3AtNQugg59f77eMSjHx4cTKbLWtyRfxNR2QK6AjBLkMH2+v3GL/4dn0aGml9fcN0/+/cL4xLH8g8HJ1DE+MGx6cJGQhuE7eQqsUkmm/Bs7ElbXfOFHWhLFOAgZ/98Ieeog5JDnewGMl4yqyytFIPcv2/VDlb46MmnZciwXYmZh5W1B9ltmO6LNv/Jj0itWB1ObTGzKJf9WQDG2Xq38JqFm0TttJAKxYb95ZQGZnmwIDAQAB";
// 服务器异步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问
public static String notify_url = "http://aa7xmz.natappfree.cc/alipay/notify/getnotify";
public static String notify_url = "http://13866134935.gnway.cc:80/smart-canteen/alipay/notify/getnotify";
// 页面跳转同步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问//标红的域名为内网穿透工具生成的域名没启动一次穿透工具生成的域名都不一样所有启动一次都需要进行修改
public static String return_url = "http://aa7xmz.natappfree.cc/alipay/return/getreturn";
public static String return_url = "http://13866134935.gnway.cc:80/smart-canteen/alipay/return/getreturn";
// 支付宝网关
public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
// 签名方式
public static String SIGNTYPE = "RSA2";
// 字符编码格式

View File

@ -4,7 +4,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.account.mapper.AccInfoMapper">
<resultMap type="com.bonus.canteen.core.account.domain.AccInfo" id="AccInfoResult">
<result property="id" column="id" />
<result property="accId" column="acc_id" />
<result property="accName" column="acc_name" />
<result property="userId" column="user_id" />
@ -61,7 +60,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAccInfoVo">
select id, acc_id, acc_name, user_id, wallet_bal, subsidy_bal, red_envelope, subsidy_freeze_bal, acc_bal, balance2, water_wallet_bal, water_subsidy_bal, freeze_wallet_bal, freeze_subsidy_bal, freeze_red_envelope, wallet_over_bal, sub_over_bal, scope, end_date, red_validity_date, acc_status, pay_pwd, sub_date_flag, sub_month_flag, acc_pay_count, last_credit_time, interval_id, curr_credit_count, curr_brush_count, curr_use_reserve_count1, curr_use_reserve_count2, same_day_count, same_month_count, curr_cumu_amount, day_cumu_amount, month_sumu_amount, min_wallet_bal_limit, min_red_bal_limit, min_sub_bal_limit, month_full_reduce_amount, last_full_reduce_time, last_sub_time, sub_validity_date, last_sub_amount, last_wal_time, last_wal_amount, revision, reserved1, reserved2, reserved3, create_by, create_time, update_by, update_time from acc_info
select acc_id, acc_name, user_id, wallet_bal, subsidy_bal, red_envelope, subsidy_freeze_bal,
acc_bal, balance2, water_wallet_bal, water_subsidy_bal, freeze_wallet_bal, freeze_subsidy_bal,
freeze_red_envelope, wallet_over_bal, sub_over_bal, scope, end_date, red_validity_date,
acc_status, pay_pwd, sub_date_flag, sub_month_flag, acc_pay_count, last_credit_time,
interval_id, curr_credit_count, curr_brush_count, curr_use_reserve_count1, curr_use_reserve_count2,
same_day_count, same_month_count, curr_cumu_amount, day_cumu_amount, month_sumu_amount,
min_wallet_bal_limit, min_red_bal_limit, min_sub_bal_limit, month_full_reduce_amount,
last_full_reduce_time, last_sub_time, sub_validity_date, last_sub_amount, last_wal_time, last_wal_amount,
revision, reserved1, reserved2, reserved3, create_by, create_time, update_by, update_time
from acc_info
</sql>
<select id="selectAccInfoList" parameterType="com.bonus.canteen.core.account.domain.AccInfo" resultMap="AccInfoResult">
@ -118,16 +126,70 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="reserved3 != null and reserved3 != ''"> and reserved3 = #{reserved3}</if>
</where>
</select>
<select id="selectAccInfoVo" parameterType="com.bonus.canteen.core.account.domain.AccInfo" resultType="com.bonus.canteen.core.account.domain.AccInfoVo">
<include refid="selectAccInfoVo"/>
<where>
<if test="accId != null "> and acc_id = #{accId}</if>
<if test="accName != null and accName != ''"> and acc_name like concat('%', #{accName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="walletBal != null "> and wallet_bal = #{walletBal}</if>
<if test="subsidyBal != null "> and subsidy_bal = #{subsidyBal}</if>
<if test="redEnvelope != null "> and red_envelope = #{redEnvelope}</if>
<if test="subsidyFreezeBal != null "> and subsidy_freeze_bal = #{subsidyFreezeBal}</if>
<if test="accBal != null "> and acc_bal = #{accBal}</if>
<if test="balance2 != null "> and balance2 = #{balance2}</if>
<if test="waterWalletBal != null "> and water_wallet_bal = #{waterWalletBal}</if>
<if test="waterSubsidyBal != null "> and water_subsidy_bal = #{waterSubsidyBal}</if>
<if test="freezeWalletBal != null "> and freeze_wallet_bal = #{freezeWalletBal}</if>
<if test="freezeSubsidyBal != null "> and freeze_subsidy_bal = #{freezeSubsidyBal}</if>
<if test="freezeRedEnvelope != null "> and freeze_red_envelope = #{freezeRedEnvelope}</if>
<if test="walletOverBal != null "> and wallet_over_bal = #{walletOverBal}</if>
<if test="subOverBal != null "> and sub_over_bal = #{subOverBal}</if>
<if test="scope != null "> and scope = #{scope}</if>
<if test="endDate != null "> and end_date = #{endDate}</if>
<if test="redValidityDate != null "> and red_validity_date = #{redValidityDate}</if>
<if test="accStatus != null "> and acc_status = #{accStatus}</if>
<if test="payPwd != null and payPwd != ''"> and pay_pwd = #{payPwd}</if>
<if test="subDateFlag != null "> and sub_date_flag = #{subDateFlag}</if>
<if test="subMonthFlag != null "> and sub_month_flag = #{subMonthFlag}</if>
<if test="accPayCount != null "> and acc_pay_count = #{accPayCount}</if>
<if test="lastCreditTime != null "> and last_credit_time = #{lastCreditTime}</if>
<if test="intervalId != null "> and interval_id = #{intervalId}</if>
<if test="currCreditCount != null "> and curr_credit_count = #{currCreditCount}</if>
<if test="currBrushCount != null "> and curr_brush_count = #{currBrushCount}</if>
<if test="currUseReserveCount1 != null "> and curr_use_reserve_count1 = #{currUseReserveCount1}</if>
<if test="currUseReserveCount2 != null "> and curr_use_reserve_count2 = #{currUseReserveCount2}</if>
<if test="sameDayCount != null "> and same_day_count = #{sameDayCount}</if>
<if test="sameMonthCount != null "> and same_month_count = #{sameMonthCount}</if>
<if test="currCumuAmount != null "> and curr_cumu_amount = #{currCumuAmount}</if>
<if test="dayCumuAmount != null "> and day_cumu_amount = #{dayCumuAmount}</if>
<if test="monthSumuAmount != null "> and month_sumu_amount = #{monthSumuAmount}</if>
<if test="minWalletBalLimit != null "> and min_wallet_bal_limit = #{minWalletBalLimit}</if>
<if test="minRedBalLimit != null "> and min_red_bal_limit = #{minRedBalLimit}</if>
<if test="minSubBalLimit != null "> and min_sub_bal_limit = #{minSubBalLimit}</if>
<if test="monthFullReduceAmount != null "> and month_full_reduce_amount = #{monthFullReduceAmount}</if>
<if test="lastFullReduceTime != null "> and last_full_reduce_time = #{lastFullReduceTime}</if>
<if test="lastSubTime != null "> and last_sub_time = #{lastSubTime}</if>
<if test="subValidityDate != null "> and sub_validity_date = #{subValidityDate}</if>
<if test="lastSubAmount != null "> and last_sub_amount = #{lastSubAmount}</if>
<if test="lastWalTime != null "> and last_wal_time = #{lastWalTime}</if>
<if test="lastWalAmount != null "> and last_wal_amount = #{lastWalAmount}</if>
<if test="revision != null "> and revision = #{revision}</if>
<if test="reserved1 != null and reserved1 != ''"> and reserved1 = #{reserved1}</if>
<if test="reserved2 != null and reserved2 != ''"> and reserved2 = #{reserved2}</if>
<if test="reserved3 != null and reserved3 != ''"> and reserved3 = #{reserved3}</if>
</where>
</select>
<select id="selectAccInfoById" parameterType="Long" resultMap="AccInfoResult">
<include refid="selectAccInfoVo"/>
where id = #{id}
where acc_id = #{accId}
</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
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="accId != null">acc_id,</if>
<if test="accName != null and accName != ''">acc_name,</if>
<if test="userId != null">user_id,</if>
<if test="walletBal != null">wallet_bal,</if>
@ -182,7 +244,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accId != null">#{accId},</if>
<if test="accName != null and accName != ''">#{accName},</if>
<if test="userId != null">#{userId},</if>
<if test="walletBal != null">#{walletBal},</if>
@ -295,17 +356,147 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
where acc_id = #{accId}
</update>
<delete id="deleteAccInfoById" parameterType="Long">
delete from acc_info where id = #{id}
<delete id="deleteAccInfoByUserId" parameterType="Long">
delete from acc_info where user_id = #{userId}
</delete>
<delete id="deleteAccInfoByIds" parameterType="String">
delete from acc_info where id in
delete from acc_info where acc_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
#{accId}
</foreach>
</delete>
</mapper>
<select id="queryAccInfoInvalidSum" resultType="java.lang.Integer">
SELECT count( a.acc_id ) FROM acc_info a
WHERE a.acc_status = #{accStatus} AND a.update_time BETWEEN #{startDateTime} and #{endDateTime}
</select>
<select id="queryAccInfoDetails" resultType="com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO">
SELECT
t1.update_time,
t1.acc_id,
t2.user_id,
t2.nick_name,
t2.phonenumber as phoneNumber,
t6.dept_name,
t7.dict_label as userTypeName,
t7.dict_value as userType,
t1.scope,
t1.acc_status,
t1.end_date
FROM acc_info t1
INNER JOIN sys_user t2 ON t1.user_id = t2.user_id
LEFT JOIN sys_dept t6 on t6.dept_id = t2.dept_id
LEFT JOIN sys_dict_data t7 on t7.dict_type = 'user_psn_type' and t7.dict_value = t2.user_type
<include refid="queryAccountInfo_ref"/>
order by t2.create_time desc
</select>
<select id="queryAccInfoBalanceSum" resultType="com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO">
SELECT
SUM( t4.accBalTotal ) AS accBalTotal,
SUM( t4.walletBal ) AS walletBal,
SUM( t4.subsidyBal ) AS subsidyBal,
SUM( t4.accFreezeBalTotal ) AS accFreezeBalTotal
FROM acc_info t1
INNER JOIN sys_user t2 ON t1.user_id = t2.user_id
LEFT JOIN
(
SELECT
user_id,
SUM( CASE WHEN wallet_id = 1 THEN wallet_bal ELSE 0 END ) AS walletBal,
SUM( CASE WHEN wallet_id = 2 THEN wallet_bal ELSE 0 END ) AS subsidyBal,
SUM( a.wallet_bal ) AS accAvailableBal,
SUM( a.frozen_balance ) AS accFreezeBalTotal,
SUM( a.wallet_bal ) + SUM( a.frozen_balance ) AS accBalTotal
FROM acc_wallet_info a
GROUP BY user_id
) AS t4 ON t4.user_id = t1.user_id
<include refid="queryAccountInfo_ref"/>
</select>
<sql id="queryAccountInfo_ref">
<where>
t1.acc_status in
<foreach collection="accountInfoQueryParam.accStatusList" item="accStatus" separator="," open="(" close=")">
#{accStatus}
</foreach>
<if test="accountInfoQueryParam.searchValue != null and accountInfoQueryParam.searchValue != ''">
and (t2.nick_name = #{accountInfoQueryParam.searchValue}
or t2.phonenumber = #{encryptedSearchValue}
or t2.nick_name_like LIKE CONCAT('%',#{accountInfoQueryParam.searchValue},'%')
)
</if>
<if test="accountInfoQueryParam.deptIdList != null and accountInfoQueryParam.deptIdList.size() > 0">
and t2.dept_id in
<foreach collection="accountInfoQueryParam.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="accountInfoQueryParam.startDateTime != null">
and t1.uptime <![CDATA[ >= ]]> #{accountInfoQueryParam.startDateTime}
</if>
<if test="accountInfoQueryParam.endDateTime != null">
and t1.uptime <![CDATA[ <= ]]> #{accountInfoQueryParam.endDateTime}
</if>
<if test="accountInfoQueryParam.walletType != null">
AND EXISTS(
SELECT null FROM
(
SELECT
user_id,
SUM( CASE WHEN wallet_id = 1 THEN wallet_bal ELSE 0 END ) AS walletBal,
SUM( CASE WHEN wallet_id = 2 THEN wallet_bal ELSE 0 END ) AS subsidyBal,
SUM( a.wallet_bal ) + SUM( a.frozen_balance ) accBalTotal
FROM
acc_wallet_info a
GROUP BY
user_id
) AS t4
<where>
t4.user_id = t1.user_id
<!--
<if test="accountInfoQueryParam.walletMinAmount != null">
<if test="accountInfoQueryParam.walletType == 0">
and t4.accBalTotal <![CDATA[ >= ]]> #{accountInfoQueryParam.walletMinAmount}
</if>
<if test="accountInfoQueryParam.walletType == 1">
and t4.walletBal <![CDATA[ >= ]]> #{accountInfoQueryParam.walletMinAmount}
</if>
<if test="accountInfoQueryParam.walletType == 2">
and t4.subsidyBal <![CDATA[ >= ]]> #{accountInfoQueryParam.walletMinAmount}
</if>
</if>
<if test="accountInfoQueryParam.walletMaxAmount != null">
<if test="accountInfoQueryParam.walletType == 0">
and t4.accBalTotal <![CDATA[ <= ]]> #{accountInfoQueryParam.walletMaxAmount}
</if>
<if test="accountInfoQueryParam.walletType == 1">
and t4.walletBal <![CDATA[ <= ]]> #{accountInfoQueryParam.walletMaxAmount}
</if>
<if test="accountInfoQueryParam.walletType == 2">
and t4.subsidyBal <![CDATA[ <= ]]> #{accountInfoQueryParam.walletMaxAmount}
</if>
</if>
-->
</where>
)
</if>
</where>
</sql>
<update id="updateAccInfoEndDateByUserId">
update acc_info
set end_date = #{endDate},
update_by = #{updateBy},
update_time = now()
where user_id in
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
</mapper>

View File

@ -0,0 +1,45 @@
<?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.bonus.canteen.core.account.mapper.AccOperationHistoryMapper">
<select id="queryPageAccOperationRecord" resultType="com.bonus.canteen.core.account.domain.bo.AccOperationHistory">
SELECT aop.id,
aop.user_id,
su.nick_name as userName,
su.phonenumber as phone,
sd.dept_name,
aop.type,
aop.create_by,
aop.create_time
FROM acc_operation_history aop
LEFT JOIN sys_user su ON aop.user_id = su.user_id
LEFT JOIN sys_dept sd on sd.dept_id = su.dept_id
<where>
<if test="param.startDateTime != null">
and aop.create_time <![CDATA[ >= ]]> #{param.startDateTime}
</if>
<if test="param.endDateTime != null">
and aop.create_time <![CDATA[ <= ]]> #{param.endDateTime}
</if>
<if test="param.type != null">
and aop.type = #{param.type}
</if>
<if test="param.deptIds != null and param.deptIds.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIds" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.createBy != null and param.createBy != ''">
and aop.create_by like #{param.createBy}
</if>
<if test="param.searchValue != null and param.searchValue != '' ">
and (su.nick_name = #{param.searchValue}
or su.phonenumber = #{encryptedSearchValue}
)
</if>
</where>
ORDER BY `id` DESC
</select>
</mapper>

View File

@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="thirdTradeNo" column="third_trade_no" />
<result property="machineSn" column="machine_sn" />
<result property="batchNum" column="batch_num" />
<result property="leOrdNo" column="le_ord_no" />
<result property="orderNo" column="order_no" />
<result property="originTradeId" column="origin_trade_id" />
<result property="subTimeRuleId" column="sub_time_rule_id" />
<result property="manageCost" column="manage_cost" />
@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="thirdTradeNo != null and thirdTradeNo != ''"> and third_trade_no = #{thirdTradeNo}</if>
<if test="machineSn != null and machineSn != ''"> and machine_sn = #{machineSn}</if>
<if test="batchNum != null and batchNum != ''"> and batch_num = #{batchNum}</if>
<if test="leOrdNo != null "> and le_ord_no = #{leOrdNo}</if>
<if test="orderNo != null "> and order_no = #{orderNo}</if>
<if test="originTradeId != null "> and origin_trade_id = #{originTradeId}</if>
<if test="subTimeRuleId != null "> and sub_time_rule_id = #{subTimeRuleId}</if>
<if test="manageCost != null "> and manage_cost = #{manageCost}</if>
@ -101,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="thirdTradeNo != null">third_trade_no,</if>
<if test="machineSn != null">machine_sn,</if>
<if test="batchNum != null">batch_num,</if>
<if test="leOrdNo != null">le_ord_no,</if>
<if test="orderNo != null">order_no,</if>
<if test="originTradeId != null">origin_trade_id,</if>
<if test="subTimeRuleId != null">sub_time_rule_id,</if>
<if test="manageCost != null">manage_cost,</if>
@ -136,7 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="thirdTradeNo != null">#{thirdTradeNo},</if>
<if test="machineSn != null">#{machineSn},</if>
<if test="batchNum != null">#{batchNum},</if>
<if test="leOrdNo != null">#{leOrdNo},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="originTradeId != null">#{originTradeId},</if>
<if test="subTimeRuleId != null">#{subTimeRuleId},</if>
<if test="manageCost != null">#{manageCost},</if>
@ -174,7 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="thirdTradeNo != null">third_trade_no = #{thirdTradeNo},</if>
<if test="machineSn != null">machine_sn = #{machineSn},</if>
<if test="batchNum != null">batch_num = #{batchNum},</if>
<if test="leOrdNo != null">le_ord_no = #{leOrdNo},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
<if test="originTradeId != null">origin_trade_id = #{originTradeId},</if>
<if test="subTimeRuleId != null">sub_time_rule_id = #{subTimeRuleId},</if>
<if test="manageCost != null">manage_cost = #{manageCost},</if>
@ -195,6 +195,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where trade_id = #{tradeId}
</update>
<update id="updateAccTradeVoByOrderNo" parameterType="com.bonus.canteen.core.account.domain.vo.AccTradeVo">
update acc_trade
set
third_trade_no = #{thirdTradeNo},pay_state = #{payState},
trade_state = #{tradeState},fail_reason = #{failReason},update_time = #{updateTime}
where order_no = #{orderNo}
</update>
<delete id="deleteAccTradeByTradeId" parameterType="Long">
delete from acc_trade where trade_id = #{tradeId}
</delete>

View File

@ -40,6 +40,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectAccWalletInfoVo"/>
where user_id = #{userId}
</select>
<select id="selectAccWalletInfoByUserIds" resultType="com.bonus.canteen.core.account.domain.vo.AccWalletInfoVO">
SELECT
user_id,
acc_id,
wallet_id,
wallet_bal,
limit_balance,
frozen_balance,
last_subsidy_amount,
last_subsidy_time
FROM acc_wallet_info
WHERE user_id IN
<foreach collection="userIds" item="userId" separator="," open="(" close=")">
#{userId}
</foreach>
</select>
<insert id="insertAccWalletInfo" parameterType="com.bonus.canteen.core.account.domain.AccWalletInfo">
insert into acc_wallet_info
@ -75,6 +92,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</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 acc_wallet_info
<trim prefix="SET" suffixOverrides=",">
@ -104,4 +132,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{userId}
</foreach>
</delete>
<update id="updateMinBalanceByUserId">
UPDATE
acc_wallet_info
SET limit_balance = #{minBalance},
update_by = #{updateBy},
update_time = #{updateTime}
<where>
<if test="userIds != null and userIds.size() != 0">
AND user_id IN
<foreach collection="userIds" item="userId" separator="," open="(" close=")">
#{userId}
</foreach>
</if>
AND wallet_id = #{walletId}
</where>
</update>
</mapper>

View File

@ -32,36 +32,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAllocCanteenVo">
select canteen_id, canteen_name, area_id, canteen_type, director, contact_tel, business_state, start_business_time, end_business_time, img_url, if_enable_pay, pay_types, if_enable_delivery, deliveries, if_enable_order, if_book, if_reserve, if_enable_pay_code, pay_code_url, del_flag, create_by, create_time, update_by, update_time, remark from alloc_canteen
select ac.canteen_id, ac.canteen_name, aa.area_name, ac.area_id, ac.canteen_type, ac.director, ac.contact_tel, ac.business_state,
ac.start_business_time, ac.end_business_time, ac.img_url, ac.if_enable_pay, ac.pay_types, ac.if_enable_delivery,
ac.deliveries, ac.if_enable_order, ac.if_book, ac.if_reserve, ac.if_enable_pay_code, ac.pay_code_url, ac.del_flag,
ac.create_by, ac.create_time, ac.update_by, ac.update_time, ac.remark
from alloc_canteen ac
left join alloc_area aa on ac.area_id = aa.area_id
</sql>
<select id="selectAllocCanteenList" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteen" resultMap="AllocCanteenResult">
<include refid="selectAllocCanteenVo"/>
<where>
<if test="canteenName != null and canteenName != ''"> and canteen_name like concat('%', #{canteenName}, '%')</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="canteenType != null "> and canteen_type = #{canteenType}</if>
<if test="director != null "> and director = #{director}</if>
<if test="contactTel != null and contactTel != ''"> and contact_tel = #{contactTel}</if>
<if test="businessState != null "> and business_state = #{businessState}</if>
<if test="startBusinessTime != null "> and start_business_time = #{startBusinessTime}</if>
<if test="endBusinessTime != null "> and end_business_time = #{endBusinessTime}</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="ifEnablePay != null "> and if_enable_pay = #{ifEnablePay}</if>
<if test="payTypes != null and payTypes != ''"> and pay_types = #{payTypes}</if>
<if test="ifEnableDelivery != null "> and if_enable_delivery = #{ifEnableDelivery}</if>
<if test="deliveries != null and deliveries != ''"> and deliveries = #{deliveries}</if>
<if test="ifEnableOrder != null "> and if_enable_order = #{ifEnableOrder}</if>
<if test="ifBook != null "> and if_book = #{ifBook}</if>
<if test="ifReserve != null "> and if_reserve = #{ifReserve}</if>
<if test="ifEnablePayCode != null "> and if_enable_pay_code = #{ifEnablePayCode}</if>
<if test="payCodeUrl != null and payCodeUrl != ''"> and pay_code_url = #{payCodeUrl}</if>
<if test="canteenName != null and canteenName != ''"> and ac.canteen_name like concat('%', #{canteenName}, '%')</if>
<if test="areaId != null "> and ac.area_id = #{areaId}</if>
<if test="canteenType != null "> and ac.canteen_type = #{canteenType}</if>
<if test="director != null "> and ac.director = #{director}</if>
<if test="contactTel != null and contactTel != ''"> and ac.contact_tel = #{contactTel}</if>
<if test="businessState != null "> and ac.business_state = #{businessState}</if>
<if test="startBusinessTime != null "> and ac.start_business_time = #{startBusinessTime}</if>
<if test="endBusinessTime != null "> and ac.end_business_time = #{endBusinessTime}</if>
<if test="imgUrl != null and imgUrl != ''"> and ac.img_url = #{imgUrl}</if>
<if test="ifEnablePay != null "> and ac.if_enable_pay = #{ifEnablePay}</if>
<if test="payTypes != null and payTypes != ''"> and ac.pay_types = #{payTypes}</if>
<if test="ifEnableDelivery != null "> and ac.if_enable_delivery = #{ifEnableDelivery}</if>
<if test="deliveries != null and deliveries != ''"> and ac.deliveries = #{deliveries}</if>
<if test="ifEnableOrder != null "> and ac.if_enable_order = #{ifEnableOrder}</if>
<if test="ifBook != null "> and ac.if_book = #{ifBook}</if>
<if test="ifReserve != null "> and ac.if_reserve = #{ifReserve}</if>
<if test="ifEnablePayCode != null "> and ac.if_enable_pay_code = #{ifEnablePayCode}</if>
<if test="payCodeUrl != null and payCodeUrl != ''"> and ac.pay_code_url = #{payCodeUrl}</if>
</where>
</select>
<select id="selectAllocCanteenByCanteenId" parameterType="Long" resultMap="AllocCanteenResult">
<include refid="selectAllocCanteenVo"/>
where canteen_id = #{canteenId}
where ac.canteen_id = #{canteenId}
</select>
<insert id="insertAllocCanteen" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteen" useGeneratedKeys="true" keyProperty="canteenId">

View File

@ -35,40 +35,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAllocStallVo">
select stall_id, stall_name, area_id, canteen_id, stall_type, third_stall_id, director, contact_tel, main_project, business_state, start_business_time, end_business_time, if_use_call_num, on_line_meal_code_prefix, off_line_meal_code_prefix, if_enable_delivery, deliveries, if_enable_order, img_url, if_book, if_reserve, if_enable_pay_code, pay_code_url, del_flag, create_by, create_time, update_by, update_time from alloc_stall
select ast.stall_id, ast.stall_name, ast.area_id, ast.canteen_id, ac.canteen_name, aa.area_name,
ast.stall_type, ast.third_stall_id, ast.director, ast.contact_tel,
ast.main_project, ast.business_state, ast.start_business_time, ast.end_business_time, ast.if_use_call_num,
ast.on_line_meal_code_prefix, ast.off_line_meal_code_prefix, ast.if_enable_delivery, ast.deliveries,
ast.if_enable_order, ast.img_url, ast.if_book, ast.if_reserve, ast.if_enable_pay_code, ast.pay_code_url,
ast.del_flag, ast.create_by, ast.create_time, ast.update_by, ast.update_time
from alloc_stall ast
left join alloc_canteen ac on ast.canteen_id = ac.canteen_id
left join alloc_area aa on ac.area_id = aa.area_id
</sql>
<select id="selectAllocStallList" parameterType="com.bonus.canteen.core.alloc.domain.AllocStall" resultMap="AllocStallResult">
<include refid="selectAllocStallVo"/>
<where>
<if test="stallName != null and stallName != ''"> and stall_name like concat('%', #{stallName}, '%')</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="canteenId != null "> and canteen_id = #{canteenId}</if>
<if test="stallType != null "> and stall_type = #{stallType}</if>
<if test="thirdStallId != null and thirdStallId != ''"> and third_stall_id = #{thirdStallId}</if>
<if test="director != null "> and director = #{director}</if>
<if test="contactTel != null and contactTel != ''"> and contact_tel = #{contactTel}</if>
<if test="mainProject != null and mainProject != ''"> and main_project = #{mainProject}</if>
<if test="businessState != null "> and business_state = #{businessState}</if>
<if test="startBusinessTime != null "> and start_business_time = #{startBusinessTime}</if>
<if test="endBusinessTime != null "> and end_business_time = #{endBusinessTime}</if>
<if test="ifUseCallNum != null "> and if_use_call_num = #{ifUseCallNum}</if>
<if test="onLineMealCodePrefix != null and onLineMealCodePrefix != ''"> and on_line_meal_code_prefix = #{onLineMealCodePrefix}</if>
<if test="offLineMealCodePrefix != null and offLineMealCodePrefix != ''"> and off_line_meal_code_prefix = #{offLineMealCodePrefix}</if>
<if test="ifEnableDelivery != null "> and if_enable_delivery = #{ifEnableDelivery}</if>
<if test="deliveries != null and deliveries != ''"> and deliveries = #{deliveries}</if>
<if test="ifEnableOrder != null "> and if_enable_order = #{ifEnableOrder}</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="ifBook != null "> and if_book = #{ifBook}</if>
<if test="ifReserve != null "> and if_reserve = #{ifReserve}</if>
<if test="ifEnablePayCode != null "> and if_enable_pay_code = #{ifEnablePayCode}</if>
<if test="payCodeUrl != null and payCodeUrl != ''"> and pay_code_url = #{payCodeUrl}</if>
<if test="stallName != null and stallName != ''"> and ast.stall_name like concat('%', #{stallName}, '%')</if>
<if test="areaId != null "> and ast.area_id = #{areaId}</if>
<if test="canteenId != null "> and ast.canteen_id = #{canteenId}</if>
<if test="stallType != null "> and ast.stall_type = #{stallType}</if>
<if test="thirdStallId != null and thirdStallId != ''"> and ast.third_stall_id = #{thirdStallId}</if>
<if test="director != null "> and ast.director = #{director}</if>
<if test="contactTel != null and contactTel != ''"> and ast.contact_tel = #{contactTel}</if>
<if test="mainProject != null and mainProject != ''"> and ast.main_project = #{mainProject}</if>
<if test="businessState != null "> and ast.business_state = #{businessState}</if>
<if test="startBusinessTime != null "> and ast.start_business_time = #{startBusinessTime}</if>
<if test="endBusinessTime != null "> and ast.end_business_time = #{endBusinessTime}</if>
<if test="ifUseCallNum != null "> and ast.if_use_call_num = #{ifUseCallNum}</if>
<if test="onLineMealCodePrefix != null and onLineMealCodePrefix != ''"> and ast.on_line_meal_code_prefix = #{onLineMealCodePrefix}</if>
<if test="offLineMealCodePrefix != null and offLineMealCodePrefix != ''"> and ast.off_line_meal_code_prefix = #{offLineMealCodePrefix}</if>
<if test="ifEnableDelivery != null "> and ast.if_enable_delivery = #{ifEnableDelivery}</if>
<if test="deliveries != null and deliveries != ''"> and ast.deliveries = #{deliveries}</if>
<if test="ifEnableOrder != null "> and ast.if_enable_order = #{ifEnableOrder}</if>
<if test="imgUrl != null and imgUrl != ''"> and ast.img_url = #{imgUrl}</if>
<if test="ifBook != null "> and ast.if_book = #{ifBook}</if>
<if test="ifReserve != null "> and ast.if_reserve = #{ifReserve}</if>
<if test="ifEnablePayCode != null "> and ast.if_enable_pay_code = #{ifEnablePayCode}</if>
<if test="payCodeUrl != null and payCodeUrl != ''"> and ast.pay_code_url = #{payCodeUrl}</if>
</where>
</select>
<select id="selectAllocStallByStallId" parameterType="Long" resultMap="AllocStallResult">
<include refid="selectAllocStallVo"/>
where stall_id = #{stallId}
where ast.stall_id = #{stallId}
</select>
<insert id="insertAllocStall" parameterType="com.bonus.canteen.core.alloc.domain.AllocStall" useGeneratedKeys="true" keyProperty="stallId">

View File

@ -1,75 +0,0 @@
package com.bonus.canteen.core.config;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.codec.Base64Encoder;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.SM2;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
@RunWith(SpringRunner.class)
public class SmUtilsTest {
public static void main(String[] args) throws NoSuchAlgorithmException {
sm2();
// sm4();
// sm4WithoutIV();
}
private static void sm2() {
System.out.println("=================sm2===================");
String privateKeyStr = "D55F4709BE51FCDC71D6385885A5CAEE70A09438F862BEB4E56F64A70C76EF5F";
String pubKeyStr = "04768E8E44656FFD4BA58C0270002A28365A5F6B0F6D40E88B9221CDFAAA8E82C8CCEDBA5FC2D03F20B11492EBE90CC04782682AFE326363A503F086C04A14092C";
SM2 sm2 = SmUtil.sm2(privateKeyStr, pubKeyStr);
String data = "liolay123466789";
byte[] encrypt = sm2.encrypt("2AD2252000231631".getBytes(StandardCharsets.UTF_8));
System.out.println("encrypt:" + Base64.encode(encrypt));
PrintStream var10000 = System.out;
byte[] var10001 = sm2.sign(data.getBytes(StandardCharsets.UTF_8));
var10000.println("sign:" + Base64Encoder.encode(var10001));
var10000 = System.out;
String var5 = new String(sm2.decrypt(encrypt));
var10000.println("decrypt:" + var5);
}
private static void sm4() throws NoSuchAlgorithmException {
System.out.println("================sm4==================");
BouncyCastleProvider provider = new BouncyCastleProvider();
KeyGenerator generator = KeyGenerator.getInstance("SM4", provider);
SecretKey secretKey = generator.generateKey();
byte[] encoded = secretKey.getEncoded();
String key = Base64Encoder.encode(encoded);
System.out.println("key: " + key);
String data = "liolay";
String encryptBySm4 = SmUtils.encryptBySm4(data, encoded);
System.out.println("encrypt: " + encryptBySm4);
PrintStream var10000 = System.out;
String var10001 = SmUtils.decryptBySm4(encryptBySm4, encoded);
var10000.println("decrypt: " + var10001);
var10000 = System.out;
var10001 = SmUtils.decryptBySm4(encryptBySm4, key);
var10000.println("decrypt: " + var10001);
}
private static void sm4WithoutIV() throws NoSuchAlgorithmException {
System.out.println("================sm4WithoutIV==================");
BouncyCastleProvider provider = new BouncyCastleProvider();
KeyGenerator generator = KeyGenerator.getInstance("SM4", provider);
SecretKey secretKey = generator.generateKey();
byte[] key = secretKey.getEncoded();
String keyEncode = Base64Encoder.encode(key);
System.out.println("key: " + keyEncode);
String plainData = "liolay";
String encryptedData = SmUtils.encryptBySm4(plainData, key);
System.out.println("encrypt: " + encryptedData);
String decryptData = SmUtils.decryptBySm4(encryptedData, key);
System.out.println("decrypt: " + decryptData);
}
}