admin
2019-10-26 96382ae55d8c2ad66954030e8ba8ada07852757f
关于提现的账户明细更改
6个文件已修改
165 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/money/UserMoneyDetailMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/tb/TaoBaoWeiQuanDrawBackServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
@@ -98,6 +98,17 @@
    private Date updateTime;
    
    private Integer state;//老版明细适用该字段
    @Column(name = "umd_show")
    private Boolean show;//是否显示
    public Boolean getShow() {
        return show;
    }
    public void setShow(Boolean show) {
        this.show = show;
    }
    public Integer getState() {
        return state;
fanli/src/main/java/com/yeshi/fanli/mapping/money/UserMoneyDetailMapper.xml
@@ -20,6 +20,7 @@
        <!-- 老版明细适用该字段 -->
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="umd_order_type" property="orderType" jdbcType="INTEGER" />
        <result column="umd_show" property="show" jdbcType="BOOLEAN" />
        <association property="userInfo" column="umd_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="umd_uid" property="id" jdbcType="BIGINT" />
@@ -31,7 +32,7 @@
        <result column="income" property="income" jdbcType="DECIMAL" />
        <result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type
    <sql id="Base_Column_List">umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
@@ -46,23 +47,23 @@
            <=
        ]]>
        (SELECT d.`umd_createtime` FROM yeshi_ec_user_money_detail d WHERE
        d.`umd_id`=#{id}) and d.umd_uid=#{uid} order by d.`umd_createtime`
        d.`umd_id`=#{id}) and d.umd_uid=#{uid}  and d.umd_show=1 order by d.`umd_createtime`
        desc,d.umd_id desc limit #{count}
    </select>
    <select id="selectCountByUid" resultType="java.lang.Long"
        parameterType="java.lang.Long">SELECT count(umd_id) FROM yeshi_ec_user_money_detail
        where umd_uid=#{uid}</select>
        where umd_uid=#{uid} and umd_show=1 </select>
    <select id="selectByMaxCreateTime" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM yeshi_ec_user_money_detail d WHERE d.umd_uid=#{uid} and
        FROM yeshi_ec_user_money_detail d WHERE d.umd_uid=#{uid} and d.umd_show=1 and
        d.`umd_createtime`<![CDATA[
            <=
        ]]>
        #{date} order by d.`umd_createtime` desc,d.umd_id desc limit #{count}
    </select>
    <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">SELECT
        count(umd_id) FROM yeshi_ec_user_money_detail where umd_uid=#{uid} and
        count(umd_id) FROM yeshi_ec_user_money_detail where umd_uid=#{uid}  and d.umd_show=1  and
        `umd_createtime`<![CDATA[
            <=
        ]]>
@@ -70,7 +71,7 @@
    </select>
    <select id="selectMonthCountByUid" resultType="java.lang.Integer">SELECT
        COUNT(*) FROM (SELECT * FROM yeshi_ec_user_money_detail d WHERE
        d.`umd_uid`=#{uid} and d.`umd_createtime` <![CDATA[<=]]>
        d.`umd_uid`=#{uid} and d.umd_show=1  and d.`umd_createtime` <![CDATA[<=]]>
        #{date} group by DATE_FORMAT(d.`umd_createtime`,'%y-%m')) a
    </select>
    <select id="selectMonthMoneyByUid" resultMap="UserMonthMoneyMap">
@@ -81,13 +82,13 @@
                income ,if(b.money is null,0,b.money) as expend FROM (select #{item}
                as `time`) c left join ( SELECT DATE_FORMAT(
                d.`umd_createtime`,'%Y-%m') AS `time`,SUM(d.`umd_money`) AS money
                FROM `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} AND
                FROM `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid}  and d.umd_show=1  AND
                d.`umd_money`&gt;=0 AND DATE_FORMAT(
                d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT(
                d.`umd_createtime`,'%Y-%m') ) a on a.time=c.time LEFT JOIN ( SELECT
                DATE_FORMAT( d.`umd_createtime`,'%Y-%m') AS
                `time`,SUM(d.`umd_money`) AS money FROM `yeshi_ec_user_money_detail`
                d WHERE d.`umd_uid`=#{uid} AND d.`umd_money`<![CDATA[<0]]>
                d WHERE d.`umd_uid`=#{uid}  and d.umd_show=1  AND d.`umd_money`<![CDATA[<0]]>
                AND DATE_FORMAT( d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY
                DATE_FORMAT( d.`umd_createtime`,'%Y-%m') ) b ON c.time=b.time
            </trim>
@@ -132,9 +133,9 @@
    <insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_user_money_detail
        (umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type)
        (umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show)
        values
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{subTitle,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{sourceIdentifyId,jdbcType=BIGINT},#{identifyCode,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER})
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{subTitle,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{sourceIdentifyId,jdbcType=BIGINT},#{identifyCode,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER},#{show,jdbcType=BOOLEAN})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
        useGeneratedKeys="true" keyProperty="id">
@@ -153,6 +154,7 @@
            <if test="createTime != null">umd_createtime,</if>
            <if test="updateTime != null">umd_updatetime,</if>
            <if test="orderType != null">umd_order_type,</if>
            <if test="show != null">umd_show,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -169,6 +171,7 @@
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="orderType != null">#{orderType,jdbcType=INTEGER}</if>
            <if test="show != null">#{show,jdbcType=BOOLEAN}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">update
@@ -184,7 +187,8 @@
        #{beiZhu,jdbcType=VARCHAR},umd_createtime =
        #{createTime,jdbcType=TIMESTAMP},umd_updatetime =
        #{updateTime,jdbcType=TIMESTAMP} ,umd_order_type
        =#{orderType,jdbcType=INTEGER} where umd_id = #{id,jdbcType=BIGINT}
        =#{orderType,jdbcType=INTEGER},umd_show
        =#{show,jdbcType=BOOLEAN} where umd_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">
        update yeshi_ec_user_money_detail
@@ -202,6 +206,7 @@
            <if test="createTime != null">umd_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">umd_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="orderType !=null">umd_order_type =#{orderType,jdbcType=INTEGER},</if>
            <if test="show !=null">umd_show =#{show,jdbcType=BOOLEAN},</if>
        </set>
        where umd_id = #{id,jdbcType=BIGINT}
    </update>
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
@@ -151,7 +151,6 @@
    @Resource
    private ExtractWeiXinRecordService extractWeiXinRecordService;
    
    @Transactional
    public Integer addExtract(Extract extract) {
        Integer integer = extract(extract);
@@ -425,7 +424,8 @@
            CMQManager.getInstance().addExtractResultMsg(extract, response, adminUser);
            LogHelper.userErrorInfo("提现:添加处理队列成功-"+extract.getId());
        } catch (Exception e) {
            LogHelper.userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
            LogHelper
                    .userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
        }
    }
@@ -683,7 +683,16 @@
            // 更新提现记录审核表
            extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
        }
        // 外显账户明细
        UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
                UserMoneyDetailTypeEnum.extract, extract.getUserInfo().getId(), extract.getId());
        if (userMoneyDetail != null) {
            UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
            detail.setShow(true);
            detail.setUpdateTime(new Date());
            userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
        }
    }
@@ -753,13 +762,11 @@
            return money;
    }
    
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void autoExtract(UserInfo user) {
        if (user == null || user.getWxOpenId() == null || user.getWxUnionId() == null ||
                user.getState() != UserInfo.STATE_NORMAL)
        if (user == null || user.getWxOpenId() == null || user.getWxUnionId() == null
                || user.getState() != UserInfo.STATE_NORMAL)
            return;
        
        Date date = new Date();
@@ -803,12 +810,12 @@
        //redPackParams.setSceneId(null);
        //redPackParams.setRiskInfo(null);
        
        // 发生红包状态
        boolean stateRedPack = false;
        
        String pwd = "1520950211";
        InputStream cert = ExtractServiceImpl.class.getClassLoader().getResourceAsStream("certificate/apiclient_cert.p12"); // 读取.p12文件
        InputStream cert = ExtractServiceImpl.class.getClassLoader()
                .getResourceAsStream("certificate/apiclient_cert.p12"); // 读取.p12文件
        // 执行发放红包
        try {
            String result = WXPayUtil.redPackToOpenId(redPackParams, pwd, cert);
@@ -872,7 +879,6 @@
        userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
    }
    private boolean parseSendResult(String result) {
        try {
            Document document = DocumentHelper.parseText(result);
@@ -900,7 +906,6 @@
        }
        return false;
    }
    
    private ExtractWeiXinRecord parseDTO(String result) {
        try {
@@ -953,8 +958,6 @@
        return null;
    }
    
    @Override
    public List<UserInfo> preAutoUser() throws Exception {
        int page = 0;
@@ -976,7 +979,8 @@
        
        while (true) {
            // 查询满足条件 1、2 的uid
            List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus, beganDate, endDate);
            List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus,
                    beganDate, endDate);
            if (listUser == null || listUser.isEmpty())
                break;
            
@@ -1014,8 +1018,6 @@
        return list;
    }
    
    @Override
    public List<String> getAutoExtractOpenIds() throws Exception {
        int page = 0;
@@ -1041,7 +1043,8 @@
        
        while (true) {
            // 查询满足条件 1、2 的uid
            List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus, beganDate, endDate);
            List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus,
                    beganDate, endDate);
            if (listUser == null || listUser.isEmpty())
                break;
            
@@ -1074,13 +1077,12 @@
        return listOpendIDs;
    }
    
    @Transactional(rollbackFor = Exception.class)
    private UserInfo subHongBaoByUid(Long uid, BigDecimal money, BigDecimal minSurplus) {
        UserInfo userInfo = userInfoMapper.selectByPrimaryKeyForUpdate(uid);
        if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getWxOpenId())
                && !StringUtil.isNullOrEmpty(userInfo.getWxUnionId()) && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
                && !StringUtil.isNullOrEmpty(userInfo.getWxUnionId())
                && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
            // 微信提现记录
            ExtractWeiXinRecord extractRecord = new ExtractWeiXinRecord();
            extractRecord.setUid(uid);
