| | |
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.alibaba.druid.support.logging.Log;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper;
|
| | |
| | | }
|
| | |
|
| | | private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
|
| | | long time1= java.lang.System.currentTimeMillis();
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | | throw new UserCloudException(1, "用户信息不存在");
|
| | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
|
| | | |
| | | long time2= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic保验证用户状态:" + (time2 - time1));
|
| | |
|
| | | |
| | | // 验证是否开通
|
| | | UserCloud userCloud = userCloudMapper.getValidByUid(uid);
|
| | | if (userCloud == null)
|
| | |
| | | if (StringUtil.isNullOrEmpty(wxId))
|
| | | throw new UserCloudException(1003, "微信号不存在,请先微信登录");
|
| | |
|
| | | long time3= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证是否满足开通:" + (time3 - time2));
|
| | |
|
| | | |
| | | // 验证开启状态
|
| | | List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
|
| | | if (listGroup == null || listGroup.size() == 0)
|
| | |
| | | if (listOpen.size() == 0)
|
| | | throw new UserCloudException(1005, "请先开启云发单群功能");
|
| | |
|
| | | long time4= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证是否开启:" + (time4 - time3));
|
| | | |
| | | // 验证发圈是否可行
|
| | | GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
|
| | | if (evaluate == null || evaluate.getState() == 0)
|
| | |
| | | if (comments == null || comments.size() == 0)
|
| | | throw new UserCloudException(1, "该内容不能转链");
|
| | |
|
| | | long time5= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证发圈内容是否满足:" + (time5 - time4));
|
| | | |
| | | // 检测微信是否登录状态
|
| | | if (!AitaokerApiUtil.onlineCheck(robotId)) {
|
| | | // 通知登录微信
|
| | |
| | | throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
|
| | | }
|
| | |
|
| | | long time6= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证发是否登录:" + (time6 - time5));
|
| | | |
| | | boolean hasToken = false;
|
| | | List<String> listComment = new ArrayList<>();
|
| | | for (CommentInfo commentInfo : comments) {
|
| | |
| | | listImg.add(imgInfo.getUrl());
|
| | | }
|
| | | }
|
| | | |
| | | long time7= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic发圈内容组织转链:" + (time7 - time6));
|
| | | |
| | |
|
| | | // 保存发送记录
|
| | | UserCloudSendRecord sendRecord = new UserCloudSendRecord();
|
| | |
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | | String pid = result.getId();
|
| | |
|
| | | long time8= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic保存发圈记录:" + (time8 - time7));
|
| | | |
| | | |
| | | for (UserCloudGroup cloudGroup : listOpen) {
|
| | | String title = evaluate.getTitle();
|
| | |
|
| | |
| | | }
|
| | | userCloudSendContentService.save(sendContent);
|
| | | }
|
| | | |
| | | long time9= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic执行发圈耗时:" + (time9 - time8));
|
| | | |
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
|
| | | throws UserCloudException {
|
| | | long begainTime = java.lang.System.currentTimeMillis();
|
| | | |
| | | // 验证是否授权
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | |
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
|
| | |
|
| | | long time2 = java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证用户耗时:" + (time2 - begainTime));
|
| | | |
| | | |
| | | // 验证是否开通
|
| | | UserCloud userCloud = userCloudMapper.getValidByUid(uid);
|
| | | if (userCloud == null)
|
| | | throw new UserCloudException(1001, "云发单已过期");
|
| | |
|
| | | |
| | | long time3= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否开通:" + (time3 - time2));
|
| | | |
| | | long time4 = time3;
|
| | | // 加入我的备选库
|
| | | if (storeId == null) {
|
| | | try {
|
| | |
| | | + "]原因:" + e.getMsg());
|
| | | throw new UserCloudException(1, "加入云发单备选库失败");
|
| | | }
|
| | | time4= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods加入备选库:" + (time4 - time3));
|
| | | }
|
| | |
|
| | | // 自选库商品是否打开
|
| | |
| | | if (listGroup == null || listGroup.size() == 0)
|
| | | throw new UserCloudException(1003, "请先登录微信");
|
| | |
|
| | | long time5= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否绑定微信:" + (time5 - time4));
|
| | | |
| | | List<UserCloudGroup> listOpen = new ArrayList<>();
|
| | | for (UserCloudGroup cloudGrou : listGroup) {
|
| | | if (cloudGrou.getState()) {
|
| | |
| | | throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
|
| | | }
|
| | |
|
| | | long time6= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否登录微信:" + (time6 - time5));
|
| | | |
| | | // 保存发送记录
|
| | | UserCloudSendRecord sendRecord = new UserCloudSendRecord();
|
| | | sendRecord.setUid(uid);
|
| | |
| | | sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_MANUAL);
|
| | | }
|
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | | |
| | | long time7= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods保存发送记录:" + (time7 - time6));
|
| | |
|
| | | try {
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | |
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | long time8= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods执行发送:" + (time8 - time7));
|
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + storeId + "]原因:" + e.getMsg());
|
| | | // 更新发单记录
|