| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo.PreviewEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount;
|
| | | import com.yeshi.fanli.exception.user.PreviewInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneyDailyCountService;
|
| | | import com.yeshi.fanli.service.inter.user.PreviewInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.money.MoneyPredictVO;
|
| | | import com.yeshi.fanli.vo.money.MoneyStatisticVO;
|
| | | import com.yeshi.fanli.vo.user.MineInfoVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/preview")
|
| | | public class PreviewInfoControllerV2 {
|
| | | @Resource
|
| | | private PreviewInfoService previewInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | | |
| | | @Resource
|
| | | private OrderMoneyDailyCountService orderMoneyDailyCountService;
|
| | | |
| | | |
| | | /**
|
| | | * 保存资金信息
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param vo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveMoneyInfo")
|
| | | public void saveMoneyInfo(String callback, AcceptData acceptData, Long uid, MoneyStatisticVO vo, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | previewInfoService.saveMoneyInfo(uid, vo);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (PreviewInfoException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "getMoneyInfo")
|
| | | public void getMoneyInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | MoneyStatisticVO dto = null;
|
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.moneyInfo);
|
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | dto = new Gson().fromJson(previewInfo.getContent(), MoneyStatisticVO.class);
|
| | | } else {
|
| | | dto = createMoneyStatistic(uid);
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dto));
|
| | | }
|
| | |
|
| | | private MoneyStatisticVO createMoneyStatistic(Long uid) {
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | |
|
| | | MoneyStatisticVO vo = new MoneyStatisticVO();
|
| | | vo.setBalanceMoney(user.getMyHongBao());
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | |
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | |
|
| | | typeList.clear();
|
| | | typeList.add(UserMoneyDetailTypeEnum.extract);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerify);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerifyNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractReject);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractAutoWX);
|
| | |
|
| | | // 本月提现
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | vo.setMonthExtractMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs());
|
| | |
|
| | | // 上月提现
|
| | | maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | vo.setLastMonthExtractMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs());
|
| | |
|
| | | minDate = new Date(0L);
|
| | | maxDate = new Date(timeStamp);
|
| | | // 累计成功提现
|
| | | vo.setTotalExtractMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs());
|
| | |
|
| | | // 累计自购返利
|
| | | typeList.clear();
|
| | | typeList.add(UserMoneyDetailTypeEnum.fanli);
|
| | | typeList.add(UserMoneyDetailTypeEnum.fanliNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.fanliWeiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.fanliWeiQuanNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.orderReward);
|
| | | typeList.add(UserMoneyDetailTypeEnum.orderRewardNew);
|
| | | vo.setTotalFanLiMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs());
|
| | |
|
| | | // 累计分享赚
|
| | | typeList.clear();
|
| | | typeList.add(UserMoneyDetailTypeEnum.share);
|
| | | typeList.add(UserMoneyDetailTypeEnum.shareNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.shareWeiQuan);
|
| | | vo.setTotalShareMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs());
|
| | |
|
| | | // 累计邀请赚
|
| | | typeList.clear();
|
| | | typeList.add(UserMoneyDetailTypeEnum.invite);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteWeiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
|
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy);
|
| | | typeList.add(UserMoneyDetailTypeEnum.teamReward);
|
| | | vo.setTotalInviteMoney(
|
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs());
|
| | |
|
| | | // 本月收货
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | vo.setMonthSettleMoney(hongBaoV2CountService.sumMoneyBySettleTimeAndUid(uid, minDate, maxDate));
|
| | |
|
| | | // 上月收货
|
| | | maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | vo.setLastMonthSettleMoney(hongBaoV2CountService.sumMoneyBySettleTimeAndUid(uid, minDate, maxDate));
|
| | |
|
| | | // 待确认收货(180天内)
|
| | | vo.setNotSettleMoney(hongBaoV2CountService.sumMoneyByANotSettleAndUid(uid));
|
| | |
|
| | | // 今日预估
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | vo.setTodayPredict(cratePredictVO(orderMoneyDailyCountService.query(uid, minDate, null)));
|
| | |
|
| | | // 本月预估
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | vo.setMonthPredict(cratePredictVO(orderMoneyDailyCountService.query(uid, minDate, maxDate)));
|
| | | return vo;
|
| | | }
|
| | | |
| | | private MoneyPredictVO cratePredictVO(List<OrderMoneyDailyCount> list) {
|
| | | MoneyPredictVO predictVO = new MoneyPredictVO();
|
| | | predictVO.setMineNum(0);
|
| | | predictVO.setTeamNum(0);
|
| | | predictVO.setMineMoney(BigDecimal.valueOf(0));
|
| | | predictVO.setTeamMoney(BigDecimal.valueOf(0));
|
| | | BigDecimal hundred = BigDecimal.valueOf(100);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (OrderMoneyDailyCount dailyCount : list) {
|
| | | if (dailyCount.getOrderNum() != null)
|
| | | predictVO.setMineNum(predictVO.getMineNum() + dailyCount.getOrderNum());
|
| | | if (dailyCount.getOrderNumTeam() != null)
|
| | | predictVO.setTeamNum(predictVO.getTeamNum() + dailyCount.getOrderNumTeam());
|
| | | if (dailyCount.getIncome() != null)
|
| | | predictVO.setMineMoney(predictVO.getMineMoney()
|
| | | .add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred)));
|
| | | if (dailyCount.getIncomeTeam() != null)
|
| | | predictVO.setTeamMoney(predictVO.getTeamMoney()
|
| | | .add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred)));
|
| | | }
|
| | | }
|
| | | predictVO.setTotalNum(predictVO.getTeamNum() + predictVO.getMineNum());
|
| | | predictVO.setTotalMoney(predictVO.getMineMoney().add(predictVO.getTeamMoney()));
|
| | | return predictVO;
|
| | | }
|
| | | |
| | | /**
|
| | | * 保存提现记录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param vo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveExtractRecord")
|
| | | public void saveExtractRecord(String callback, AcceptData acceptData, Long uid, String dayTime, BigDecimal money,
|
| | | PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | previewInfoService.saveExtractRecord(uid, dayTime, money);
|
| | | } catch (PreviewInfoException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getExtractRecord")
|
| | | public void getExtractRecord(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | List<Extract> list = null;
|
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.extractRecord);
|
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | Gson gson = new Gson();
|
| | | list = gson.fromJson(previewInfo.getContent(), new TypeToken<ArrayList<Extract>>() {}.getType());
|
| | | }
|
| | | |
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | |
|
| | | JSONArray JSONArray = new JSONArray();
|
| | | |
| | | if (list.size() > 0) {
|
| | | for (Extract extract : list) {
|
| | | Date receiveTime = extract.getReceiveTime();
|
| | | if (receiveTime == null) {
|
| | | continue;
|
| | | }
|
| | | String account = "支付宝:" + UserUtil.filterAlipayAccount(extract.getAccount());
|
| | | account = account + "-姓名:" + UserUtil.filterAlipayName(extract.getName());
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("id", extract.getId());
|
| | | object.put("title", "你于" + TimeUtil.formatDate(receiveTime) + "提现成功");
|
| | | object.put("account", account);
|
| | | object.put("money", "¥" + extract.getMoney().setScale(2).toString());
|
| | | JSONArray.add(object);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("count", JSONArray.size());
|
| | | json.put("list", JSONArray);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | }
|
| | | |
| | | /**
|
| | | * 删除提现记录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param vo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "previewExtractRecord")
|
| | | public void previewExtractRecord(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | previewInfoService.previewExtractRecord(uid);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("已添加预览"));
|
| | | } catch (PreviewInfoException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 删除提现记录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param vo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteExtractRecord")
|
| | | public void deleteExtractRecord(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | if (uid == null || id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不完整"));
|
| | | return;
|
| | | }
|
| | | previewInfoService.deleteExtractRecord(uid, id);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存我的信息
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param infoVO
|
| | | * @param file
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveMineInfo")
|
| | | public void saveMineInfo(String callback, AcceptData acceptData, MineInfoVO infoVO, PrintWriter out) {
|
| | | if (infoVO == null || infoVO.getUid() == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | previewInfoService.saveMineInfo(infoVO);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
|
| | | }
|
| | | }
|
| | | |
| | | @RequestMapping(value = "getMineInfo")
|
| | | public void getMineInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.mineInfo);
|
| | | if (previewInfo == null || StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | MineInfoVO dto = new Gson().fromJson(previewInfo.getContent(), MineInfoVO.class);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dto));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 到账预览-生产图片
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param money
|
| | | * @param time
|
| | | * @param orderNo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveMoneyArrival")
|
| | | public void saveMoneyArrival(String callback, AcceptData acceptData, Long uid, BigDecimal money, String dayTime,
|
| | | String orderNo, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | String link = previewInfoService.saveMoneyArrival(uid, money, dayTime, orderNo);
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("link", link);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object));
|
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @RequestMapping(value = "getMoneyArrivalImg")
|
| | | public void getMoneyArrivalImg(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.moneyInfo);
|
| | | if (previewInfo == null || StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("link", previewInfo.getContent());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 推送预览
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param vo
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveOrderInfo")
|
| | | public void saveOrderInfo(String callback, AcceptData acceptData, Long uid, Integer type, Integer num, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (type == null || num == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请完善数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.fanli.dto.push.PushContentDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.Extract; |
| | | import com.yeshi.fanli.entity.bus.user.PayInfo; |
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo; |
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo.PreviewEnum; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory; |
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum; |
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount; |
| | | import com.yeshi.fanli.exception.push.PushException; |
| | | import com.yeshi.fanli.exception.user.PreviewInfoException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.OrderMoneyDailyCountService; |
| | | import com.yeshi.fanli.service.inter.push.PushService; |
| | | import com.yeshi.fanli.service.inter.user.PayInfoService; |
| | | import com.yeshi.fanli.service.inter.user.PreviewInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.account.UserUtil; |
| | | import com.yeshi.fanli.vo.money.MoneyPredictVO; |
| | | import com.yeshi.fanli.vo.money.MoneyStatisticVO; |
| | | import com.yeshi.fanli.vo.user.MineInfoVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/preview") |
| | | public class PreviewInfoControllerV2 { |
| | | @Resource |
| | | private PreviewInfoService previewInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private HongBaoV2CountService hongBaoV2CountService; |
| | | |
| | | @Resource |
| | | private UserMoneyDetailService userMoneyDetailService; |
| | | |
| | | @Resource |
| | | private OrderMoneyDailyCountService orderMoneyDailyCountService; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @Resource |
| | | private PushService pushService; |
| | | |
| | | @Resource |
| | | private PayInfoService payInfoService; |
| | | |
| | | /** |
| | | * 保存资金信息 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param vo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveMoneyInfo") |
| | | public void saveMoneyInfo(String callback, AcceptData acceptData, Long uid, MoneyStatisticVO vo, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | try { |
| | | previewInfoService.saveMoneyInfo(uid, vo); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getMoneyInfo") |
| | | public void getMoneyInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | MoneyStatisticVO dto = null; |
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.moneyInfo); |
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) { |
| | | dto = new Gson().fromJson(previewInfo.getContent(), MoneyStatisticVO.class); |
| | | } else { |
| | | dto = createMoneyStatistic(uid); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dto)); |
| | | } |
| | | |
| | | private MoneyStatisticVO createMoneyStatistic(Long uid) { |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | |
| | | MoneyStatisticVO vo = new MoneyStatisticVO(); |
| | | vo.setBalanceMoney(user.getMyHongBao()); |
| | | Date minDate = null; |
| | | Date maxDate = null; |
| | | long timeStamp = System.currentTimeMillis(); |
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>(); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(timeStamp); |
| | | |
| | | typeList.clear(); |
| | | typeList.add(UserMoneyDetailTypeEnum.extract); |
| | | typeList.add(UserMoneyDetailTypeEnum.extractNew); |
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerify); |
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerifyNew); |
| | | typeList.add(UserMoneyDetailTypeEnum.extractReject); |
| | | typeList.add(UserMoneyDetailTypeEnum.extractAutoWX); |
| | | |
| | | // 本月提现 |
| | | maxDate = new Date(timeStamp); |
| | | calendar = Calendar.getInstance(); |
| | | minDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | vo.setMonthExtractMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs()); |
| | | |
| | | // 上月提现 |
| | | maxDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | minDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | vo.setLastMonthExtractMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs()); |
| | | |
| | | minDate = new Date(0L); |
| | | maxDate = new Date(timeStamp); |
| | | // 累计成功提现 |
| | | vo.setTotalExtractMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs()); |
| | | |
| | | // 累计自购返利 |
| | | typeList.clear(); |
| | | typeList.add(UserMoneyDetailTypeEnum.fanli); |
| | | typeList.add(UserMoneyDetailTypeEnum.fanliNew); |
| | | typeList.add(UserMoneyDetailTypeEnum.fanliWeiQuan); |
| | | typeList.add(UserMoneyDetailTypeEnum.fanliWeiQuanNew); |
| | | typeList.add(UserMoneyDetailTypeEnum.orderReward); |
| | | typeList.add(UserMoneyDetailTypeEnum.orderRewardNew); |
| | | vo.setTotalFanLiMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs()); |
| | | |
| | | // 累计分享赚 |
| | | typeList.clear(); |
| | | typeList.add(UserMoneyDetailTypeEnum.share); |
| | | typeList.add(UserMoneyDetailTypeEnum.shareNew); |
| | | typeList.add(UserMoneyDetailTypeEnum.shareWeiQuan); |
| | | vo.setTotalShareMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs()); |
| | | |
| | | // 累计邀请赚 |
| | | typeList.clear(); |
| | | typeList.add(UserMoneyDetailTypeEnum.invite); |
| | | typeList.add(UserMoneyDetailTypeEnum.inviteWeiQuan); |
| | | typeList.add(UserMoneyDetailTypeEnum.inviteAndShare); |
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy); |
| | | typeList.add(UserMoneyDetailTypeEnum.teamReward); |
| | | vo.setTotalInviteMoney( |
| | | userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate).abs()); |
| | | |
| | | // 本月收货 |
| | | maxDate = new Date(timeStamp); |
| | | calendar = Calendar.getInstance(); |
| | | minDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | vo.setMonthSettleMoney(hongBaoV2CountService.sumMoneyBySettleTimeAndUid(uid, minDate, maxDate)); |
| | | |
| | | // 上月收货 |
| | | maxDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | minDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | vo.setLastMonthSettleMoney(hongBaoV2CountService.sumMoneyBySettleTimeAndUid(uid, minDate, maxDate)); |
| | | |
| | | // 待确认收货(180天内) |
| | | vo.setNotSettleMoney(hongBaoV2CountService.sumMoneyByANotSettleAndUid(uid)); |
| | | |
| | | // 今日预估 |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp))); |
| | | vo.setTodayPredict(cratePredictVO(orderMoneyDailyCountService.query(uid, minDate, null))); |
| | | |
| | | // 本月预估 |
| | | maxDate = new Date(timeStamp); |
| | | calendar = Calendar.getInstance(); |
| | | minDate = new Date(TimeUtil |
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | vo.setMonthPredict(cratePredictVO(orderMoneyDailyCountService.query(uid, minDate, maxDate))); |
| | | return vo; |
| | | } |
| | | |
| | | private MoneyPredictVO cratePredictVO(List<OrderMoneyDailyCount> list) { |
| | | MoneyPredictVO predictVO = new MoneyPredictVO(); |
| | | predictVO.setMineNum(0); |
| | | predictVO.setTeamNum(0); |
| | | predictVO.setMineMoney(BigDecimal.valueOf(0)); |
| | | predictVO.setTeamMoney(BigDecimal.valueOf(0)); |
| | | BigDecimal hundred = BigDecimal.valueOf(100); |
| | | if (list != null && list.size() > 0) { |
| | | for (OrderMoneyDailyCount dailyCount : list) { |
| | | if (dailyCount.getOrderNum() != null) |
| | | predictVO.setMineNum(predictVO.getMineNum() + dailyCount.getOrderNum()); |
| | | if (dailyCount.getOrderNumTeam() != null) |
| | | predictVO.setTeamNum(predictVO.getTeamNum() + dailyCount.getOrderNumTeam()); |
| | | if (dailyCount.getIncome() != null) |
| | | predictVO.setMineMoney(predictVO.getMineMoney() |
| | | .add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred))); |
| | | if (dailyCount.getIncomeTeam() != null) |
| | | predictVO.setTeamMoney(predictVO.getTeamMoney() |
| | | .add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred))); |
| | | } |
| | | } |
| | | predictVO.setTotalNum(predictVO.getTeamNum() + predictVO.getMineNum()); |
| | | predictVO.setTotalMoney(predictVO.getMineMoney().add(predictVO.getTeamMoney())); |
| | | return predictVO; |
| | | } |
| | | |
| | | /** |
| | | * 保存提现记录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param vo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveExtractRecord") |
| | | public void saveExtractRecord(String callback, AcceptData acceptData, Long uid, String dayTime, BigDecimal money, |
| | | PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | try { |
| | | previewInfoService.saveExtractRecord(uid, dayTime, money); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getExtractRecord") |
| | | public void getExtractRecord(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | List<Extract> list = null; |
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.extractRecord); |
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) { |
| | | Gson gson = new Gson(); |
| | | list = gson.fromJson(previewInfo.getContent(), new TypeToken<ArrayList<Extract>>() { |
| | | }.getType()); |
| | | } |
| | | |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | JSONArray JSONArray = new JSONArray(); |
| | | if (list.size() > 0) { |
| | | for (Extract extract : list) { |
| | | Date receiveTime = extract.getReceiveTime(); |
| | | if (receiveTime == null) { |
| | | continue; |
| | | } |
| | | String account = "支付宝:" + UserUtil.filterAlipayAccount(extract.getAccount()); |
| | | account = account + "-姓名:" + UserUtil.filterAlipayName(extract.getName()); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("id", extract.getId()); |
| | | object.put("title", "你于" + TimeUtil.formatDate(receiveTime) + "提现成功"); |
| | | object.put("account", account); |
| | | object.put("money", "¥" + extract.getMoney().setScale(2).toString()); |
| | | JSONArray.add(object); |
| | | } |
| | | } |
| | | |
| | | JSONObject json = new JSONObject(); |
| | | json.put("count", JSONArray.size()); |
| | | json.put("list", JSONArray); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json)); |
| | | } |
| | | |
| | | /** |
| | | * 删除提现记录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param vo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "previewExtractRecord") |
| | | public void previewExtractRecord(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | try { |
| | | previewInfoService.previewExtractRecord(uid); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("已添加预览")); |
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除提现记录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param vo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "deleteExtractRecord") |
| | | public void deleteExtractRecord(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) { |
| | | if (uid == null || id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不完整")); |
| | | return; |
| | | } |
| | | previewInfoService.deleteExtractRecord(uid, id); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功")); |
| | | } |
| | | |
| | | /** |
| | | * 保存我的信息 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param infoVO |
| | | * @param file |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveMineInfo") |
| | | public void saveMineInfo(String callback, AcceptData acceptData, MineInfoVO infoVO, PrintWriter out) { |
| | | if (infoVO == null || infoVO.getUid() == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | try { |
| | | previewInfoService.saveMineInfo(infoVO); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getMineInfo") |
| | | public void getMineInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.mineInfo); |
| | | MineInfoVO dto = null; |
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) { |
| | | dto = new Gson().fromJson(previewInfo.getContent(), MineInfoVO.class); |
| | | } |
| | | |
| | | if (dto == null) |
| | | dto = new MineInfoVO(); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(dto))); |
| | | } |
| | | |
| | | /** |
| | | * 到账预览-生产图片 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param money |
| | | * @param time |
| | | * @param orderNo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveMoneyArrival") |
| | | public void saveMoneyArrival(String callback, AcceptData acceptData, Long uid, BigDecimal money, String dayTime, |
| | | PrintWriter out) { |
| | | try { |
| | | // 查询最新一条支付宝订单号 |
| | | PayInfo payInfo = payInfoService.getNearInfo(); |
| | | String orderNo = getAlipayNo(payInfo.getOrderId()); |
| | | |
| | | String link = previewInfoService.saveMoneyArrival(uid, money, dayTime, orderNo, acceptData.getPlatform()); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("link", link); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); |
| | | } catch (PreviewInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("预览失败")); |
| | | } |
| | | } |
| | | |
| | | private String getAlipayNo(String payNo) { |
| | | // 替换前8位 |
| | | String newNo = payNo.substring(9, payNo.length()); |
| | | newNo = TimeUtil.getyyyyMMdd(java.lang.System.currentTimeMillis()) + newNo; |
| | | // 随机生成替换后6位 |
| | | newNo = newNo.substring(0, payNo.length() - 6); |
| | | newNo += (long) ((Math.random() * 9 + 1) * 100000); |
| | | return newNo; |
| | | } |
| | | |
| | | @RequestMapping(value = "getMoneyArrivalImg") |
| | | public void getMoneyArrivalImg(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | PreviewInfo previewInfo = previewInfoService.get(uid, PreviewEnum.moneyInfo); |
| | | String link = null; |
| | | if (previewInfo != null && StringUtil.isNullOrEmpty(previewInfo.getContent())) { |
| | | link = previewInfo.getContent(); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("link", link); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); |
| | | } |
| | | |
| | | /** |
| | | * 推送预览 |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param vo |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveOrderInfo") |
| | | public void saveOrderInfo(String callback, AcceptData acceptData, Long uid, Integer type, Integer num, |
| | | PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (type == null || type < 1 || type > 2) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择订单类型")); |
| | | return; |
| | | } |
| | | |
| | | if (num == null || num <= 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写推送数量")); |
| | | return; |
| | | } |
| | | |
| | | if (num > 50) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("最多支持50条")); |
| | | return; |
| | | } |
| | | |
| | | // 获取最新订单号 |
| | | String orderNo = commonOrderService.getNewestOrderNoByTaoBao(); |
| | | |
| | | // 随机订单号 |
| | | List<String> list = getRandomOrderNo(orderNo, num); |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // @Override |
| | | // public void run() { |
| | | for (String orderId : list) { |
| | | PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(Constant.SOURCE_TYPE_TAOBAO, orderId, |
| | | BigDecimal.ZERO); |
| | | try { |
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null,acceptData.getSystem()); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (PushException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // } |
| | | // }).start(); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功")); |
| | | } |
| | | |
| | | private List<String> getRandomOrderNo(String orderNo, int count) { |
| | | String newNo = orderNo.substring(0, 3); |
| | | long lenth = orderNo.length() - 3; |
| | | |
| | | long tempNum = 1; |
| | | for (long i = 0; i < lenth - 1; i++) { |
| | | tempNum = tempNum * 10; |
| | | } |
| | | |
| | | Set<String> set = new HashSet<>(); |
| | | for (int i = 0; i < count; i++) { |
| | | int temp = set.size(); |
| | | while (set.size() <= temp) { |
| | | long randomNum = (long) ((Math.random() * 9 + 1) * tempNum); |
| | | set.add(newNo + randomNum); |
| | | } |
| | | } |
| | | |
| | | // 转换list |
| | | List<String> list = new ArrayList<>(); |
| | | for (String s : set) { |
| | | list.add(s); |
| | | } |
| | | // 排序 |
| | | Collections.sort(list); |
| | | |
| | | return list; |
| | | } |
| | | } |