| | |
| | | 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 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.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.PreviewInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private OrderMoneyDailyCountService orderMoneyDailyCountService;
|
| | | |
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | | |
| | | @Resource
|
| | | private PushService pushService;
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | try {
|
| | | previewInfoService.saveExtractRecord(uid, dayTime, money);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (PreviewInfoException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getExtractRecord")
|
| | |
| | | list = new ArrayList<>();
|
| | |
|
| | | JSONArray JSONArray = new JSONArray();
|
| | | |
| | | if (list.size() > 0) {
|
| | | for (Extract extract : list) {
|
| | | Date receiveTime = extract.getReceiveTime();
|
| | |
| | | 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);
|
| | | if (previewInfo == null || StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | MineInfoVO dto = null;
|
| | | if (previewInfo != null && !StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | dto = new Gson().fromJson(previewInfo.getContent(), MineInfoVO.class);
|
| | | }
|
| | |
|
| | | MineInfoVO dto = new Gson().fromJson(previewInfo.getContent(), MineInfoVO.class);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dto));
|
| | | if (dto == null)
|
| | | dto = new MineInfoVO();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(dto)));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @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);
|
| | | 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));
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
|
| | | 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;
|
| | | String link = null;
|
| | | if (previewInfo != null && StringUtil.isNullOrEmpty(previewInfo.getContent())) {
|
| | | link = previewInfo.getContent();
|
| | | }
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("link", previewInfo.getContent());
|
| | | object.put("link", link);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object));
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (type == null || num == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请完善数据"));
|
| | | if (type == null || type < 1 || type > 2) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择订单类型"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | 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);
|
| | | for (String orderId: list) {
|
| | | PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(Constant.SOURCE_TYPE_TAOBAO, |
| | | orderId, BigDecimal.ZERO);
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | 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;
|
| | | }
|
| | | }
|