2024-08-10 朱宝民 注册虚拟卡、虚拟卡充值添加操作记录(新加操作记录表)
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoSe; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcOperate; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-08-10 10:15 |
| | | * @LastEditTime 2024-08-10 10:15 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface SeVcOperateMapper extends BaseMapper<SeVcOperate> { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(SeVcOperate record); |
| | | |
| | | int insertSelective(SeVcOperate record); |
| | | |
| | | SeVcOperate selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(SeVcOperate record); |
| | | |
| | | int updateByPrimaryKey(SeVcOperate record); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.pojoSe; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-08-10 10:15 |
| | | * @LastEditTime 2024-08-10 10:15 |
| | | * @Description |
| | | */ |
| | | |
| | | 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 com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 虚拟卡操作表 |
| | | */ |
| | | @TableName(value = "se_vc_operate", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SeVcOperate implements BaseEntity { |
| | | public static final long serialVersionUID = 202408100908001L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 虚拟卡ID |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | private Long vcId; |
| | | |
| | | /** |
| | | * 农户ID |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | private Long clientId; |
| | | |
| | | /** |
| | | * 操作类型;1-开户,2-充值,3-消费,4-销户,5-申请退款,6-退款审核,7-退款 |
| | | */ |
| | | private Byte operateType; |
| | | |
| | | /** |
| | | * 充值ID;充值时填写 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | private Long rechargeId; |
| | | |
| | | /** |
| | | * 操作人 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | private Long operator; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date operateTime; |
| | | |
| | | } |
New file |
| | |
| | | <?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.SeVcOperateMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeVcOperate"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table se_vc_operate--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="vc_id" jdbcType="BIGINT" property="vcId" /> |
| | | <result column="client_id" jdbcType="BIGINT" property="clientId" /> |
| | | <result column="operate_type" jdbcType="TINYINT" property="operateType" /> |
| | | <result column="recharge_id" jdbcType="BIGINT" property="rechargeId" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | | <result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, vc_id, client_id, operate_type, recharge_id, `operator`, operate_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from se_vc_operate |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from se_vc_operate |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVcOperate"> |
| | | <!--@mbg.generated--> |
| | | insert into se_vc_operate (id, vc_id, client_id, |
| | | operate_type, recharge_id, `operator`, |
| | | operate_time) |
| | | values (#{id,jdbcType=BIGINT}, #{vcId,jdbcType=BIGINT}, #{clientId,jdbcType=BIGINT}, |
| | | #{operateType,jdbcType=TINYINT}, #{rechargeId,jdbcType=BIGINT}, #{operator,jdbcType=BIGINT}, |
| | | #{operateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVcOperate"> |
| | | <!--@mbg.generated--> |
| | | insert into se_vc_operate |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="vcId != null"> |
| | | vc_id, |
| | | </if> |
| | | <if test="clientId != null"> |
| | | client_id, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | operate_type, |
| | | </if> |
| | | <if test="rechargeId != null"> |
| | | recharge_id, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator`, |
| | | </if> |
| | | <if test="operateTime != null"> |
| | | operate_time, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="vcId != null"> |
| | | #{vcId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="clientId != null"> |
| | | #{clientId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | #{operateType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="rechargeId != null"> |
| | | #{rechargeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operator != null"> |
| | | #{operator,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateTime != null"> |
| | | #{operateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVcOperate"> |
| | | <!--@mbg.generated--> |
| | | update se_vc_operate |
| | | <set> |
| | | <if test="vcId != null"> |
| | | vc_id = #{vcId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="clientId != null"> |
| | | client_id = #{clientId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | operate_type = #{operateType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="rechargeId != null"> |
| | | recharge_id = #{rechargeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateTime != null"> |
| | | operate_time = #{operateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVcOperate"> |
| | | <!--@mbg.generated--> |
| | | update se_vc_operate |
| | | set vc_id = #{vcId,jdbcType=BIGINT}, |
| | | client_id = #{clientId,jdbcType=BIGINT}, |
| | | operate_type = #{operateType,jdbcType=TINYINT}, |
| | | recharge_id = #{rechargeId,jdbcType=BIGINT}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | operate_time = #{operateTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | OPEN_ACCOUNT((byte)1, "开户"), |
| | | RECHARGE((byte)2, "充值"), |
| | | CONSUME((byte)3, "消费"), |
| | | APPLY_REFUND((byte)4, "申请退款"), |
| | | AUDIT_REFUND((byte)5, "退款审核"), |
| | | REFUND((byte)6, "退款"), |
| | | OPEN_VALVE((byte)7, "开阀"), |
| | | CLOSE_VALVE((byte)8, "关阀"); |
| | | CLOSING_ACCOUNT((byte)4, "销户"), |
| | | APPLY_REFUND((byte)5, "申请退款"), |
| | | AUDIT_REFUND((byte)6, "退款审核"), |
| | | REFUND((byte)7, "退款"); |
| | | |
| | | private final Byte code; |
| | | private final String message; |
| | |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.voSt.VoClient; |
| | | import com.dy.pipIrrGlobal.voSt.VoClientOpenCardCount; |
| | | import com.dy.pipIrrGlobal.voSt.VoClientRechargeTotal; |
| | | import com.dy.pipIrrGlobal.voSt.VoICCard; |
| | | import com.dy.pipIrrGlobal.voSt.*; |
| | | import com.dy.pipIrrStatistics.card.IcCardqo.CommonQO; |
| | | import com.dy.pipIrrStatistics.client.qo.*; |
| | | import com.dy.pipIrrGlobal.voSt.VoDayClient; |
| | | import com.dy.pipIrrGlobal.voSt.VoMonthClient; |
| | | import com.dy.pipIrrStatistics.client.qo.AmountSpentQO; |
| | | import com.dy.pipIrrStatistics.client.qo.OpenCountQO; |
| | | import com.dy.pipIrrStatistics.client.qo.WaterConsumptionQO; |
| | | import com.dy.pipIrrStatistics.client.qo.WaterDurationQO; |
| | | import com.dy.pipIrrStatistics.intake.qo.ClientAmountQO; |
| | | import com.dy.pipIrrStatistics.result.StatisticlResultCode; |
| | | import jakarta.validation.Valid; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | */ |
| | | @GetMapping(path = "/getDayIntakeAmount") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoDayIntakeAmount>>> getDayIntakeAmount(IntakeAmountQO qo) { |
| | | public BaseResponse<QueryResultVo<List<VoDayIntakeAmount>>> getDayIntakeAmount(@NotNull IntakeAmountQO qo) { |
| | | if(qo.getYearMonth() == null) { |
| | | return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.YEAR_AND_MONTH_CANNOT_BE_NULL.getMessage()); |
| | | } |
| | |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; |
| | | import com.dy.pipIrrGlobal.voSe.VoVcRecharge; |
| | | import com.dy.pipIrrGlobal.voSe.VoVirtualCard; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "add_vc") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | |
| | | vcNum = areaCode + "00001"; |
| | | } |
| | | |
| | | // 生成虚拟卡记录 |
| | | SeVirtualCard seVirtualCard = new SeVirtualCard(); |
| | | seVirtualCard.setVcNum(Long.parseLong(vcNum)); |
| | | seVirtualCard.setClientId(clientId); |
| | |
| | | seVirtualCard.setLastOperateTime(new Date()); |
| | | seVirtualCard.setInUse((byte) 0); |
| | | seVirtualCard.setCreateTime(new Date()); |
| | | Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); |
| | | if(rec == null) { |
| | | Long vcId = virtualCardSv.insertVirtualCard(seVirtualCard); |
| | | if(vcId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); |
| | | } |
| | | |
| | | // 生成虚拟卡操作记录,注册虚拟卡操作人为农户 |
| | | SeVcOperate seVcOperate = new SeVcOperate(); |
| | | seVcOperate.setVcId(vcId); |
| | | seVcOperate.setClientId(clientId); |
| | | seVcOperate.setOperateType(LastOperateENUM.OPEN_ACCOUNT.getCode()); |
| | | seVcOperate.setOperator(clientId); |
| | | seVcOperate.setOperateTime(new Date()); |
| | | Long vcOperateId = virtualCardSv.insertVcOperate(seVcOperate); |
| | | if(vcOperateId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | |
| | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoSe.*; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRefund; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRefundItem; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.*; |
| | | import com.dy.pipIrrGlobal.voSe.VoOrders; |
| | | import com.dy.pipIrrGlobal.voSe.VoVcRecharge; |
| | | import com.dy.pipIrrGlobal.voSe.VoVirtualCard; |
| | |
| | | |
| | | @Autowired |
| | | private SeClientMapper seClientMapper; |
| | | |
| | | @Autowired |
| | | private SeVcOperateMapper seVcOperateMapper; |
| | | |
| | | /** |
| | | * 根据农户ID获取5级行政区划代码,注册虚拟卡使用 |
| | |
| | | * 添加虚拟卡充值记录 |
| | | * JSAPI下单后生成部分充值记录 |
| | | * @param po |
| | | * @return |
| | | * @return -1:虚拟卡不存在,0:添加充值记录失败 |
| | | */ |
| | | public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) { |
| | | //public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) { |
| | | public Long insertVCRecharge(DtoVirtualCard po) { |
| | | String orderNumber = po.getOrderNumber(); |
| | | Long virtualId = po.getVirtualId(); |
| | | Long clientId = po.getClientId(); |
| | |
| | | |
| | | // 验证该虚拟卡账户是否存在并取出当前账户余额 |
| | | SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId); |
| | | |
| | | if(seVirtualCard == null) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.NO_ACCOUNT.getMessage()); |
| | | return -1L; |
| | | } |
| | | Double money = seVirtualCard.getMoney(); |
| | | |
| | |
| | | seVcRecharge.setRechargeAmount(rechargeAmount); |
| | | seVcRecharge.setOrderTime(new Date()); |
| | | seVcRecharge.setOrderState(OrderStateENUM.NON_PAYMENT.getCode()); |
| | | Integer rec = seVcRechargeMapper.insert(seVcRecharge); |
| | | if(rec == null) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage()); |
| | | seVcRechargeMapper.insert(seVcRecharge); |
| | | Long rechargeId = seVcRecharge.getId(); |
| | | if(rechargeId == null) { |
| | | return 0L; |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | return rechargeId; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 添加虚拟卡操作记录 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long insertVcOperate(SeVcOperate po) { |
| | | seVcOperateMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | } |
| | |
| | | OPEN_ACCOUNT((byte)1, "开户"), |
| | | RECHARGE((byte)2, "充值"), |
| | | CONSUME((byte)3, "消费"), |
| | | APPLY_REFUND((byte)4, "申请退款"), |
| | | AUDIT_REFUND((byte)5, "退款审核"), |
| | | REFUND((byte)6, "退款"), |
| | | OPEN_VALVE((byte)7, "开阀"), |
| | | CLOSE_VALVE((byte)8, "关阀"); |
| | | CLOSING_ACCOUNT((byte)4, "销户"), |
| | | APPLY_REFUND((byte)5, "申请退款"), |
| | | AUDIT_REFUND((byte)6, "退款审核"), |
| | | REFUND((byte)7, "退款"); |
| | | |
| | | private final Byte code; |
| | | private final String message; |
| | |
| | | virtualCard.setClientId(clientId); |
| | | virtualCard.setOrderNumber(orderNumber); |
| | | virtualCard.setRechargeAmount(rechargeAmount); |
| | | BaseResponse result = virtualCardSv.insertVCRecharge(virtualCard); |
| | | if(!result.getCode().equals("0001")) { |
| | | |
| | | // -1:虚拟卡不存在,0:添加充值记录失败 |
| | | Long rechargeId = virtualCardSv.insertVCRecharge(virtualCard); |
| | | if(rechargeId.equals(-1)) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.NO_ACCOUNT.getMessage()); |
| | | } |
| | | if(rechargeId.equals(0)) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage()); |
| | | } |
| | | |
| | | // 生成充值操作记录,充值操作人为农户 |
| | | SeVcOperate seVcOperate = new SeVcOperate(); |
| | | seVcOperate.setVcId(virtualId); |
| | | seVcOperate.setClientId(clientId); |
| | | seVcOperate.setOperateType(LastOperateENUM.RECHARGE.getCode()); |
| | | seVcOperate.setRechargeId(rechargeId); |
| | | seVcOperate.setOperator(clientId); |
| | | seVcOperate.setOperateTime(new Date()); |
| | | Long vcOperateId = virtualCardSv.insertVcOperate(seVcOperate); |
| | | if(vcOperateId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.RECHARGE_ADD_FAIL.getMessage()); |
| | | } |
| | | |
| | |
| | | |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeVcOperateMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeVcRechargeMapper; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeOpenId; |
| | |
| | | |
| | | @Autowired |
| | | private SeClientMapper seClientMapper; |
| | | |
| | | @Autowired |
| | | private SeVcOperateMapper seVcOperateMapper; |
| | | |
| | | /** |
| | | * 根据登录态ID获取登录态对象 |
| | |
| | | //return po.getClientId(); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 添加虚拟卡操作记录 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | //public Long insertVcOperate(SeVcOperate po) { |
| | | // seVcOperateMapper.insert(po); |
| | | // return po.getId(); |
| | | //} |
| | | } |