pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaUserMapper.java
@@ -101,4 +101,32 @@ * @return */ Map getUserInfoById(@Param("userId") Long userId); /** * 根据指定的条件获取用户记录数 * @param params * @return */ Long getRecordCount(Map<?, ?> params); /** * 根据指定条件获取用户列表 * @param params * @return */ List<VoUserInfo> getUsers(Map<?, ?> params); /** * 根据用户编号获取角色ID列表 * @param userId * @return */ List<Map<String, Object>> getRoleIdsByUserId(@Param("userId") Long userId); /** * getRoleNamesByUserId * @param userId * @return */ List<Map<String, Object>> getRoleNamesByUserId(@Param("userId") Long userId); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeCardOperateMapper.java
New file @@ -0,0 +1,27 @@ package com.dy.pipIrrGlobal.daoSe; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import org.apache.ibatis.annotations.Mapper; /** * @author ZhuBaoMin * @date 2024-01-18 19:28 * @LastEditTime 2024-01-18 19:28 * @Description */ @Mapper public interface SeCardOperateMapper extends BaseMapper { int deleteByPrimaryKey(Long id); int insert(SeCardOperate record); int insertSelective(SeCardOperate record); SeCardOperate selectByPrimaryKey(Long id); int updateByPrimaryKeySelective(SeCardOperate record); int updateByPrimaryKey(SeCardOperate record); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeActiveCard.java
@@ -89,7 +89,7 @@ */ @Schema(description = "补卡金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "补卡金额不小于{min}", min = 0) private Double reissueamount; private Float reissueamount; /** * 操作类型;1-开卡,2-补卡 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeCardOperate.java
New file @@ -0,0 +1,138 @@ package com.dy.pipIrrGlobal.pojoSe; import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.dy.common.po.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; import lombok.*; import org.hibernate.validator.constraints.Length; import java.util.Date; /** * @author ZhuBaoMin * @date 2024-01-18 19:10 * @LastEditTime 2024-01-18 19:10 * @Description */ @TableName(value="se_card_operate", autoResultMap = true) @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "水卡操作实体") public class SeCardOperate implements BaseEntity { public static final long serialVersionUID = 202401181914001L; /** * 主键 */ @JSONField(serializeUsing= ObjectWriterImplToString.class) @TableId(type = IdType.INPUT) @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long id; /** * 水卡ID */ @Schema(description = "水卡ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotNull(message = "水卡ID不能为空") private Long cardId; /** * 农户ID */ @Schema(description = "农户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotNull(message = "农户ID不能为空") private Long clientId; /** * 卡片余额;充值、挂失、冲正、解锁 */ @Schema(description = "卡片余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "卡片余额不小于{min}", min = 0) private Float money; /** * 系统余额;冲正时使用 */ @Schema(description = "系统余额", requiredMode = Schema.RequiredMode.REQUIRED) @Length(message = "系统余额不小于{min}", min = 0) private Float systemBalance; /** * 交易金额;购水金额、退款金额 */ @Schema(description = "交易金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "交易金额不小于{min}", min = 0) private Float tradeAmount; /** * 水价;充值时使用 */ @Schema(description = "水价", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "水价不小于{min}", min = 0) private Float price; /** * 购卡金额 */ @Schema(description = "购卡金额", requiredMode = Schema.RequiredMode.REQUIRED) @Length(message = "购卡金额不小于{min}字", min = 0) private Integer cardCost; /** * 赠送金额 */ @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "赠送金额不小于{min}", min = 0) private Float gift; /** * 非交易金额;补卡金额、补扣金额、剩余金额(解锁) */ @Schema(description = "非交易金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "非交易金额不小于{min}", min = 0) private Float noTradeAmount; /** * 操作类型 */ @Schema(description = "操作类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "付款方式不大于{max},不小于{min}", min = 1, max = 8) private Byte operateType; /** * 付款方式编号 */ @Schema(description = "付款方式编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "付款方式编号不大于{max},不小于{min}", min = 1, max = 4) private Long paymentId; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Length(message = "备注长度小于{max}字", min = 1, max = 200) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人ID必须为大于0的整数") private Long operator; /** * 操作时间 */ @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Date operateDt; } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoUserInfo.java
@@ -21,10 +21,25 @@ private static final long serialVersionUID = 1L; @Schema(title = "用户ID") private String userId; private Long userId; @Schema(title = "用户姓名") private String userName; @Schema(title = "手机号") private String phone; @Schema(title = "片区ID") private Long blockId; @Schema(title = "片区名称") private String blockName; @Schema(title = "状态编号") private Integer stateId; @Schema(title = "状态名称") private String stateName; @Schema(title = "角色编号列表") private List<Map<String, Object>> roleIds; @@ -33,7 +48,6 @@ private List<Map<String, Object>> roleNames; @Schema(title = "权限列表") //private List<Map<String, Object>> permissions; private JSONArray permissions; } pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -256,4 +256,82 @@ </if> </where> </select> <!--根据指定的条件获取用户记录数--> <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM ba_user user INNER JOIN ba_user_role usro ON usro.userId = user.id <where> AND user.supperAdmin != 1 AND user.deleted = 0 <if test = "name != null and name !=''"> AND user.name like CONCAT('%',#{name},'%') </if> <if test = "phone != null and phone !=''"> AND user.phone like CONCAT('%',#{phone},'%') </if> <if test = "roleId != null and roleId > 0"> AND usro.roleId = ${roleId} </if> </where> </select> <!--根据指定条件获取用户列表--> <select id="getUsers" resultType="com.dy.pipIrrGlobal.voBa.VoUserInfo"> SELECT id AS userId, phone, name AS userName, disabled AS stateId, (CASE WHEN disabled = 0 THEN "正常" WHEN disabled = 1 THEN "已禁用" END) AS stateName, blockId, (SELECT name FROM ba_block WHERE id = user.blockId) AS blockName FROM ba_user user INNER JOIN ba_user_role usro ON usro.userId = user.id <where> AND user.supperAdmin != 1 AND user.deleted = 0 <if test = "name != null and name !=''"> AND user.name like CONCAT('%',#{name},'%') </if> <if test = "phone != null and phone !=''"> AND user.phone like CONCAT('%',#{phone},'%') </if> <if test = "roleId != null and roleId > 0"> AND usro.roleId = ${roleId} </if> </where> ORDER BY user.id DESC <if test="pageCurr != null and pageSize != null"> LIMIT ${pageCurr}, ${pageSize} </if> </select> <!--根据用户编号获取角色ID列表--> <select id="getRoleIdsByUserId" resultType="java.util.HashMap"> SELECT roleId FROM ba_user_role WHERE userId = ${userId} </select> <select id="getRoleNamesByUserId" resultType="java.util.HashMap"> SELECT ro.name AS roleName FROM ba_user_role usro INNER JOIN ba_role ro ON usro.roleId = ro.id WHERE userId = ${userId} </select> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml
New file @@ -0,0 +1,221 @@ <?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.dy.pipIrrGlobal.daoSe.SeCardOperateMapper"> <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeCardOperate"> <!--@mbg.generated--> <!--@Table se_card_operate--> <id column="id" jdbcType="BIGINT" property="id" /> <result column="card_id" jdbcType="BIGINT" property="cardId" /> <result column="client_id" jdbcType="BIGINT" property="clientId" /> <result column="money" jdbcType="FLOAT" property="money" /> <result column="system_balance" jdbcType="FLOAT" property="systemBalance" /> <result column="trade_amount" jdbcType="FLOAT" property="tradeAmount" /> <result column="price" jdbcType="FLOAT" property="price" /> <result column="card_cost" jdbcType="INTEGER" property="cardCost" /> <result column="gift" jdbcType="FLOAT" property="gift" /> <result column="no_trade_amount" jdbcType="FLOAT" property="noTradeAmount" /> <result column="operate_type_id" jdbcType="BIGINT" property="operateType" /> <result column="payment_id" jdbcType="BIGINT" property="paymentId" /> <result column="remarks" jdbcType="VARCHAR" property="remarks" /> <result column="operator" jdbcType="BIGINT" property="operator" /> <result column="operate_dt" jdbcType="TIMESTAMP" property="operateDt" /> </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> id, card_id, client_id, money, system_balance, trade_amount, price, card_cost, gift, no_trade_amount, operate_type_id, payment_id, remarks, `operator`, operate_dt </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> select <include refid="Base_Column_List" /> from se_card_operate where id = #{id,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <!--@mbg.generated--> delete from se_card_operate where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeCardOperate"> <!--@mbg.generated--> insert into se_card_operate (id, card_id, client_id, money, system_balance, trade_amount, price, card_cost, gift, no_trade_amount, operate_type, payment_id, remarks, `operator`, operate_dt ) values (#{id,jdbcType=BIGINT}, #{cardId,jdbcType=BIGINT}, #{clientId,jdbcType=BIGINT}, #{money,jdbcType=FLOAT}, #{systemBalance,jdbcType=FLOAT}, #{tradeAmount,jdbcType=FLOAT}, #{price,jdbcType=FLOAT}, #{cardCost,jdbcType=INTEGER}, #{gift,jdbcType=FLOAT}, #{noTradeAmount,jdbcType=FLOAT}, #{operateType,jdbcType=BIGINT}, #{paymentId,jdbcType=BIGINT}, #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{operateDt,jdbcType=TIMESTAMP} ) </insert> <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeCardOperate"> <!--@mbg.generated--> insert into se_card_operate <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="cardId != null"> card_id, </if> <if test="clientId != null"> client_id, </if> <if test="money != null"> money, </if> <if test="systemBalance != null"> system_balance, </if> <if test="tradeAmount != null"> trade_amount, </if> <if test="price != null"> price, </if> <if test="cardCost != null"> card_cost, </if> <if test="gift != null"> gift, </if> <if test="noTradeAmount != null"> no_trade_amount, </if> <if test="operateType != null"> operate_type_id, </if> <if test="paymentId != null"> payment_id, </if> <if test="remarks != null"> remarks, </if> <if test="operator != null"> `operator`, </if> <if test="operateDt != null"> operate_dt, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=BIGINT}, </if> <if test="cardId != null"> #{cardId,jdbcType=BIGINT}, </if> <if test="clientId != null"> #{clientId,jdbcType=BIGINT}, </if> <if test="money != null"> #{money,jdbcType=FLOAT}, </if> <if test="systemBalance != null"> #{systemBalance,jdbcType=FLOAT}, </if> <if test="tradeAmount != null"> #{tradeAmount,jdbcType=FLOAT}, </if> <if test="price != null"> #{price,jdbcType=FLOAT}, </if> <if test="cardCost != null"> #{cardCost,jdbcType=INTEGER}, </if> <if test="gift != null"> #{gift,jdbcType=FLOAT}, </if> <if test="noTradeAmount != null"> #{noTradeAmount,jdbcType=FLOAT}, </if> <if test="operateType != null"> #{operateType,jdbcType=BIGINT}, </if> <if test="paymentId != null"> #{paymentId,jdbcType=BIGINT}, </if> <if test="remarks != null"> #{remarks,jdbcType=VARCHAR}, </if> <if test="operator != null"> #{operator,jdbcType=BIGINT}, </if> <if test="operateDt != null"> #{operateDt,jdbcType=TIMESTAMP}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeCardOperate"> <!--@mbg.generated--> update se_card_operate <set> <if test="cardId != null"> card_id = #{cardId,jdbcType=BIGINT}, </if> <if test="clientId != null"> client_id = #{clientId,jdbcType=BIGINT}, </if> <if test="money != null"> money = #{money,jdbcType=FLOAT}, </if> <if test="systemBalance != null"> system_balance = #{systemBalance,jdbcType=FLOAT}, </if> <if test="tradeAmount != null"> trade_amount = #{tradeAmount,jdbcType=FLOAT}, </if> <if test="price != null"> price = #{price,jdbcType=FLOAT}, </if> <if test="cardCost != null"> card_cost = #{cardCost,jdbcType=INTEGER}, </if> <if test="gift != null"> gift = #{gift,jdbcType=FLOAT}, </if> <if test="noTradeAmount != null"> no_trade_amount = #{noTradeAmount,jdbcType=FLOAT}, </if> <if test="operateType != null"> operate_type_id = #{operateType,jdbcType=BIGINT}, </if> <if test="paymentId != null"> payment_id = #{paymentId,jdbcType=BIGINT}, </if> <if test="remarks != null"> remarks = #{remarks,jdbcType=VARCHAR}, </if> <if test="operator != null"> `operator` = #{operator,jdbcType=BIGINT}, </if> <if test="operateDt != null"> operate_dt = #{operateDt,jdbcType=TIMESTAMP}, </if> </set> where id = #{id,jdbcType=BIGINT} </update> <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeCardOperate"> <!--@mbg.generated--> update se_card_operate set card_id = #{cardId,jdbcType=BIGINT}, client_id = #{clientId,jdbcType=BIGINT}, money = #{money,jdbcType=FLOAT}, system_balance = #{systemBalance,jdbcType=FLOAT}, trade_amount = #{tradeAmount,jdbcType=FLOAT}, price = #{price,jdbcType=FLOAT}, card_cost = #{cardCost,jdbcType=INTEGER}, gift = #{gift,jdbcType=FLOAT}, no_trade_amount = #{noTradeAmount,jdbcType=FLOAT}, operate_type_id = #{operateType,jdbcType=BIGINT}, payment_id = #{paymentId,jdbcType=BIGINT}, remarks = #{remarks,jdbcType=VARCHAR}, `operator` = #{operator,jdbcType=BIGINT}, operate_dt = #{operateDt,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} </update> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
@@ -87,11 +87,11 @@ schema = @Schema(implementation = BaUser.class))} ) }) @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) @GetMapping(path = "some") @SsoAop() public BaseResponse<QueryResultVo<List<BaUser>>> some(@RequestBody @Valid QueryVo vo) { public BaseResponse<QueryResultVo<List<VoUserInfo>>> some(QueryVo vo) { try { QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo); QueryResultVo<List<VoUserInfo>> res = this.sv.selectSome(vo); return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("查询用户异常", e); pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -54,23 +54,68 @@ } /** * 得到一个用户 * * @param vo 查询条件值对象 * @return 用户实体 * 获取用户列表 */ @SuppressWarnings("unchecked") public QueryResultVo<List<BaUser>> selectSome(QueryVo vo) { Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo); Long itemTotal = this.dao.selectTotal(params); public QueryResultVo<List<VoUserInfo>> selectSome(QueryVo queryVo) { Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); QueryResultVo<List<BaUser>> rsVo = new QueryResultVo<>(); rsVo.pageSize = vo.pageSize; rsVo.pageCurr = vo.pageCurr; Long itemTotal = this.dao.getRecordCount(params); QueryResultVo<List<VoUserInfo>> rsVo = new QueryResultVo<>() ; Integer pageCurr = 0; Integer pageSize = 10000; rsVo.pageCurr = 1; rsVo.pageSize = 10000; if(queryVo.pageSize != null && queryVo.pageCurr != null) { rsVo.pageSize = queryVo.pageSize ; rsVo.pageCurr = queryVo.pageCurr; pageSize = queryVo.pageSize ; pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString()); } params.put("pageCurr", pageCurr); params.put("pageSize", pageSize); rsVo.calculateAndSet(itemTotal, params); rsVo.obj = this.dao.selectSome(params); return rsVo; /** * 获取用户列表,取用户ID * 根据用户ID获取roleId列表,并添加到返回对象中 * 根据用户ID获取roleName列表,并添加到返回对象中 */ List<VoUserInfo> list_users = Optional.ofNullable(this.dao.getUsers(params)).orElse(new ArrayList<>()); if(list_users.size() > 0) { for(int i = 0; i < list_users.size(); i++) { VoUserInfo voUserInfo = list_users.get(i); Long userId = voUserInfo.getUserId(); JSONArray array_roleIds = new JSONArray(); List<Map<String, Object>> list_roleIds = Optional.ofNullable(this.dao.getRoleIdsByUserId(userId)).orElse(new ArrayList<>()); for (int j = 0; j < list_roleIds.size(); j++) { Map map_roleId = list_roleIds.get(j); if(map_roleId != null) { array_roleIds.add(map_roleId.get("roleId").toString()); } } List<Map<String, Object>> list_roleId = (List<Map<String, Object>>) JSON.parse(array_roleIds.toJSONString()); JSONArray array_roleNames = new JSONArray(); List<Map<String, Object>> list_roleNames = Optional.ofNullable(this.dao.getRoleNamesByUserId(userId)).orElse(new ArrayList<>()); for (int j = 0; j < list_roleNames.size(); j++) { Map map_roleName = list_roleNames.get(j); if(map_roleName != null) { array_roleNames.add(map_roleName.get("roleName").toString()); } } List<Map<String, Object>> list_roleName = (List<Map<String, Object>>) JSON.parse(array_roleNames.toJSONString()); voUserInfo.setRoleIds(list_roleId); voUserInfo.setRoleNames(list_roleName); } } rsVo.obj = list_users; return rsVo ; } /** @@ -182,7 +227,7 @@ JSONArray array_permission = new JSONArray(); Map map = Optional.ofNullable(dao.getUserInfoById(userId)).orElse(new HashMap()); if(map.size() > 0) { voUserInfo.setUserId(String.valueOf(userId)); voUserInfo.setUserId(userId); voUserInfo.setUserName(map.get("userName").toString()); } @@ -216,7 +261,6 @@ voUserInfo.setRoleIds(list_roleIds); voUserInfo.setRoleNames(list_roleNames); voUserInfo.setPermissions(array_permission); return voUserInfo; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/ActiveCardCtrl.java
@@ -9,6 +9,7 @@ import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.util.Constant; import com.dy.pipIrrGlobal.voSe.VoActiveCard; import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; import com.dy.pipIrrSell.clientCard.CardStateENUM; import com.dy.pipIrrSell.clientCard.ClientCardSv; import com.dy.pipIrrSell.clientCard.LastOperateENUM; @@ -262,7 +263,7 @@ //String clientNum = ""; Long clientId = 0L; Integer cardCost = po.getCardCost(); Double reissueAmount = po.getReissueAmount(); Float reissueAmount = po.getReissueAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); @@ -304,7 +305,7 @@ activeCard.setCardcost(cardCost); activeCard.setPaymentid(paymentId); activeCard.setReissueamount(reissueAmount); activeCard.setOperatetype(OperateTypeENUM.REPLACE.getCode()); activeCard.setOperatetype(OperateTypeENUM.REISSUE.getCode()); activeCard.setRemarks(remarks); activeCard.setOperator(operator); activeCard.setOperatedt(replaceTime); pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/DtoActiveCard.java
@@ -65,7 +65,7 @@ */ @Schema(description = "补卡金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="补卡金额不能小于0") private Double reissueAmount; private Float reissueAmount; /** * 支付方式编号 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/OperateTypeENUM.java
File was deleted pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
New file @@ -0,0 +1,550 @@ package com.dy.pipIrrSell.cardOperate; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.util.Constant; import com.dy.pipIrrSell.cardOperate.converter.RechargeDtoMapper; import com.dy.pipIrrSell.cardOperate.dto.*; import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; import com.dy.pipIrrSell.clientCard.CardStateENUM; import com.dy.pipIrrSell.clientCard.ClientCardSv; import com.dy.pipIrrSell.clientCard.LastOperateENUM; import com.dy.pipIrrSell.result.SellResultCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.time.format.DateTimeFormatter; import java.util.*; /** * @author ZhuBaoMin * @date 2024-01-18 19:36 * @LastEditTime 2024-01-18 19:36 * @Description */ @Slf4j @Tag(name = "水卡操作管理", description = "水卡各种操作") @RestController @RequestMapping(path="card") @RequiredArgsConstructor public class CardOperateCtrl { private final CardOperateSv cardOperateSv; private final ClientCardSv clientCardSv; /** * 开卡 * @param po 开卡传入对象 * @param bindingResult * @return 水卡编号 */ @Operation(summary = "开卡", description = "新开农户卡") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "active", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_active(@RequestBody @Valid DtoActiveCard po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 获取5级行政区划串areaCode String areaCode = String.valueOf(cardOperateSv.getAreaCodeByNum(po.getClientNum())); /** * 根据行政区划串(areaCode)在水卡表中针对水卡编号(cardNum)进行模糊查询 * 如果4位顺序号已经达到最大值,提示用户联系系统管理员 * 如果4位顺序号未达到最大值,则加1 * cardNum为新的卡号 */ String cardNum = Optional.ofNullable(cardOperateSv.getCardNumOfMax(areaCode)).orElse(""); if(cardNum != null && cardNum.trim().length() > 0) { Integer number = Integer.parseInt(cardNum.substring(12)); number = number + 1; if(number > 9999) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); } cardNum = cardNum.substring(0, 12) + String.format("%04d", number); } else { cardNum = areaCode + "0001"; } /** * cardAddr 水卡地址(仅仅写入,无业务) * clientNum 农户编号 * cardCost 卡片费用 * amount 充值金额 * reissueAmount 补卡金额,补卡时使用 * paymentId 支付方式编号 * remarks 备注 * operator 操作人编号 * activeTime 开卡时间 */ String cardAddr = po.getCardAddr(); String clientNum = po.getClientNum(); Integer cardCost = po.getCardCost(); Float amount = po.getAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date activeTime = new Date(); /** * 根据农户编号获取农户ID */ Long clientId = cardOperateSv.getClientIdByNum(clientNum); /** * 添加农户卡记录 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setCardaddr(cardAddr); seClientCard.setCardnum(cardNum); seClientCard.setClientid(clientId); seClientCard.setMoney(0f); seClientCard.setState(CardStateENUM.NORMAL.getCode()); seClientCard.setCreatedt(activeTime); seClientCard.setLastoper(LastOperateENUM.ACTIVE.getCode()); Long cardId = Optional.ofNullable(clientCardSv.add(seClientCard)).orElse(0L) ; if(cardId == 0) { return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加开卡记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setCardCost(cardCost); seCardOperate.setPaymentId(paymentId); seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(activeTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); } /** * 如果操作人员开卡时输入了充值金额,则开卡后调用充值功能 */ po.setCardNum(cardNum); if(amount != null && amount > 0) { po.setClientId(clientId); DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); dtoRecharge.setMoney(0f); dtoRecharge.setGift(0f); dtoRecharge.setPrice(0f); BaseResponse<Boolean> job = cardOperateSv.addRecharge(dtoRecharge); if(!job.getCode().equals("0001")) { return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); } } Map map = new HashMap(); map.put("projectCode", Constant.projectCode_ym); map.put("cardNum", cardNum); return BaseResponseUtils.buildSuccess(map) ; } /** * 补卡 * @param po * @param bindingResult * @return */ @Operation(summary = "补卡", description = "补卡") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "reissue", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_reissue(@RequestBody @Valid com.dy.pipIrrSell.activeCard.DtoActiveCard po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** * cardId 水卡编号(非传入参数,由cardNum反查,更新水卡表用) * cardNum 水卡编号 * clientId 农户ID(非传入参数,由cardNum反查,添加补卡使用) * cardCost 卡片费用 * reissueAmount 补卡金额,补卡时使用 * paymentId 支付方式编号 * remarks 备注 * operator 操作人编号 * activeTime 补卡时间 */ Long cardId = 0L; Long clientId = 0L; String cardNum = po.getCardNum(); Integer cardCost = po.getCardCost(); Float reissueAmount = po.getReissueAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date reissueTime = new Date(); /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_ERROR.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 修改农户卡信息: * 补卡时间 * 最后操作类型-2 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); seClientCard.setReplacedt(reissueTime); seClientCard.setLastoper(LastOperateENUM.REPLACE.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加补卡记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setCardCost(cardCost); seCardOperate.setPaymentId(paymentId); seCardOperate.setNoTradeAmount(reissueAmount); seCardOperate.setOperateType(OperateTypeENUM.REISSUE.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(reissueTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } /** * 充值 * @param po 充值传输对象 * @param bindingResult * @return */ @Operation(summary = "充值", description = "充值") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "recharge", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add(@RequestBody @Valid DtoRecharge po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } return cardOperateSv.addRecharge(po); } /** * 销卡 * @param po * @param bindingResult * @return */ @Operation(summary = "添加注销记录", description = "添加注销记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "cancel", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add(@RequestBody @Valid DtoCancel po, BindingResult bindingResult){ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** * cardId 水卡编号(非传入参数,由cardNum反查,修改农户卡使用) * clientId 农户编号(非传入参数,由cardNum反查) * cardNum 水卡编号 * refund 退款金额 * refundType 退款方式 * remarks 备注 * operator 操作人编号 * cancelTime 注销时间 */ Long cardId = 0L; Long clientId = 0L; String cardNum = po.getCardNum(); Float refund = po.getRefund(); Byte refundType = po.getRefundType(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date cancelTime = new Date(); /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 修改农户卡信息: * 注销时间 * 最后操作类型-4 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); seClientCard.setCanceldt(cancelTime); seClientCard.setMoney(0f); seClientCard.setState(CardStateENUM.CANCELLED.getCode()); seClientCard.setLastoper(LastOperateENUM.CANCEL.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加注销记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setTradeAmount(-refund); seCardOperate.setOperateType(OperateTypeENUM.CANCEL.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(cancelTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CANCELL_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } /** * 挂失 * @param po * @param bindingResult * @return */ @Operation(summary = "添加挂失记录", description = "添加挂失记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "loss", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add(@RequestBody @Valid DtoLoss po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** * cardId 水卡编号(非传入参数,由cardNum反查) * clientId 农户编号(非传入参数,由cardNum反查) * cardNum 水卡编号 * money 余额 * refund 退款金额 * remarks 备注 * operator 操作人编号 * lossTime 挂失时间 */ Long cardId = 0L; Long clientId = 0L; String cardNum = po.getCardNum(); Float money = po.getMoney(); Float refund = po.getRefund(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date lossTime = new Date(); /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 修改农户卡信息: * 挂失时间 * 最后操作类型-4 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); seClientCard.setMoney(money); seClientCard.setLossdtdt(lossTime); seClientCard.setState(CardStateENUM.LOSS.getCode()); seClientCard.setLastoper(LastOperateENUM.LOSS.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加挂失记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); seCardOperate.setTradeAmount(-refund); seCardOperate.setOperateType(OperateTypeENUM.LOSS.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(lossTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } @Operation(summary = "添加冲正记录", description = "添加冲正记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "reversal", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add(@RequestBody @Valid DtoReversal po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** * cardId 水卡编号(非传入参数,由cardNum反查,修改农户卡使用) * clientId 农户编号(非传入参数,由cardNum反查) * cardNum 水卡编号 * cardBalance 卡片余额 * systemBalance 系统余额 * remarks 备注 * operator 操作人编号 * reversalTime 冲正时间 */ Long cardId = 0L; Long clientId = 0L; String cardNum = po.getCardNum(); Float cardBalance = po.getCardBalance(); Float systemBalance = po.getSystemBalance(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date reversalTime = new Date(); /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 修改农户卡信息: * 挂失时间 * 最后操作类型-4 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); seClientCard.setReversaldt(reversalTime); seClientCard.setMoney(cardBalance); seClientCard.setLastoper(LastOperateENUM.REVERSAL.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加冲正记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(cardBalance); seCardOperate.setSystemBalance(systemBalance); seCardOperate.setOperateType(OperateTypeENUM.REVERSAL.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(reversalTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.REVERSAL_FAIL_WRITE_REVERSAL_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
New file @@ -0,0 +1,177 @@ package com.dy.pipIrrSell.cardOperate; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; import com.dy.pipIrrGlobal.daoSe.SeClientMapper; import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrSell.cardOperate.dto.DtoRecharge; import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; import com.dy.pipIrrSell.clientCard.ClientCardSv; import com.dy.pipIrrSell.clientCard.LastOperateENUM; import com.dy.pipIrrSell.result.SellResultCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Optional; /** * @author ZhuBaoMin * @date 2024-01-18 19:36 * @LastEditTime 2024-01-18 19:36 * @Description */ @Slf4j @Service public class CardOperateSv { @Autowired private SeCardOperateMapper seCardOperateMapper; @Autowired private SeClientCardMapper seClientCardMapper; @Autowired private SeClientMapper seClientMapper; @Autowired private ClientCardSv clientCardSv; /** * 添加开卡记录 * @param po 水卡操作对象 * @return 开卡记录主键 */ public Long activeCard(SeCardOperate po) { seCardOperateMapper.insert(po); return po.getId(); } /** * 根据农户编号获取5级行政区划代码,开卡使用 * @param clientNum 农户编号 * @return 5级行政区划代码 */ public Long getAreaCodeByNum(String clientNum) { return seClientMapper.getAreaCodeByNum(clientNum); } /** * 根据行政区划串模块查询水卡编号,开卡使用 * @param areaCode * @return */ String getCardNumOfMax(String areaCode) { return seClientCardMapper.getCardNumOfMax(areaCode); } /** * 根据农户编号获取农户ID,开卡使用 * @param clientNum * @return */ public Long getClientIdByNum(String clientNum) { return seClientMapper.getClientIdByNum(clientNum); } /** * 添加水卡操作对象,各操作都使用 * @param po 水卡操作对象 * @return 操作记录主键 */ public Long add(SeCardOperate po) { seCardOperateMapper.insert(po); return po.getId(); } /** * 添加充值记录 * 修改农户信息、添加充值记录 * @param po * @return */ public BaseResponse<Boolean> addRecharge(DtoRecharge po){ /** * cardId 水卡编号(依据水卡编号获取) * clientId 农户编号(依据水卡编号获取) * cardNum 水卡编号 * money 卡片余额 * amount 充值金额 * gift 赠送金额 * afterRecharge 充值后余额 * paymentId 支付方式编号 * price 水价 * remarks 备注 * operator 操作人编号 * rechargeTime 充值时间 */ Long cardId = 0L; Long clientId = 0L; String cardNum = po.getCardNum(); Float money = po.getMoney(); Float amount = po.getAmount(); Float gift = po.getGift(); Float afterRecharge = money + amount + gift; Long paymentId = po.getPaymentId(); Float price = po.getPrice(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date rechargeTime = new Date(); /** * 依据水卡编号获取水卡表主键及农户编号 */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 修改农户卡信息: * 补卡时间 * 最后操作类型-2 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); seClientCard.setMoney(afterRecharge); seClientCard.setRechargedt(rechargeTime); seClientCard.setLastoper(LastOperateENUM.RECHARGE.getCode ()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 添加充值记录 */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); seCardOperate.setTradeAmount(amount); seCardOperate.setGift(gift); seCardOperate.setOperateType(OperateTypeENUM.RECHARGE.getCode()); seCardOperate.setPaymentId(paymentId); seCardOperate.setPrice(price); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); seCardOperate.setOperateDt(rechargeTime); seCardOperateMapper.insert(seCardOperate); Long rec = Optional.ofNullable(seCardOperate.getId()).orElse(0L); if(rec == 0) { return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/converter/RechargeDtoMapper.java
New file @@ -0,0 +1,26 @@ package com.dy.pipIrrSell.cardOperate.converter; import com.dy.pipIrrSell.cardOperate.dto.DtoActiveCard; import com.dy.pipIrrSell.cardOperate.dto.DtoRecharge; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; /** * @author ZhuBaoMin * @date 2024-01-19 9:41 * @LastEditTime 2024-01-19 9:41 * @Description */ @Mapper public interface RechargeDtoMapper { RechargeDtoMapper INSTANCT = Mappers.getMapper(RechargeDtoMapper.class); @Mapping(target = "cardNum", source = "cardNum") @Mapping(target = "amount", source = "amount") @Mapping(target = "paymentId", source = "paymentId") @Mapping(target = "remarks", source = "remarks") @Mapping(target = "operator", source = "operator") DtoRecharge po2vo(DtoActiveCard po); } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/dto/DtoActiveCard.java
New file @@ -0,0 +1,89 @@ package com.dy.pipIrrSell.cardOperate.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Positive; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-18 19:44 * @LastEditTime 2024-01-18 19:44 * @Description */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "开卡/补卡传入对象") public class DtoActiveCard { public static final long serialVersionUID = 202401181945001L; /** * 水卡地址,仅保存,无业务 */ @Schema(description = "水卡地址", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotBlank(message = "水卡地址不能为空") private String cardAddr; /** * 农户编号,开卡使用 */ @Schema(description = "农户编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String clientNum; /** * 农户ID(主键),不是开卡接口传入,由农户编号获得,保存开卡记录和充值记录都需要 */ @Schema(description = "农户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long clientId; /** * 水卡编号,不是开卡接口传入,由农户编号获得,充值需要 */ @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String cardNum; /** * 卡片费用 */ @Schema(description = "卡片费用", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "卡片费用必须为大于0的整数") private Integer cardCost; /** * 充值金额 */ @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="充值金额不能小于0") private Float amount; /** * 补卡金额 */ @Schema(description = "补卡金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="补卡金额不能小于0") private Double reissueAmount; /** * 支付方式编号 */ @Schema(description = "支付方式编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "支付方式编号必须为大于0的整数") private Long paymentId; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人编号必须为大于0的整数") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/dto/DtoCancel.java
New file @@ -0,0 +1,64 @@ package com.dy.pipIrrSell.cardOperate.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Positive; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-19 10:08 * @LastEditTime 2024-01-19 10:08 * @Description */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "注销传入对象") public class DtoCancel { public static final long serialVersionUID = 202401191009001L; /** * 水卡编号 */ @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotBlank private String cardNum; /** * 农户编号 */ //@Schema(description = "农户编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) //private Long clientId; /** * 退款金额 */ @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="退款金额不能小于0") private Float refund; /** * 退款方式;1-现金 */ @Schema(description = "退款方式", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "退款方式必须为大于0的整数") private Byte refundType; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人编号必须为大于0的整数") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/dto/DtoLoss.java
New file @@ -0,0 +1,58 @@ package com.dy.pipIrrSell.cardOperate.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Positive; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-19 10:32 * @LastEditTime 2024-01-19 10:32 * @Description */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "挂失传入对象") public class DtoLoss { public static final long serialVersionUID = 202401191033001L; /** * 水卡编号 */ @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotBlank(message = "水卡编号不能为空") private String cardNum; /** * 余额 */ @Schema(description = "余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="余额不能小于0") private Float money; /** * 退款金额 */ @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="退款金额不能小于0") private Float refund; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人编号必须为大于0的整数") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/dto/DtoRecharge.java
New file @@ -0,0 +1,84 @@ package com.dy.pipIrrSell.cardOperate.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Positive; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-19 9:06 * @LastEditTime 2024-01-19 9:06 * @Description */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "充值传入对象") public class DtoRecharge { public static final long serialVersionUID = 202401190907001L; /** * 水卡编号 */ @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotBlank(message = "水卡编号不能为空") private String cardNum; /** * 农户ID,不是充值接口传入,由开卡对象传入,保存充值记录需要 */ @Schema(description = "农户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long clientId; /** * 卡片余额 */ @Schema(description = "卡片余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="卡片余额不能小于0") private Float money; /** * 充值金额 */ @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="充值金额不能小于0") private Float amount; /** * 赠送金额 */ @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="赠送金额不能小于0") private Float gift; /** * 付款方式编号 */ @Schema(description = "付款方式编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long paymentId; /** * 水价 */ @Schema(description = "水价", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="水价不能小于0") private Float price; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人编号必须为大于0的整数") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/dto/DtoReversal.java
New file @@ -0,0 +1,64 @@ package com.dy.pipIrrSell.cardOperate.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Positive; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-19 13:36 * @LastEditTime 2024-01-19 13:36 * @Description */ @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "冲正传入对象") public class DtoReversal { public static final long serialVersionUID = 202401191337001L; /** * 水卡编号 */ @Schema(description = "水卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotBlank(message = "水卡编号不能为空") private String cardNum; /** * 农户编号 */ //@Schema(description = "农户编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) //private String clientNum; /** * 卡片余额 */ @Schema(description = "卡片余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="卡片余额不能小于0") private Float cardBalance; /** * 系统余额 */ @Schema(description = "系统余额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Min(value = 0, message="系统余额不能小于0") private Float systemBalance; /** * 备注信息 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private String remarks; /** * 操作人编号 */ @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Positive(message = "操作人编号必须为大于0的整数") private Long operator; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/enums/OperateTypeENUM.java
New file @@ -0,0 +1,27 @@ package com.dy.pipIrrSell.cardOperate.enums; import lombok.AllArgsConstructor; import lombok.Getter; /** * @author ZhuBaoMin * @date 2023/12/8 10:56 * @LastEditTime 2023/12/8 10:56 * @Description 开卡/补卡类型枚举 */ @Getter @AllArgsConstructor public enum OperateTypeENUM { ACTIVE((byte)1, "开卡"), RECHARGE((byte)2, "充值"), CANCEL((byte)3, "销卡"), REISSUE((byte)4, "补卡"), REFUND((byte)5, "补扣"), LOSS((byte)6, "挂失"), REVERSAL((byte)7, "冲正"), UNLOCK((byte)8, "解锁"); private final Byte code; private final String message; }