@@ -1119,7 +1121,6 @@
        return null;
    }
    
    @Override
    public void updateManualExtractRecord(List<RedPackRecord> list) throws ExtractException{
        if (list == null || list.isEmpty())
@@ -1130,13 +1131,13 @@
        }
    }
    
    @Transactional(rollbackFor = Exception.class)
    private void updateWeiXinRecord(RedPackRecord redPackRecord){
        if (StringUtil.isNullOrEmpty(redPackRecord.getOpenId()))
            return;
        
        ExtractWeiXinRecord record  = extractWeiXinRecordService.getByOpenIdAndType(redPackRecord.getOpenId(), ExtractWeiXinRecord.TYPE_MANUAL);
        ExtractWeiXinRecord record = extractWeiXinRecordService.getByOpenIdAndType(redPackRecord.getOpenId(),
                ExtractWeiXinRecord.TYPE_MANUAL);
        if (record == null)
            return;
            
@@ -1206,7 +1207,8 @@
            // 资金明细
            UserMoneyDetail detail = new UserMoneyDetail();
            detail.setCreateTime(new Date());
            detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWXRefund.name() + ":" + record.getId()));
            detail.setIdentifyCode(
                    StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWXRefund.name() + ":" + record.getId()));
            detail.setMoney(record.getMoney());
            detail.setTitle(UserMoneyDetailTypeEnum.extractAutoWXRefund.getDesc());
            detail.setType(UserMoneyDetailTypeEnum.extractAutoWXRefund);
