| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | 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.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.aitaoker.QrcodeLoginDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.CloudOrderMenuEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloud;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGoods;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGroup;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudManage;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudException;
|
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudGroupException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudService;
|
| | | import com.yeshi.fanli.service.manger.alipay.UserCloudAlipayManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.suning.SuningUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.user.cloud.CloudOrderMenuVO;
|
| | | import com.yeshi.fanli.vo.user.cloud.UserCloudInfoVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/user/cloud")
|
| | | public class UserCloudControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private UserCloudService userCloudService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudOrderService userCloudOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudGroupService userCloudGroupService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudGoodsService userCloudGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudManageService userCloudManageService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudAlipayManager userCloudAlipayManager;
|
| | | |
| | | @Resource
|
| | | private GoodsEvaluateService goodsEvaluateService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | |
| | |
|
| | | /**
|
| | | * 查询开通记录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderRecord")
|
| | | public void getOrderRecord(String callback, AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null)
|
| | | page = 1;
|
| | |
|
| | | // 查询成功记录
|
| | | int state = 1;
|
| | | List<UserCloudOrder> list = userCloudOrderService.getOrderRecord(page, Constant.PAGE_SIZE, uid, state);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2, BigDecimal.ROUND_DOWN);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(TimeUtil.formatDate(value));
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | long count = userCloudOrderService.countOrderRecord(uid, state);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", gsonBuilder.create().toJson(list));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取开通信息
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getCloudInfo")
|
| | | public void getCloudInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户信息不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<CloudOrderMenuVO> listMenu = new ArrayList<>();
|
| | | CloudOrderMenuEnum[] menus = CloudOrderMenuEnum.values();
|
| | | for (CloudOrderMenuEnum menuEnum: menus) {
|
| | | CloudOrderMenuVO menuVO = new CloudOrderMenuVO();
|
| | | menuVO.setMoney(BigDecimal.valueOf(menuEnum.getMoney()) );
|
| | | menuVO.setType(menuEnum.name());
|
| | | menuVO.setDesc(menuEnum.getDescShow());
|
| | | listMenu.add(menuVO);
|
| | | }
|
| | | |
| | | |
| | | UserCloudInfoVO cloudInfoVO = new UserCloudInfoVO();
|
| | | cloudInfoVO.setNickName(userInfo.getNickName());
|
| | | cloudInfoVO.setPortrait(userInfo.getPortrait());
|
| | | cloudInfoVO.setOpenState(0); // 未开通
|
| | | cloudInfoVO.setListMenu(listMenu);
|
| | | |
| | | |
| | | // 是否开通
|
| | | UserCloud userCloud = userCloudService.getLastByUid(uid);
|
| | | if (userCloud == null) {
|
| | | cloudInfoVO.setOpenState(0); // 未开通
|
| | | } else {
|
| | | Date endTime = userCloud.getEndTime();
|
| | | if (endTime != null && endTime.getTime() > java.lang.System.currentTimeMillis()) {
|
| | | cloudInfoVO.setOpenState(1); // 还未过期
|
| | | // 登录微信
|
| | | cloudInfoVO.setWxName(userCloud.getWxName());
|
| | | if (userCloud.getStartTime() != null)
|
| | | cloudInfoVO.setOpenTime(TimeUtil.formatDateDot(userCloud.getStartTime()));
|
| | | if (userCloud.getEndTime() != null) {
|
| | | try {
|
| | | cloudInfoVO.setCountdown(DateUtil.daysBetween2(new Date(), userCloud.getEndTime()) + "");
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | Integer robotId = userCloud.getRobotId();
|
| | | // 检测是否已登录
|
| | | if (AitaokerApiUtil.onlineCheck(robotId)) {
|
| | | boolean circle = false;
|
| | | List<UserCloudGroup> listGroup = new ArrayList<>();
|
| | | List<UserCloudGroup> list = userCloudGroupService.listByUid(uid);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (UserCloudGroup cloudGroup : list) {
|
| | | if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) {
|
| | | if (cloudGroup.getState() != null)
|
| | | circle = cloudGroup.getState();
|
| | | } else {
|
| | | listGroup.add(cloudGroup);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | cloudInfoVO.setLoginState(true);
|
| | | cloudInfoVO.setCircle(circle);
|
| | | cloudInfoVO.setListGroup(listGroup);
|
| | | }
|
| | | }
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(cloudInfoVO));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取登录二维码
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getQrcodeMaclogin")
|
| | | public void getQrcodeMaclogin(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserCloud userCloud = userCloudService.getValidByUid(uid);
|
| | | if (userCloud == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "未开通云发单"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 机器人ID
|
| | | Integer robotId = userCloud.getRobotId();
|
| | | if (robotId == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "正在开通中,如有疑问请联系客服"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 获取登录URL
|
| | | QrcodeLoginDTO maclogin = AitaokerApiUtil.getQrcodeMaclogin(userCloud.getRobotId());
|
| | | if (maclogin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "获取登录二维码失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("wId", maclogin.getwId());
|
| | | data.put("qrCodeUrl", maclogin.getQrCodeUrl());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 检测是否微信登录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param wId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "macloginCheck")
|
| | | public void macloginCheck(String callback, AcceptData acceptData, Long uid, String wId, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserCloud userCloud = userCloudService.getValidByUid(uid);
|
| | | if (userCloud == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "云发单开通已过期"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 机器人ID
|
| | | Integer robotId = userCloud.getRobotId();
|
| | | if (robotId == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "正在开通中,如有疑问请联系客服"));
|
| | | return;
|
| | | }
|
| | |
|
| | | boolean state = false;
|
| | | JSONObject data = new JSONObject();
|
| | | QrcodeLoginDTO dto = AitaokerApiUtil.getQrcodeMacloginCheck(robotId, wId);
|
| | | if (dto != null) {
|
| | | LogHelper.cloudInfo("方法macloginCheck: [uid=" + uid + "][wxID=" + dto.getWcId() + "][ NickName=" + dto.getNickName() + "]" );
|
| | | try {
|
| | | // 更新微信信息
|
| | | userCloudService.updateWXInfo(uid, dto.getWcId(), dto.getNickName(), dto.getHeadUrl());
|
| | | } catch (UserCloudException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | return;
|
| | | }
|
| | |
|
| | | state = true;
|
| | | boolean circle = false;
|
| | | List<UserCloudGroup> listGroup = new ArrayList<>();
|
| | | List<UserCloudGroup> list = userCloudGroupService.listByUid(uid);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (UserCloudGroup cloudGroup : list) {
|
| | | if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) {
|
| | | if (cloudGroup.getState() != null)
|
| | | circle = cloudGroup.getState();
|
| | | } else {
|
| | | listGroup.add(cloudGroup);
|
| | | }
|
| | | }
|
| | | }
|
| | | data.put("wxName", dto.getNickName());
|
| | | data.put("circle", circle);
|
| | | data.put("listGroup", listGroup);
|
| | | }
|
| | | data.put("state", state);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 退出登录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "macloginOffline")
|
| | | public void macloginOffline(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserCloud userCloud = userCloudService.getLastByUid(uid);
|
| | | if (userCloud == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("云发单开通已过期"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 机器人ID
|
| | | Integer robotId = userCloud.getRobotId();
|
| | | if (robotId == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "未绑定机器人"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 退出机器人
|
| | | boolean offline = AitaokerApiUtil.macloginOffline(robotId);
|
| | | if (offline) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("退出成功"));
|
| | | } else {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("退出失败"));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 切换朋友圈状态
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "switchCircleState")
|
| | | public void switchCircleState(String callback, AcceptData acceptData, Long uid, Integer state, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | if (state == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "状态不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | boolean reslut = false;
|
| | | if (state == 1) {
|
| | | reslut = true;
|
| | | }
|
| | | |
| | | try {
|
| | | userCloudGroupService.switchCircleState(uid, reslut);
|
| | | } catch (UserCloudGroupException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 检测是否微信登录
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param wId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "searchGroup")
|
| | | public void searchGroup(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | // 重新获取群列表
|
| | | userCloudService.searchGroup(uid);
|
| | | // 获取最新群
|
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGroup", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (UserCloudException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置状态
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "switchGroupState")
|
| | | public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, Integer state,
|
| | | PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | if (id == null || state == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | boolean reslut = false;
|
| | | if (state == 1) {
|
| | | reslut = true;
|
| | | }
|
| | | |
| | | try {
|
| | | userCloudGroupService.switchGroupState(uid, id, reslut);
|
| | | // 获取最新群
|
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGroup", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (UserCloudGroupException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 设置状态
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteGroup")
|
| | | public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, |
| | | PrintWriter out) {
|
| | | if (uid == null || id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | userCloudGroupService.deleteGroup(uid, id);
|
| | | |
| | | // 获取最新群
|
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGroup", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (UserCloudGroupException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取云发单库商品
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGoodsList")
|
| | | public void getGoodsList(String callback, AcceptData acceptData, Long uid, Integer page, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null)
|
| | | page = 1;
|
| | |
|
| | | List<UserCloudGoods> list = userCloudGoodsService.listByUid((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE,
|
| | | uid);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | JSONObject data = new JSONObject();
|
| | | if (list.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | for (UserCloudGoods cloudGoods : list) {
|
| | | CommonGoods commonGoods = cloudGoods.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 判断是否已分享, 已分享显示已下架
|
| | | Integer state = cloudGoods.getState();
|
| | | if (state != null && state == UserCloudGoods.STATE_SHARED) {
|
| | | Integer goodsState = commonGoods.getState();
|
| | | if (goodsState != null && goodsState != 1) {
|
| | | commonGoods.setState(2);
|
| | | }
|
| | | }
|
| | | |
| | | if (state != null && state == UserCloudGoods.STATE_INVALID) {
|
| | | commonGoods.setState(1);
|
| | | }
|
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
|
| | | detailVO.setId(commonGoods.getId());
|
| | |
|
| | | JSONObject dataObject = new JSONObject();
|
| | | dataObject.put("id", cloudGoods.getId());
|
| | | dataObject.put("goods", gson.toJson(detailVO));
|
| | | array.add(dataObject);
|
| | | }
|
| | | }
|
| | |
|
| | | // 第一页返回设置信息
|
| | | if (page == 1) {
|
| | | boolean custom = false;
|
| | | boolean official = false;
|
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | if (cloudManage.getOfficial() != null)
|
| | | official = cloudManage.getOfficial();
|
| | | if (cloudManage.getCustom() != null)
|
| | | custom = cloudManage.getCustom();
|
| | | }
|
| | | data.put("custom", custom);
|
| | | data.put("official", official);
|
| | | }
|
| | | data.put("count", userCloudGoodsService.countByUid(uid));
|
| | | data.put("list", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 删除云发单备选库
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteGoods")
|
| | | public void deleteGoods(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整"));
|
| | | return;
|
| | | }
|
| | | userCloudGoodsService.deleteByPrimaryKeyAndUid(id, uid);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置状态
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "switchState")
|
| | | public void switchState(String callback, AcceptData acceptData, Long uid, Integer type, Integer state,
|
| | | PrintWriter out) {
|
| | | if (uid == null || type == null || state == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整"));
|
| | | return;
|
| | | }
|
| | | |
| | | boolean reslut = false;
|
| | | if (state == 1) {
|
| | | reslut = true;
|
| | | }
|
| | | |
| | | if (type == 1) {
|
| | | userCloudManageService.save(uid, reslut, null);
|
| | | } else {
|
| | | userCloudManageService.save(uid, null, reslut);
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("state", reslut);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 云发单支付
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type 机器人类型
|
| | | * @param response
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "pay")
|
| | | public void pay(String callback, AcceptData acceptData, Long uid, String type, PrintWriter out) {
|
| | | try {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(type)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请选择云发单套餐"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 创建支付信息
|
| | | String alipayForm = userCloudAlipayManager.getAlipayForm(uid, type);
|
| | |
|
| | | // 返回信息 - 缓存到session
|
| | | StringBuilder builder = new StringBuilder();
|
| | | builder.append("<html><head><title>alipay</title></head>");
|
| | | builder.append("<body>" + alipayForm + "</body></html>");
|
| | | |
| | | // 缓存到redis- 一分钟
|
| | | String key = RedisKeyEnum.cloudAlipayLink.getKey() + uid + "_" + type;
|
| | | key = StringUtil.Md5(key);
|
| | | redisManager.cacheCommonString(key , builder.toString() , 60*10);
|
| | | |
| | | String link = configService.get(ConfigKeyEnum.cloudAlipayJumpLink.getKey()) +"?key=%s";
|
| | | JSONObject dataObject = new JSONObject();
|
| | | dataObject.put("link", String.format(link, key));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dataObject));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "创建支付信息失败"));
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 动态一键发单
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sendCircle")
|
| | | public void sendCircle(String callback, AcceptData acceptData, Long uid, String id, PrintWriter out) {
|
| | | if (uid == null || StringUtil.isNullOrEmpty(id)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不能为空"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | userCloudService.sendByDynamic(uid, id);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("一键发单成功"));
|
| | | } catch (UserCloudException e) {
|
| | | if (e.getCode() > 1000 && e.getCode() < 1100) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("link", configService.get(ConfigKeyEnum.robotCloudLink.getKey()));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrue(e.getCode(), data, e.getMsg()).toString());
|
| | | } else {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg()));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 商品详情一键发单
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | | * @param goodsType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sendGoods")
|
| | | public void sendGoods(String callback, AcceptData acceptData, Long uid, String goodsId, Integer goodsType, PrintWriter out) {
|
| | | if (uid == null || goodsId == null || goodsType == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId, goodsType);
|
| | | if (evaluate != null) {
|
| | | userCloudService.sendByDynamic(uid, evaluate.getId());
|
| | | } else {
|
| | | |
| | | Long gid = null;
|
| | | Long sellerId = null;
|
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { // 苏宁
|
| | | String[] ids = SuningUtil.getGoodsIdDetail(goodsId);
|
| | | gid = Long.parseLong(ids[1]);
|
| | | sellerId = Long.parseLong(ids[0]);
|
| | | } else {
|
| | | gid = Long.parseLong(goodsId);
|
| | | }
|
| | | userCloudService.sendCustomGoods(uid, gid, goodsType, sellerId);
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("加入发单库成功"));
|
| | | } catch (UserCloudException e) {
|
| | | if (e.getCode() > 1000 && e.getCode() < 1100) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("link", configService.get(ConfigKeyEnum.robotCloudLink.getKey()));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrue(e.getCode(), data, e.getMsg()).toString());
|
| | | } else {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg()));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.DateUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.JsonElement; |
| | | import com.google.gson.JsonPrimitive; |
| | | import com.google.gson.JsonSerializationContext; |
| | | import com.google.gson.JsonSerializer; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.aitaoker.QrcodeLoginDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.CloudOrderMenuEnum; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloud; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGoods; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGroup; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudManage; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder; |
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudException; |
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudGroupException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; |
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGroupService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudOrderService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudService; |
| | | import com.yeshi.fanli.service.manger.alipay.UserCloudAlipayManager; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.RedisKeyEnum; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil; |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.suning.SuningUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.homemodule.BannerVO; |
| | | import com.yeshi.fanli.vo.user.cloud.CloudOrderMenuVO; |
| | | import com.yeshi.fanli.vo.user.cloud.UserCloudInfoVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/user/cloud") |
| | | public class UserCloudControllerV2 { |
| | | |
| | | @Resource |
| | | private UserCloudService userCloudService; |
| | | |
| | | @Resource |
| | | private UserCloudOrderService userCloudOrderService; |
| | | |
| | | @Resource |
| | | private UserCloudGroupService userCloudGroupService; |
| | | |
| | | @Resource |
| | | private UserCloudGoodsService userCloudGoodsService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private UserCloudManageService userCloudManageService; |
| | | |
| | | @Resource |
| | | private UserCloudAlipayManager userCloudAlipayManager; |
| | | |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | |
| | | @Resource |
| | | private UserVIPPreInfoService userVIPPreInfoService; |
| | | |
| | | /** |
| | | * 查询开通记录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param page |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getOrderRecord") |
| | | public void getOrderRecord(String callback, AcceptData acceptData, Integer page, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (page == null) |
| | | page = 1; |
| | | |
| | | // 查询成功记录 |
| | | int state = 1; |
| | | List<UserCloudOrder> list = userCloudOrderService.getOrderRecord(page, Constant.PAGE_SIZE, uid, state); |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() { |
| | | @Override |
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | // 保留2位小数 |
| | | value = value.setScale(2, BigDecimal.ROUND_DOWN); |
| | | return new JsonPrimitive(value.toString()); |
| | | } |
| | | } |
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(TimeUtil.formatDate(value)); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | long count = userCloudOrderService.countOrderRecord(uid, state); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | data.put("list", gsonBuilder.create().toJson(list)); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取开通信息 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getCloudInfo") |
| | | public void getCloudInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo userInfo = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (userInfo == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户信息不存在")); |
| | | return; |
| | | } |
| | | |
| | | List<CloudOrderMenuVO> listMenu = new ArrayList<>(); |
| | | CloudOrderMenuEnum[] menus = CloudOrderMenuEnum.values(); |
| | | for (CloudOrderMenuEnum menuEnum : menus) { |
| | | CloudOrderMenuVO menuVO = new CloudOrderMenuVO(); |
| | | menuVO.setMoney(BigDecimal.valueOf(menuEnum.getMoney())); |
| | | menuVO.setType(menuEnum.name()); |
| | | menuVO.setDesc(menuEnum.getDescShow()); |
| | | listMenu.add(menuVO); |
| | | } |
| | | |
| | | |
| | | UserCloudInfoVO cloudInfoVO = new UserCloudInfoVO(); |
| | | cloudInfoVO.setNickName(userInfo.getNickName()); |
| | | cloudInfoVO.setPortrait(userInfo.getPortrait()); |
| | | cloudInfoVO.setOpenState(0); // 未开通 |
| | | cloudInfoVO.setListMenu(listMenu); |
| | | |
| | | |
| | | // 是否开通 |
| | | UserCloud userCloud = userCloudService.getLastByUid(uid); |
| | | if (userCloud == null) { |
| | | cloudInfoVO.setOpenState(0); // 未开通 |
| | | } else { |
| | | Date endTime = userCloud.getEndTime(); |
| | | if (endTime != null && endTime.getTime() > java.lang.System.currentTimeMillis()) { |
| | | cloudInfoVO.setOpenState(1); // 还未过期 |
| | | // 登录微信 |
| | | cloudInfoVO.setWxName(userCloud.getWxName()); |
| | | if (userCloud.getStartTime() != null) |
| | | cloudInfoVO.setOpenTime(TimeUtil.formatDateDot(userCloud.getStartTime())); |
| | | if (userCloud.getEndTime() != null) { |
| | | try { |
| | | cloudInfoVO.setCountdown(DateUtil.daysBetween2(new Date(), userCloud.getEndTime()) + ""); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | Integer robotId = userCloud.getRobotId(); |
| | | // 检测是否已登录 |
| | | if (AitaokerApiUtil.onlineCheck(robotId)) { |
| | | boolean circle = false; |
| | | List<UserCloudGroup> listGroup = new ArrayList<>(); |
| | | List<UserCloudGroup> list = userCloudGroupService.listByUid(uid); |
| | | if (list != null && list.size() > 0) { |
| | | for (UserCloudGroup cloudGroup : list) { |
| | | if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { |
| | | if (cloudGroup.getState() != null) |
| | | circle = cloudGroup.getState(); |
| | | } else { |
| | | listGroup.add(cloudGroup); |
| | | } |
| | | } |
| | | } |
| | | |
| | | cloudInfoVO.setLoginState(true); |
| | | cloudInfoVO.setCircle(circle); |
| | | cloudInfoVO.setListGroup(listGroup); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 教程 |
| | | List<BannerVO> listBanner = swiperPictureService.getByBannerCard("cloud_course", acceptData.getSystem()); |
| | | if (listBanner != null && listBanner.size() > 0) { |
| | | cloudInfoVO.setCourse(listBanner.get(0)); |
| | | } |
| | | GsonBuilder gsonBuilder = new GsonBuilder(); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(gsonBuilder.create().toJson(cloudInfoVO))); |
| | | } |
| | | |
| | | /** |
| | | * 获取登录二维码 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestSerializableByKey(key = "'getQrcodeMaclogin-'+#uid") |
| | | @RequestMapping(value = "getQrcodeMaclogin") |
| | | public void getQrcodeMaclogin(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | UserCloud userCloud = userCloudService.getValidByUid(uid); |
| | | if (userCloud == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "未开通云发单")); |
| | | return; |
| | | } |
| | | |
| | | // 机器人ID |
| | | Integer robotId = userCloud.getRobotId(); |
| | | if (robotId == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "正在开通中,如有疑问请联系客服")); |
| | | return; |
| | | } |
| | | |
| | | // 获取登录URL |
| | | QrcodeLoginDTO maclogin = AitaokerApiUtil.getQrcodeMaclogin(userCloud.getRobotId()); |
| | | if (maclogin == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "获取登录二维码失败")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("wId", maclogin.getwId()); |
| | | data.put("qrCodeUrl", maclogin.getQrCodeUrl()); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 检测是否微信登录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param wId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "macloginCheck") |
| | | public void macloginCheck(String callback, AcceptData acceptData, Long uid, String wId, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | UserCloud userCloud = userCloudService.getValidByUid(uid); |
| | | if (userCloud == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "云发单开通已过期")); |
| | | return; |
| | | } |
| | | |
| | | // 机器人ID |
| | | Integer robotId = userCloud.getRobotId(); |
| | | if (robotId == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "正在开通中,如有疑问请联系客服")); |
| | | return; |
| | | } |
| | | |
| | | boolean state = false; |
| | | JSONObject data = new JSONObject(); |
| | | QrcodeLoginDTO dto = AitaokerApiUtil.getQrcodeMacloginCheck(robotId, wId); |
| | | if (dto != null) { |
| | | LogHelper.cloudInfo("方法macloginCheck: [uid=" + uid + "][wxID=" + dto.getWcId() + "][ NickName=" + dto.getNickName() + "]"); |
| | | try { |
| | | // 更新微信信息 |
| | | userCloudService.updateWXInfo(uid, dto.getWcId(), dto.getNickName(), dto.getHeadUrl()); |
| | | } catch (UserCloudException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | state = true; |
| | | boolean circle = false; |
| | | List<UserCloudGroup> listGroup = new ArrayList<>(); |
| | | List<UserCloudGroup> list = userCloudGroupService.listByUid(uid); |
| | | if (list != null && list.size() > 0) { |
| | | for (UserCloudGroup cloudGroup : list) { |
| | | if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { |
| | | if (cloudGroup.getState() != null) |
| | | circle = cloudGroup.getState(); |
| | | } else { |
| | | listGroup.add(cloudGroup); |
| | | } |
| | | } |
| | | } |
| | | data.put("wxName", dto.getNickName()); |
| | | data.put("circle", circle); |
| | | data.put("listGroup", listGroup); |
| | | } |
| | | data.put("state", state); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 退出登录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "macloginOffline") |
| | | public void macloginOffline(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | UserCloud userCloud = userCloudService.getLastByUid(uid); |
| | | if (userCloud == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("云发单开通已过期")); |
| | | return; |
| | | } |
| | | |
| | | // 机器人ID |
| | | Integer robotId = userCloud.getRobotId(); |
| | | if (robotId == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "未绑定机器人")); |
| | | return; |
| | | } |
| | | |
| | | // 退出机器人 |
| | | boolean offline = AitaokerApiUtil.macloginOffline(robotId); |
| | | if (offline) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("退出成功")); |
| | | } else { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("退出失败")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 切换朋友圈状态 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "switchCircleState") |
| | | public void switchCircleState(String callback, AcceptData acceptData, Long uid, Integer state, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | if (state == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "状态不能为空")); |
| | | return; |
| | | } |
| | | |
| | | boolean reslut = false; |
| | | if (state == 1) { |
| | | reslut = true; |
| | | } |
| | | |
| | | try { |
| | | userCloudGroupService.switchCircleState(uid, reslut); |
| | | } catch (UserCloudGroupException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); |
| | | } |
| | | |
| | | /** |
| | | * 检测是否微信登录 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param wId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "searchGroup") |
| | | public void searchGroup(String callback, AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | UserCloud userCloud = userCloudService.getValidByUid(uid); |
| | | if (userCloud == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请先开通云发单")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 重新获取群列表 |
| | | userCloudService.searchGroup(uid); |
| | | // 获取最新群 |
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid); |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGroup", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (UserCloudException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置状态 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param type |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "switchGroupState") |
| | | public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, Integer state, |
| | | PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | if (id == null || state == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不能为空")); |
| | | return; |
| | | } |
| | | |
| | | UserCloud userCloud = userCloudService.getValidByUid(uid); |
| | | if (userCloud == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请先开通云发单")); |
| | | return; |
| | | } |
| | | |
| | | boolean reslut = false; |
| | | if (state == 1) { |
| | | reslut = true; |
| | | } |
| | | |
| | | try { |
| | | |
| | | |
| | | userCloudGroupService.switchGroupState(uid, id, reslut); |
| | | // 获取最新群 |
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid); |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGroup", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (UserCloudGroupException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置状态 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param type |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "deleteGroup") |
| | | public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, |
| | | PrintWriter out) { |
| | | if (uid == null || id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | userCloudGroupService.deleteGroup(uid, id); |
| | | |
| | | // 获取最新群 |
| | | List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid); |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGroup", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (UserCloudGroupException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取云发单库商品 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param page |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getGoodsList") |
| | | public void getGoodsList(String callback, AcceptData acceptData, Long uid, Integer page, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (page == null) |
| | | page = 1; |
| | | |
| | | List<UserCloudGoods> list = userCloudGoodsService.listByUid((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, |
| | | uid); |
| | | if (list == null) |
| | | list = new ArrayList<>(); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | JSONObject data = new JSONObject(); |
| | | if (list.size() > 0) { |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | for (UserCloudGoods cloudGoods : list) { |
| | | CommonGoods commonGoods = cloudGoods.getCommonGoods(); |
| | | if (commonGoods == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 判断是否已分享, 已分享显示已下架 |
| | | Integer state = cloudGoods.getState(); |
| | | if (state != null && state == UserCloudGoods.STATE_SHARED) { |
| | | Integer goodsState = commonGoods.getState(); |
| | | if (goodsState != null && goodsState != 1) { |
| | | commonGoods.setState(2); |
| | | } |
| | | } |
| | | |
| | | if (state != null && state == UserCloudGoods.STATE_INVALID) { |
| | | commonGoods.setState(1); |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO); |
| | | detailVO.setId(commonGoods.getId()); |
| | | |
| | | JSONObject dataObject = new JSONObject(); |
| | | dataObject.put("id", cloudGoods.getId()); |
| | | dataObject.put("goods", gson.toJson(detailVO)); |
| | | array.add(dataObject); |
| | | } |
| | | } |
| | | |
| | | // 第一页返回设置信息 |
| | | if (page == 1) { |
| | | boolean custom = false; |
| | | boolean official = false; |
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid); |
| | | if (cloudManage != null) { |
| | | if (cloudManage.getOfficial() != null) |
| | | official = cloudManage.getOfficial(); |
| | | if (cloudManage.getCustom() != null) |
| | | custom = cloudManage.getCustom(); |
| | | } |
| | | data.put("custom", custom); |
| | | data.put("official", official); |
| | | } |
| | | data.put("count", userCloudGoodsService.countByUid(uid)); |
| | | data.put("list", array); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除云发单备选库 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "deleteGoods") |
| | | public void deleteGoods(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (id == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整")); |
| | | return; |
| | | } |
| | | userCloudGoodsService.deleteByPrimaryKeyAndUid(id, uid); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); |
| | | } |
| | | |
| | | /** |
| | | * 设置状态 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param type |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "switchState") |
| | | public void switchState(String callback, AcceptData acceptData, Long uid, Integer type, Integer state, |
| | | PrintWriter out) { |
| | | if (uid == null || type == null || state == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整")); |
| | | return; |
| | | } |
| | | |
| | | boolean reslut = false; |
| | | if (state == 1) { |
| | | reslut = true; |
| | | } |
| | | |
| | | if (type == 1) { |
| | | userCloudManageService.save(uid, reslut, null); |
| | | } else { |
| | | userCloudManageService.save(uid, null, reslut); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("state", reslut); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 云发单支付 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param type 机器人类型 |
| | | * @param response |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "pay") |
| | | public void pay(String callback, AcceptData acceptData, Long uid, String type, PrintWriter out) { |
| | | try { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(type)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请选择云发单套餐")); |
| | | return; |
| | | } |
| | | |
| | | CloudOrderMenuEnum typeEnum = CloudOrderMenuEnum.valueOf(type); |
| | | if (typeEnum == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "套餐选择出错")); |
| | | return; |
| | | } |
| | | |
| | | if (typeEnum == CloudOrderMenuEnum.robotMonthVip) { |
| | | UserVIPPreInfo vip = userVIPPreInfoService.getLatestProcessInfo(uid); |
| | | if (vip == null || vip.getProcess() < UserVIPLevel.LEVEL_7) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户等级不满足")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 创建支付信息 |
| | | String alipayForm = userCloudAlipayManager.getAlipayForm(uid, type); |
| | | |
| | | // 返回信息 - 缓存到session |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("<html><head><title>alipay</title></head>"); |
| | | builder.append("<body>" + alipayForm + "</body></html>"); |
| | | |
| | | // 缓存到redis- 一分钟 |
| | | String key = RedisKeyEnum.cloudAlipayLink.getKey() + uid + "_" + type; |
| | | key = StringUtil.Md5(key); |
| | | redisManager.cacheCommonString(key, builder.toString(), 60 * 10); |
| | | |
| | | String link = configService.getValue(ConfigKeyEnum.cloudAlipayJumpLink.getKey(), acceptData.getSystem()) + "?key=%s"; |
| | | JSONObject dataObject = new JSONObject(); |
| | | dataObject.put("link", String.format(link, key)); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dataObject)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "创建支付信息失败")); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 支付完成 |
| | | * |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "payEnd") |
| | | public void payEnd(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) { |
| | | if (uid == null || id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "参数信息缺失")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 检测是否支付完成 |
| | | userCloudAlipayManager.tradeQueryByOrderId(id); |
| | | |
| | | UserCloudOrder cloudOrder = userCloudOrderService.selectByPrimaryKey(id); |
| | | JSONObject dataObject = new JSONObject(); |
| | | dataObject.put("money", cloudOrder.getMoney()); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dataObject)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "回调信息失败")); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 动态一键发单 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "sendCircle") |
| | | public void sendCircle(String callback, AcceptData acceptData, Long uid, String id, PrintWriter out) { |
| | | if (uid == null || StringUtil.isNullOrEmpty(id)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不能为空")); |
| | | return; |
| | | } |
| | | try { |
| | | userCloudService.sendByDynamic(uid, id); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("一键发单成功")); |
| | | } catch (UserCloudException e) { |
| | | if (e.getCode() > 1000 && e.getCode() < 1100) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("link", configService.getValue(ConfigKeyEnum.robotCloudLink.getKey(), acceptData.getSystem())); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrue(e.getCode(), data, e.getMsg()).toString()); |
| | | } else { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 商品详情一键发单 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param goodsId |
| | | * @param goodsType |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "sendGoods") |
| | | public void sendGoods(String callback, AcceptData acceptData, Long uid, String goodsId, Integer goodsType, PrintWriter out) { |
| | | if (uid == null || goodsId == null || goodsType == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不能为空")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId, goodsType, acceptData.getSystem()); |
| | | if (evaluate != null) { |
| | | userCloudService.sendByDynamic(uid, evaluate.getId()); |
| | | } else { |
| | | |
| | | String gid = null; |
| | | Long sellerId = null; |
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { // 苏宁 |
| | | String[] ids = SuningUtil.getGoodsIdDetail(goodsId); |
| | | gid = ids[1]; |
| | | sellerId = Long.parseLong(ids[0]); |
| | | } else { |
| | | gid = goodsId; |
| | | } |
| | | userCloudService.sendCustomGoods(uid, gid, goodsType, sellerId); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("加入发单库成功")); |
| | | } catch (UserCloudException e) { |
| | | if (e.getCode() > 1000 && e.getCode() < 1100) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("link", configService.getValue(ConfigKeyEnum.robotCloudLink.getKey(), acceptData.getSystem())); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrue(e.getCode(), data, e.getMsg()).toString()); |
| | | } else { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | } |
| | | } |
| | | } |
| | | } |