| | |
| | | KEY = Constant.systemCommonConfig.getSignKey();
|
| | | }
|
| | |
|
| | | // @Around(EDP)
|
| | | @Around(EDP)
|
| | | public Object testAround(ProceedingJoinPoint joinPoint) throws IOException {
|
| | | Object[] args = joinPoint.getArgs();
|
| | | PrintWriter out = null;
|
| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.FileReader;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.OutputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLDecoder;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
| | | import org.yeshi.utils.CsvUtil;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.IPUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.entity.wx.RedPackRecord;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.PushRecordService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | @RequestMapping(value = "downAutoExtractTxt")
|
| | | public void downAutoExtractTxt(String callback, HttpServletResponse response, PrintWriter out) {
|
| | | try {
|
| | | List<String> list = extractService.getAutoExtractOpenIds();
|
| | | if (list == null || list.size() <= 1) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无用户满足自动提现条件"));
|
| | | return;
|
| | | }
|
| | | |
| | | String filepath = "自动提现OpenId "+ java.lang.System.currentTimeMillis() + ".txt";
|
| | | response.reset();
|
| | | response.setContentType("application/octet-stream");
|
| | | String fileName= URLDecoder.decode(filepath,"utf-8");
|
| | | response.addHeader("Content-Disposition","attachment;"+ "filename=\"" +URLEncoder.encode(fileName, "utf-8") + "\"");
|
| | | |
| | | StringBuilder sb = new StringBuilder();
|
| | | for(String t:list){
|
| | | sb.append(t+"\r\n");
|
| | | }
|
| | | |
| | | OutputStream os = response.getOutputStream();
|
| | | byte[] byt = sb.toString().getBytes();
|
| | | os.write(byt);
|
| | | os.flush();
|
| | | os.close();
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @RequestMapping(value = "uploadExcel", method = RequestMethod.POST)
|
| | | public void uploadExcel(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件不能为空!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<RedPackRecord> list = CsvUtil.getCsvData(file, RedPackRecord.class);
|
| | | extractService.updateManualExtractRecord(list);
|
| | | out.print(JsonUtil.loadTrueResult("上传成功"));
|
| | | } catch (ExtractException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult("上传失败"));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | // 高级接口 -- 信息更完整
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId)); |
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | } else {
|
| | | type = 4;
|
| | | goods = JDUtil.getSimpleGoodsInfo(jdId);
|
| | |
| | | package com.yeshi.fanli.dao.mybatis; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord; |
| | | |
| | | public interface ExtractWeiXinRecordMapper extends BaseMapper<ExtractWeiXinRecord> { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据openid、发放方式查询 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | ExtractWeiXinRecord getByOpenIdAndType(@Param("openId")String openId, @Param("type") Integer type); |
| | | |
| | | |
| | | /** |
| | | * 查询满足条件的用户id |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<Long> getValidUsers(@Param("list")List<Long> list,@Param("receivedDate") String receivedDate, |
| | | @Param("refundDate") String refundDate); |
| | | } |
| | |
| | | List<UserInfo> listByClosed(@Param("appId") String appId, @Param("phone") String phone);
|
| | |
|
| | | long countAvaiableUser();
|
| | | |
| | | |
| | | /**
|
| | | * 查询满足自动提现用户
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | List<Long> getAutoExtractUserIds(@Param("start") int start, @Param("count") int count, @Param("money") BigDecimal money);
|
| | | } |
| | |
| | | ""), hongbao("官方红包", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png", ""), hongbaoDeduct("红包退款", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png",
|
| | | ""), buyScore("购买积分", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""), extract("提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png",
|
| | | ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励金","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),;
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", "");
|
| | |
|
| | | private final String desc;
|
| | | private final String picture;
|
| | |
| | | <result column="aer_status" property="status" jdbcType="VARCHAR"/> |
| | | <result column="aer_send_time" property="sendTime" jdbcType="TIMESTAMP"/> |
| | | <result column="aer_rcv_time" property="rcvTime" jdbcType="TIMESTAMP"/> |
| | | <result column="aer_send_type" property="sendType" jdbcType="VARCHAR"/> |
| | | <result column="aer_hb_type" property="hbType" jdbcType="VARCHAR"/> |
| | | <result column="aer_total_num" property="totalNum" jdbcType="INTEGER"/> |
| | | <result column="aer_type" property="type" jdbcType="INTEGER"/> |
| | | <result column="aer_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="aer_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">aer_id,aer_uid,aer_open_id,aer_union_id,aer_money,aer_billno,aer_detailno,aer_status,aer_send_time,aer_rcv_time,aer_create_time,aer_update_time</sql> |
| | | <sql id="Base_Column_List">aer_id,aer_uid,aer_open_id,aer_union_id,aer_money,aer_billno,aer_detailno,aer_status,aer_send_time,aer_rcv_time,aer_send_type,aer_hb_type,aer_total_num,aer_type,aer_create_time,aer_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_extract_weixin_record where aer_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_extract_weixin_record where aer_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_extract_weixin_record (aer_id,aer_uid,aer_open_id,aer_union_id,aer_money,aer_billno,aer_detailno,aer_status,aer_send_time,aer_rcv_time,aer_create_time,aer_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{openId,jdbcType=VARCHAR},#{unionId,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{billno,jdbcType=VARCHAR},#{detailno,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR},#{sendTime,jdbcType=TIMESTAMP},#{rcvTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_extract_weixin_record (aer_id,aer_uid,aer_open_id,aer_union_id,aer_money,aer_billno,aer_detailno,aer_status,aer_send_time,aer_rcv_time,aer_send_type,aer_hb_type,aer_total_num,aer_type,aer_create_time,aer_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{openId,jdbcType=VARCHAR},#{unionId,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{billno,jdbcType=VARCHAR},#{detailno,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR},#{sendTime,jdbcType=TIMESTAMP},#{rcvTime,jdbcType=TIMESTAMP},#{sendType,jdbcType=VARCHAR},#{hbType,jdbcType=VARCHAR},#{totalNum,jdbcType=INTEGER},#{type,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_extract_weixin_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">aer_id,</if> |
| | |
| | | <if test="status != null">aer_status,</if> |
| | | <if test="sendTime != null">aer_send_time,</if> |
| | | <if test="rcvTime != null">aer_rcv_time,</if> |
| | | <if test="sendType != null">aer_send_type,</if> |
| | | <if test="hbType != null">aer_hb_type,</if> |
| | | <if test="totalNum != null">aer_total_num,</if> |
| | | <if test="type != null">aer_type,</if> |
| | | <if test="createTime != null">aer_create_time,</if> |
| | | <if test="updateTime != null">aer_update_time,</if> |
| | | </trim>values |
| | |
| | | <if test="status != null">#{status,jdbcType=VARCHAR},</if> |
| | | <if test="sendTime != null">#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="rcvTime != null">#{rcvTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="sendType != null">#{sendType,jdbcType=VARCHAR},</if> |
| | | <if test="hbType != null">#{hbType,jdbcType=VARCHAR},</if> |
| | | <if test="totalNum != null">#{totalNum,jdbcType=INTEGER},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord">update yeshi_ec_extract_weixin_record set aer_uid = #{uid,jdbcType=BIGINT},aer_open_id = #{openId,jdbcType=VARCHAR},aer_union_id = #{unionId,jdbcType=VARCHAR},aer_money = #{money,jdbcType=DECIMAL},aer_billno = #{billno,jdbcType=VARCHAR},aer_detailno = #{detailno,jdbcType=VARCHAR},aer_status = #{status,jdbcType=VARCHAR},aer_send_time = #{sendTime,jdbcType=TIMESTAMP},aer_rcv_time = #{rcvTime,jdbcType=TIMESTAMP},aer_create_time = #{createTime,jdbcType=TIMESTAMP},aer_update_time = #{updateTime,jdbcType=TIMESTAMP} where aer_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord">update yeshi_ec_extract_weixin_record set aer_uid = #{uid,jdbcType=BIGINT},aer_open_id = #{openId,jdbcType=VARCHAR},aer_union_id = #{unionId,jdbcType=VARCHAR},aer_money = #{money,jdbcType=DECIMAL},aer_billno = #{billno,jdbcType=VARCHAR},aer_detailno = #{detailno,jdbcType=VARCHAR},aer_status = #{status,jdbcType=VARCHAR},aer_send_time = #{sendTime,jdbcType=TIMESTAMP},aer_rcv_time = #{rcvTime,jdbcType=TIMESTAMP},aer_send_type = #{sendType,jdbcType=VARCHAR},aer_hb_type = #{hbType,jdbcType=VARCHAR},aer_total_num = #{totalNum,jdbcType=INTEGER},aer_type = #{type,jdbcType=INTEGER},aer_create_time = #{createTime,jdbcType=TIMESTAMP},aer_update_time = #{updateTime,jdbcType=TIMESTAMP} where aer_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord">update yeshi_ec_extract_weixin_record |
| | | <set> |
| | | <if test="uid != null">aer_uid=#{uid,jdbcType=BIGINT},</if> |
| | |
| | | <if test="status != null">aer_status=#{status,jdbcType=VARCHAR},</if> |
| | | <if test="sendTime != null">aer_send_time=#{sendTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="rcvTime != null">aer_rcv_time=#{rcvTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="sendType != null">aer_send_type=#{sendType,jdbcType=VARCHAR},</if> |
| | | <if test="hbType != null">aer_hb_type=#{hbType,jdbcType=VARCHAR},</if> |
| | | <if test="totalNum != null">aer_total_num=#{totalNum,jdbcType=INTEGER},</if> |
| | | <if test="type != null">aer_type=#{type,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">aer_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">aer_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where aer_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="getValidUsers" resultType="Long"> |
| | | SELECT DISTINCT A.uid |
| | | FROM (SELECT t.uid,d.`aer_uid` AS existUid,cc.aer_uid FROM ( |
| | | <foreach collection="list" item="item" index="index"> |
| | | <if test="index != 0">UNION</if> SELECT #{item} AS uid |
| | | </foreach> |
| | | )t |
| | | LEFT JOIN `yeshi_ec_extract_weixin_record` d ON d.aer_uid = t.uid |
| | | LEFT JOIN (SELECT DISTINCT d.aer_uid FROM `yeshi_ec_extract_weixin_record` d |
| | | WHERE IF(d.`aer_status` = 'RECEIVED',d.`aer_create_time` <![CDATA[<=]]> #{receivedDate}, FALSE) |
| | | OR IF(d.`aer_status` = 'REFUND',d.`aer_create_time` <![CDATA[<=]]> #{refundDate}, FALSE) |
| | | ORDER BY d.`aer_create_time` DESC |
| | | )cc ON cc.aer_uid = t.uid |
| | | WHERE IF (d.`aer_uid` IS NULL,TRUE, IFNULL(cc.aer_uid,FALSE)))A |
| | | </select> |
| | | |
| | | <select id="getByOpenIdAndType" resultMap="BaseResultMap"> |
| | | SELECT * FROM `yeshi_ec_extract_weixin_record` d |
| | | WHERE d.`aer_open_id` = #{openId} AND d.`aer_type` = #{type} |
| | | AND d.`aer_status`<![CDATA[<>]]> 'RECEIVED' AND d.`aer_status`<![CDATA[<>]]> 'REFUND' |
| | | ORDER BY d.`aer_create_time` DESC |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | yeshi_ec_user u
|
| | | where u.state=0
|
| | | </select>
|
| | | |
| | | <select id="getAutoExtractUserIds" resultType="java.lang.Long">
|
| | | SELECT u.`id` FROM `yeshi_ec_user_info_extra` t
|
| | | LEFT JOIN `yeshi_ec_user` u ON u.`id` = t.`uie_uid`
|
| | | WHERE t.`uie_auto_extract` = 1 AND u.`state` = 0 AND u.`my_hongBao` <![CDATA[>=]]> #{money} |
| | | AND u.`wx_open_id` IS NOT NULL
|
| | | LIMIT #{start},#{count}
|
| | | </select>
|
| | |
|
| | | </mapper>
|
| | |
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | |
| | | import org.dom4j.Element;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.entity.wx.RedPackParams;
|
| | | import org.yeshi.utils.entity.wx.RedPackRecord;
|
| | | import org.yeshi.utils.wx.WXPayUtil;
|
| | |
|
| | | import com.alipay.api.AlipayApiException;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | public void downAutoOpenIdFile() {
|
| | | @Override
|
| | | public List<String> getAutoExtractOpenIds() throws Exception {
|
| | | int page = 0;
|
| | | int pageSize = 100;
|
| | | int maxSize = 300;
|
| | | Date nowDate = new Date();
|
| | | // 条件3:距离上一次成功领取微信红包已经超过了30天时间,可在第31天再次下发;
|
| | | String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
|
| | | // 条件4:距离上一次未成功领取微信红包已经超过了15天时间,可在第16天再次下发;
|
| | | String refundDate = DateUtil.reduceDayTostring(15, nowDate);
|
| | |
|
| | | // 提现金额
|
| | | BigDecimal money = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MONEY);
|
| | | // 余额最低限制
|
| | | BigDecimal minSurplus = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MIN_SURPLUS);
|
| | |
|
| | | List<String> listOpendIDs = new ArrayList<String>();
|
| | | // 首行appID
|
| | | listOpendIDs.add(Constant.getWXAccount(null, null).getAppId());
|
| | |
|
| | | while (true) {
|
| | | // 查询满足条件 1、2 的uid
|
| | | List<Long> listId = userInfoService.getAutoExtractUserIds(page * pageSize, pageSize, minSurplus);
|
| | | if (listId == null || listId.isEmpty())
|
| | | break;
|
| | | |
| | | // 查询记录是否满足
|
| | | List<Long> listValid = extractWeiXinRecordService.getValidUsers(listId, receivedDate, refundDate);
|
| | | if (listValid == null || listValid.isEmpty()) {
|
| | | page ++;
|
| | | continue;
|
| | | }
|
| | | |
| | | for (Long uid: listValid) {
|
| | | UserInfo userInfo = subHongBaoByUid(uid, money, minSurplus);
|
| | | if (userInfo != null) {
|
| | | listOpendIDs.add(userInfo.getWxOpenId());
|
| | | if (listOpendIDs.size() >= maxSize)
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (listOpendIDs.size() >= maxSize)
|
| | | break;
|
| | | |
| | | page ++;
|
| | | }
|
| | | return listOpendIDs;
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private UserInfo subHongBaoByUid(Long uid, BigDecimal money, BigDecimal minSurplus) {
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo != null && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
|
| | | // 微信提现记录
|
| | | ExtractWeiXinRecord extractRecord = new ExtractWeiXinRecord();
|
| | | extractRecord.setUid(uid);
|
| | | extractRecord.setOpenId(userInfo.getWxOpenId());
|
| | | extractRecord.setUnionId(userInfo.getWxUnionId());
|
| | | extractRecord.setMoney(money);
|
| | | extractRecord.setStatus(ExtractWeiXinRecord.SENDING);
|
| | | extractRecord.setType(ExtractWeiXinRecord.TYPE_MANUAL);
|
| | | extractRecord.setCreateTime(new Date());
|
| | | extractRecord.setUpdateTime(new Date());
|
| | | extractWeiXinRecordService.insertSelective(extractRecord);
|
| | | // 记录id
|
| | | Long recordId = extractRecord.getId();
|
| | | |
| | | // 资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWX.name() + ":" + recordId));
|
| | | detail.setMoney(new BigDecimal("-"+ money.toString()));
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.extractAutoWX.getDesc());
|
| | | detail.setType(UserMoneyDetailTypeEnum.extractAutoWX);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(userInfo);
|
| | | |
| | | // 资金计算
|
| | | userMoneyService.subUserMoney(userInfo.getId(), money, detail);
|
| | |
|
| | | // 4、发送消息通知
|
| | | String desc = "为保障你的账户余额安全,自动提现金额将不会高于5元";
|
| | | String beizu = "账户中剩余余额请在本App内完成提现";
|
| | | userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
|
| | | |
| | | // 满足条件返回信息
|
| | | return userInfo;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void updateManualExtractRecord(List<RedPackRecord> list) throws ExtractException{
|
| | | if (list == null || list.isEmpty())
|
| | | throw new ExtractException(1, "红包记录信息为空");
|
| | |
|
| | | for (RedPackRecord redPackRecord: list) {
|
| | | updateWeiXinRecord(redPackRecord);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void updateWeiXinRecord(RedPackRecord redPackRecord){
|
| | | if (StringUtil.isNullOrEmpty(redPackRecord.getOpenId()))
|
| | | return;
|
| | |
|
| | | ExtractWeiXinRecord record = extractWeiXinRecordService.getByOpenIdAndType(redPackRecord.getOpenId(), ExtractWeiXinRecord.TYPE_MANUAL);
|
| | | if (record == null)
|
| | | return;
|
| | | |
| | | // 状态过滤
|
| | | String statusOld = record.getStatus();
|
| | | if (StringUtil.isNullOrEmpty(statusOld) ||ExtractWeiXinRecord.REFUND.equals(statusOld) |
| | | || ExtractWeiXinRecord.RFUND_ING.equals(statusOld)) |
| | | return;
|
| | | |
| | | ExtractWeiXinRecord updeteRecord = new ExtractWeiXinRecord();
|
| | | updeteRecord.setId(record.getId());
|
| | | updeteRecord.setUpdateTime(new Date());
|
| | | |
| | | String billno = redPackRecord.getBillno();
|
| | | if (!StringUtil.isNullOrEmpty(billno)) {
|
| | | updeteRecord.setBillno(billno.replace("`", ""));
|
| | | }
|
| | | |
| | | String detailno = redPackRecord.getDetailno();
|
| | | if (!StringUtil.isNullOrEmpty(detailno)) {
|
| | | updeteRecord.setDetailno(detailno.replace("`", ""));
|
| | | }
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
|
| | | String rcvTime = redPackRecord.getRcvTime();
|
| | | if (!StringUtil.isNullOrEmpty(rcvTime)) {
|
| | | try {
|
| | | updeteRecord.setRcvTime(sdf.parse(rcvTime));
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | String sendTime = redPackRecord.getSendTime();
|
| | | if (!StringUtil.isNullOrEmpty(sendTime)) {
|
| | | try {
|
| | | updeteRecord.setSendTime(sdf.parse(sendTime));
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | String status = redPackRecord.getStatus();
|
| | | if (!StringUtil.isNullOrEmpty(status)) {
|
| | | switch (status) {
|
| | | case "已发放待领取":
|
| | | status = ExtractWeiXinRecord.SENT;
|
| | | break;
|
| | | case "过期未领退款":
|
| | | status = ExtractWeiXinRecord.REFUND;
|
| | | break;
|
| | | case "已领取":
|
| | | status = ExtractWeiXinRecord.RECEIVED;
|
| | | break;
|
| | | default:
|
| | | status = null;
|
| | | break;
|
| | | } |
| | | }
|
| | | updeteRecord.setStatus(status);
|
| | | |
| | | // 更新红包记录
|
| | | extractWeiXinRecordService.updateByPrimaryKeySelective(updeteRecord);
|
| | | |
| | | if (!ExtractWeiXinRecord.REFUND.equals(status))
|
| | | return;
|
| | | |
| | | // 资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWXRefund.name() + ":" + record.getId()));
|
| | | detail.setMoney(record.getMoney());
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.extractAutoWXRefund.getDesc());
|
| | | detail.setType(UserMoneyDetailTypeEnum.extractAutoWXRefund);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(record.getUid()));
|
| | | |
| | | // 资金计算
|
| | | userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.money.extract;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | public void updateByPrimaryKeySelective(ExtractWeiXinRecord record) {
|
| | | extractWeiXinRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<Long> getValidUsers(List<Long> list, String receivedDate, String refundDate) {
|
| | | return extractWeiXinRecordMapper.getValidUsers(list, receivedDate, refundDate);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ExtractWeiXinRecord getByOpenIdAndType(String openId, Integer type) {
|
| | | return extractWeiXinRecordMapper.getByOpenIdAndType(openId, type);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.extractAutoWX) {
|
| | | if (detail.getMoney() == null || detail.getUser() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | }
|
| | |
|
| | | userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
|
| | |
| | | userInfo.setNickName(nickName);
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Long> getAutoExtractUserIds(int start, int count, BigDecimal minSurplus) {
|
| | | return userInfoMapper.getAutoExtractUserIds(start, count, minSurplus);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.yeshi.utils.entity.wx.RedPackRecord;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | * @param user
|
| | | */
|
| | | public void autoExtract(UserInfo user);
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | | * 获取自动提现openid
|
| | | * @return
|
| | | */
|
| | | public List<String> getAutoExtractOpenIds() throws Exception;
|
| | |
|
| | | /**
|
| | | * 更新手动微信提现红包记录
|
| | | * @param list
|
| | | * @throws ExtractException
|
| | | */
|
| | | public void updateManualExtractRecord(List<RedPackRecord> list) throws ExtractException;
|
| | | |
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.money.extract;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.ExtractWeiXinRecord;
|
| | |
|
| | | public interface ExtractWeiXinRecordService {
|
| | |
| | | public void insertSelective(ExtractWeiXinRecord record);
|
| | |
|
| | | public void updateByPrimaryKeySelective(ExtractWeiXinRecord record);
|
| | |
|
| | | /**
|
| | | * 查询有效用户ID
|
| | | */
|
| | | public List<Long> getValidUsers(List<Long> list, String receivedDate, String refundDate);
|
| | |
|
| | | /**
|
| | | * 根据openid、发放方式
|
| | | * @param openId
|
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | public ExtractWeiXinRecord getByOpenIdAndType(String openId, Integer type);
|
| | |
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.io.IOException;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.InviteUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.user.UserInfoException;
|
| | | import com.yeshi.fanli.vo.user.UserInfoVO;
|
| | |
| | | */
|
| | | public void saveUserInfo(String nickName, Long uid) throws UserInfoException;
|
| | |
|
| | | |
| | | /**
|
| | | * 获取可提现用户列表
|
| | | * @param page
|
| | | * @param count
|
| | | */
|
| | | public List<Long> getAutoExtractUserIds(int page, int count, BigDecimal minSurplus);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | // 微信自动提现金额
|
| | | public static final int AUTO_EXTRACT_MONEY = 1;
|
| | | // 微信自动提现最低余额
|
| | | public static final int AUTO_EXTRACT_MIN_SURPLUS = 2;
|
| | |
|
| | | public static WXGZConfig wxGZConfig;
|
| | |
|
| | |
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(filterMoney(msg.getMoney()) + "元", COLOR_HIGHLIGHT_CONTENT));
|
| | | contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getMoney()), COLOR_HIGHLIGHT_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("金额", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | |
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | |
|
| | | String inOrderCount = json.optString("inOrderCount");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setInOrderCount30Days(Long.parseLong(inOrderCount));
|
| | | }
|
| | | |
| | | goods.setCouponInfo(null);
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | | imageList.add(json.optString("imgUrl"));
|
| | | goods.setPicUrl(json.optString("imgUrl"));
|
| | | goods.setImageList(imageList);
|
| | | goods.setInOrderCount30Days(0L);
|
| | | goods.setIsHot(null);
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | goods.setOwner(null);
|
| | |
| | | <?xml version="1.0"?> |
| | | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>com.yeshi</groupId> |
| | | <artifactId>FanLiMain</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </parent> |
| | | <groupId>com.yeshi</groupId> |
| | | <artifactId>utils</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>utils</name> |
| | | <url>http://maven.apache.org</url> |
| | | <properties> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | </properties> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | | <artifactId>junit</artifactId> |
| | | <version>3.8.1</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | </project> |
| | | <?xml version="1.0"?>
|
| | | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | | <parent>
|
| | | <groupId>com.yeshi</groupId>
|
| | | <artifactId>FanLiMain</artifactId>
|
| | | <version>0.0.1-SNAPSHOT</version>
|
| | | </parent>
|
| | | <groupId>com.yeshi</groupId>
|
| | | <artifactId>utils</artifactId>
|
| | | <version>0.0.1-SNAPSHOT</version>
|
| | | <name>utils</name>
|
| | | <url>http://maven.apache.org</url>
|
| | | <properties>
|
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
| | | </properties>
|
| | | <dependencies>
|
| | | <dependency>
|
| | | <groupId>junit</groupId>
|
| | | <artifactId>junit</artifactId>
|
| | | <version>3.8.1</version>
|
| | | <scope>test</scope>
|
| | | </dependency>
|
| | | |
| | | <!-- csv文件解析依赖 -->
|
| | | <dependency>
|
| | | <groupId>com.opencsv</groupId>
|
| | | <artifactId>opencsv</artifactId>
|
| | | <version>4.3.2</version>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | | </project>
|
New file |
| | |
| | | package org.yeshi.utils;
|
| | |
|
| | | import java.io.InputStreamReader;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import com.opencsv.bean.CsvToBean;
|
| | | import com.opencsv.bean.CsvToBeanBuilder;
|
| | | import com.opencsv.bean.HeaderColumnNameMappingStrategy;
|
| | |
|
| | | public class CsvUtil {
|
| | |
|
| | | /**
|
| | | * 解析csv文件并转成bean
|
| | | * |
| | | * @param file csv文件
|
| | | * @param clazz 类
|
| | | * @param <T> 泛型
|
| | | * @return 泛型bean集合
|
| | | */
|
| | | public static <T> List<T> getCsvData(MultipartFile file, Class<T> clazz) {
|
| | | InputStreamReader in = null;
|
| | | try {
|
| | | in = new InputStreamReader(file.getInputStream(), "gbk");
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | HeaderColumnNameMappingStrategy<T> strategy = new HeaderColumnNameMappingStrategy<>();
|
| | | strategy.setType(clazz);
|
| | |
|
| | | CsvToBean<T> csvToBean = new CsvToBeanBuilder<T>(in).withSeparator(',').withQuoteChar('\'')
|
| | | .withMappingStrategy(strategy).build();
|
| | | return csvToBean.parse();
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | return ca.getTime();
|
| | | }
|
| | | |
| | | /**
|
| | | * 指定日期减去天数后的日期
|
| | | * |
| | | * @param num 减去的天数
|
| | | * @param nowDate 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static String reduceDayTostring(int num, Date date) throws ParseException {
|
| | | // 设置要获取到什么样的时间
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | // 获取String类型的时间
|
| | | String date_str = format.format(date);
|
| | | Date currdate = format.parse(date_str);
|
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, -num); // 日期减 如果不够减会将月变动
|
| | | return format.format(ca.getTime());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 计算两个日期之间相差的天数
|
New file |
| | |
| | | package org.yeshi.utils.entity.wx;
|
| | |
|
| | | import com.opencsv.bean.CsvBindByName;
|
| | |
|
| | | /**
|
| | | * 微信自动提现记录
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class RedPackRecord {
|
| | | // openId
|
| | | @CsvBindByName(column = "用户openid", required = true)
|
| | | private String openId;
|
| | | // 交易订单号
|
| | | @CsvBindByName(column = "商户订单号")
|
| | | private String billno;
|
| | | |
| | | // 红包订单-微信
|
| | | @CsvBindByName(column = "红包订单号")
|
| | | private String detailno;
|
| | |
|
| | | // 红包状态-微信
|
| | | @CsvBindByName(column = "红包状态")
|
| | | private String status;
|
| | | |
| | | // 发出时间-微信
|
| | | @CsvBindByName(column = "发送时间")
|
| | | private String sendTime;
|
| | | |
| | | // 接收时间-微信
|
| | | @CsvBindByName(column = "更新(领取/退款)时间")
|
| | | private String rcvTime;
|
| | | |
| | |
|
| | | public String getOpenId() {
|
| | | return openId;
|
| | | }
|
| | |
|
| | | public void setOpenId(String openId) {
|
| | | this.openId = openId;
|
| | | }
|
| | |
|
| | | public String getBillno() {
|
| | | return billno;
|
| | | }
|
| | |
|
| | | public void setBillno(String billno) {
|
| | | this.billno = billno;
|
| | | }
|
| | |
|
| | | public String getDetailno() {
|
| | | return detailno;
|
| | | }
|
| | |
|
| | | public void setDetailno(String detailno) {
|
| | | this.detailno = detailno;
|
| | | }
|
| | |
|
| | | public String getStatus() {
|
| | | return status;
|
| | | }
|
| | |
|
| | | public void setStatus(String status) {
|
| | | this.status = status;
|
| | | }
|
| | |
|
| | | public String getSendTime() {
|
| | | return sendTime;
|
| | | }
|
| | |
|
| | | public void setSendTime(String sendTime) {
|
| | | this.sendTime = sendTime;
|
| | | }
|
| | |
|
| | | public String getRcvTime() {
|
| | | return rcvTime;
|
| | | }
|
| | |
|
| | | public void setRcvTime(String rcvTime) {
|
| | | this.rcvTime = rcvTime;
|
| | | }
|
| | | }
|