fanli/src/main/java/com/yeshi/fanli/service/impl/money/tb/TaoBaoWeiQuanDrawBackServiceImpl.java
@@ -133,33 +133,7 @@
        List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
        if (list == null || list.size() == 0)
            return;
        // 查询还未扣款的主红包
        List<HongBaoV2> mainHongBaoList = new ArrayList<>();
        for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
            List<CommonOrder> orderList = commonOrderMapper.listBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                    weiQuanOrder.getOrderItemId());
            if (orderList != null && orderList.size() > 0)
                for (CommonOrder commonOrder : orderList) {
                    // 修改订单状态为维权
                    CommonOrder co = new CommonOrder(commonOrder.getId());
                    co.setState(CommonOrder.STATE_WQ);
                    co.setUpdateTime(new Date());
                    commonOrderMapper.updateByPrimaryKeySelective(co);
                    HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                    if (hongBaoOrder.getCommonOrder() != null
                            && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
                    // 查询是否已经维权
                    {
                        TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
                                hongBaoOrder.getCommonOrder().getTradeId(),
                                hongBaoOrder.getHongBaoV2().getUserInfo().getId());
                        if (drawBack == null)// 添加还未扣款的子订单
                            mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
                    }
                }
        }
        List<HongBaoV2> mainHongBaoList = getWeiQuanMainHongBao(list, orderId);
        if (mainHongBaoList == null || mainHongBaoList.size() == 0)
            return;
