| | |
| | | sendRecord.setWxId(wxId);
|
| | | sendRecord.setRobotId(robotId);
|
| | | sendRecord.setSendTime(new Date());
|
| | | sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE);
|
| | | sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE);
|
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | | String pid = result.getId();
|
| | |
|
| | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException{
|
| | | sendCircleByGoods(uid, goodsId, goodsType, null, sellerId);
|
| | | sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | try {
|
| | | // 发送商品
|
| | | sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId());
|
| | | sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(), UserCloudSendRecord.SEND_WAY_AUTO);
|
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" +uid + " 库id:"+ id + "]原因:"+ e.getMsg());
|
| | | }
|
| | | }
|
| | |
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId) throws UserCloudException {
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId,
|
| | | Long sellerId, int way) throws UserCloudException {
|
| | | // 验证是否授权
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | |
| | | custom = cloudManage.getCustom();
|
| | | }
|
| | | if (!custom) {
|
| | | throw new UserCloudException(0, "成功加入云发单库");
|
| | | return;
|
| | | }
|
| | |
|
| | | Integer robotId = userCloud.getRobotId();
|
| | |
| | | }
|
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
|
| | | sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
|
| | | sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId());
|
| | | try {
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
|
| | | sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
|
| | | sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId());
|
| | | }
|
| | | // 更新发单记录
|
| | | if (storeId != null) {
|
| | | UserCloudGoods record = new UserCloudGoods();
|
| | | record.setId(storeId);
|
| | | record.setState(UserCloudGoods.STATE_SHARED);
|
| | | record.setSendTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" +uid + " 库id:"+ storeId + "]原因:"+ e.getMsg());
|
| | | // 更新发单记录
|
| | | if (storeId != null) {
|
| | | UserCloudGoods record = new UserCloudGoods();
|
| | | record.setId(storeId);
|
| | | record.setState(UserCloudGoods.STATE_INVALID);
|
| | | record.setSendTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 更新发单记录
|
| | | if (storeId != null) {
|
| | | UserCloudGoods record = new UserCloudGoods();
|
| | | record.setId(storeId);
|
| | | record.setState(UserCloudGoods.STATE_SHARED);
|
| | | record.setSendTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | Date lastTime = new Date(time);
|
| | |
|
| | | for (int i = 0; i < 1000; i ++) {
|
| | | List<Long> list = userCloudMapper.listValidUid((i-1)*1000, 1000);
|
| | | // 查询哪些用户开通
|
| | | List<Long> list = userCloudMapper.listValidUid(i*1000, 1000);
|
| | | if (list == null || list.size() == 0) {
|
| | | break;
|
| | | }
|
| | |
|
| | | for (Long uid: list) {
|
| | | try {
|
| | | // 判断是否该 内容已发
|
| | | UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid, id);
|
| | | if (record != null)
|
| | | continue;
|
| | |
|
| | | // 是否在一个小时内已发送过
|
| | | UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
|
| | | if (last != null)
|
| | | continue;
|