@@ -297,33 +271,25 @@
        }
    }
    @Transactional
    @Override
    public void doWeiQuanShare(String orderId) throws TaoBaoWeiQuanException {
        if (StringUtil.isNullOrEmpty(orderId))
            throw new TaoBaoWeiQuanException(1, "订单号为空值");
    private List<HongBaoV2> getWeiQuanMainHongBao(List<TaoBaoWeiQuanOrder> list, String orderId) {
        // 查询是否为维权订单
        List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
        if (list == null || list.size() == 0)
            return;
            return null;
        // 获取和该订单号有关联的用户
        // 获取主红包(同一个订单号的单只会对应同一个用户)
        List<CommonOrderVO> typeList = new ArrayList<>();
        CommonOrderVO cv = new CommonOrderVO();
        cv.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
        cv.setOrderNo(orderId);
        typeList.add(cv);
        List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
        // 查询还未扣款的主红包
        List<HongBaoV2> mainHongBaoList = new ArrayList<>();
        if (commonOrderList != null)
            for (CommonOrderVO vo : commonOrderList) {
                // 更改订单状态
                CommonOrder co = new CommonOrder(vo.getId());
        for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
            List<CommonOrder> orderList = commonOrderMapper.listBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                    weiQuanOrder.getOrderItemId());
            if (orderList != null && orderList.size() > 0)
                for (CommonOrder commonOrder : orderList) {
                    // 修改订单状态为维权
                    CommonOrder co = new CommonOrder(commonOrder.getId());
                co.setState(CommonOrder.STATE_WQ);
                co.setUpdateTime(new Date());
                commonOrderMapper.updateByPrimaryKeySelective(co);
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
                    HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
                if (hongBaoOrder.getCommonOrder() != null
                        && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
                // 查询是否已经维权
@@ -335,6 +301,20 @@
                        mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
                }
            }
        }
        return mainHongBaoList;
    }
    @Transactional
    @Override
    public void doWeiQuanShare(String orderId) throws TaoBaoWeiQuanException {
        if (StringUtil.isNullOrEmpty(orderId))
            throw new TaoBaoWeiQuanException(1, "订单号为空值");
        List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
        if(list==null||list.size()==0)
            return;
        List<HongBaoV2> mainHongBaoList = getWeiQuanMainHongBao(list, orderId);
        if (mainHongBaoList == null || mainHongBaoList.size() == 0)
            return;
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -316,6 +316,7 @@
        detail.setType(UserMoneyDetailTypeEnum.extract);
        detail.setUpdateTime(new Date());
        detail.setUserInfo(extract.getUserInfo());
        detail.setShow(false);
        return detail;
    }
@@ -375,6 +376,7 @@
        detail.setType(UserMoneyDetailTypeEnum.extractReject);
        detail.setUpdateTime(new Date());
        detail.setUserInfo(extract.getUserInfo());
        detail.setShow(false);// 隐藏提现失败记录
        return detail;
    }
@@ -587,7 +589,8 @@
        detail.setIdentifyCode(
                StringUtil.Md5(UserMoneyDetailTypeEnum.subsidy.name() + "-" + orderType + "-" + uid + "-" + timeF));
        detail.setMoney(money);
        detail.setTitle(timeF + UserMoneyDetailTypeEnum.subsidy.getDesc()+"["+Constant.getSourceName(orderType)+"]");
        detail.setTitle(
                timeF + UserMoneyDetailTypeEnum.subsidy.getDesc() + "[" + Constant.getSourceName(orderType) + "]");
        detail.setType(UserMoneyDetailTypeEnum.subsidy);
        detail.setDescInfo("邀请订单补贴");
        detail.setUpdateTime(new Date());