| | |
| | | }
|
| | |
|
| | | @RequestMapping("findThreeFriendsCount")
|
| | | public void findThreeFriendsCount(long id, PrintWriter out) {
|
| | | public void findThreeFriendsCount(long id, String callback, PrintWriter out) {
|
| | | int count1 = userInfoService.findFriendsCount(id, 1);
|
| | | int count2 = userInfoService.findFriendsCount(id, 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count1", count1);
|
| | | data.put("count2", count2);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("findThreeFriends")
|
| | | public void findThreeFriends(long id, int type, int page, PrintWriter out) {
|
| | | public void findThreeFriends(long id, int type, int page, String callback, PrintWriter out) {
|
| | | int pageSize = 30;
|
| | | List<InviteUser> list = userInfoService.getFriendsList(id, type, page, pageSize);
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", array);
|
| | | data.put("pages", count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("findThreeSales")
|
| | |
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html",
|
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | else
|
| | |
|
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
|
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | data.put("inviteList", configService.get("team_list"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | final UserInfo uuser = user;
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * h5收藏
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping("collectionGoodsJp")
|
| | | public void collectionGoodsJp(String callback, AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
|
| | | |
| | | public void collectionGoodsJp(String callback, AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
|
| | |
|
| | | if (uid == null || auctionId == null) {
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult(""));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | CollectionGoods find = collectionGoodsService.findByUidAndAuctionId(uid, auctionId);
|
| | | |
| | |
|
| | | if (find == null) {
|
| | | // 添加收藏
|
| | | CollectionGoods cg = TaoBaoUtil.getCollectionGoods(auctionId, new UserInfo(uid));
|
| | | collectionGoodsService.save(cg);
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadTrueResult(1));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1));
|
| | | } else {
|
| | | // 取消收藏
|
| | | collectionGoodsService.delete(find);
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadTrueResult(0));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(0));
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping("collectionGoodsList")
|
| | |
| | | import javax.persistence.ManyToOne;
|
| | | import javax.persistence.Table;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | /**
|
| | | * 丢失订单
|
| | | * |
| | | * @author cxx
|
| | | *
|
| | | * @date 2018年1月29日
|
| | | */
|
| | | @Entity
|
| | | @Table(name="yeshi_ec_lost_order")
|
| | | @Table(name = "yeshi_ec_lost_order")
|
| | | @org.yeshi.utils.mybatis.Table("yeshi_ec_lost_order")
|
| | | public class LostOrder {
|
| | | |
| | |
|
| | | public final static int RESULT_CODE_VERFING = 1;// 审核中
|
| | | public final static int RESULT_CODE_SUCCESS = 2;// 成功
|
| | | public final static int RESULT_CODE_FAIL = 3;// 失败(通过后3日未处理成功则判断为失败)
|
| | |
|
| | | @Id
|
| | | @GeneratedValue(strategy=GenerationType.AUTO)
|
| | | @GeneratedValue(strategy = GenerationType.AUTO)
|
| | | @Expose
|
| | | @Column(name="id")
|
| | | private Long id;
|
| | | @Expose
|
| | | private String orderId;//订单号
|
| | | @Column(name="orderId")
|
| | | private String orderId;// 订单号
|
| | | @Column(name="type")
|
| | | @Expose
|
| | | private Integer type;//订单类型
|
| | | private Integer type;// 订单类型 1-淘宝订单
|
| | | @Column(name="state")
|
| | | @Expose
|
| | | private Integer state;//订单状态 0:审核 1:通过 2:拒绝
|
| | | private Integer state;// 订单状态 0:审核 1:通过 2:拒绝
|
| | | @Column(name="createTime")
|
| | | @Expose
|
| | | private Long createTime;
|
| | | @Column(name="handleTime")
|
| | | @Expose
|
| | | private Long handleTime;
|
| | | |
| | |
|
| | | @Column(name="uid")
|
| | | @ManyToOne
|
| | | @JoinColumn(name="uid")
|
| | | @JoinColumn(name = "uid")
|
| | | @Expose
|
| | | private UserInfo userInfo;
|
| | | |
| | |
|
| | | @Column(name="oid")
|
| | | @ManyToOne
|
| | | @JoinColumn(name="oid")
|
| | | @JoinColumn(name = "oid")
|
| | | @Expose
|
| | | private Order order;
|
| | | @Column(name="remake")
|
| | | @Expose
|
| | | private String remake;
|
| | | @Column(name="judge")
|
| | | @Expose
|
| | | private String judge;//系统判定:如果用户在本系统购买并成功上传过订单,且上传的丢失订单后6为相同的话,那么系统判定为匹配
|
| | | |
| | | private String judge;// 系统判定:如果用户在本系统购买并成功上传过订单,且上传的丢失订单后6位相同的话,那么系统判定为匹配
|
| | |
|
| | | @Column(name="result_code")
|
| | | @javax.persistence.Column(name="result_code")
|
| | | @Expose
|
| | | private Integer resultCode;// 第三方平台订单爬取结果
|
| | |
|
| | | public Integer getResultCode() {
|
| | | return resultCode;
|
| | | }
|
| | |
|
| | | public void setResultCode(Integer resultCode) {
|
| | | this.resultCode = resultCode;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | | |
| | |
|
| | | public String getRemake() {
|
| | | return remake;
|
| | | }
|
| | |
| | | public void setRemake(String remake) {
|
| | | this.remake = remake;
|
| | | }
|
| | | |
| | |
|
| | | public String getJudge() {
|
| | | return judge;
|
| | | }
|
| | |
| | | public void setOrder(Order order) {
|
| | | this.order = order;
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.LostOrderMapper;
|
| | | import com.yeshi.fanli.dao.order.LostOrderDao;
|
| | | import com.yeshi.fanli.dao.order.PidOrderDao;
|
| | | import com.yeshi.fanli.entity.bus.user.LostOrder;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | @Service
|
| | | public class LostOrderServiceImpl implements LostOrderService {
|
| | |
| | | @Resource
|
| | | private PidOrderDao pidOrderDao;
|
| | |
|
| | | @Resource
|
| | | private LostOrderMapper lostOrderMapper;
|
| | |
|
| | | @Override
|
| | | public int addLostOrder(LostOrder lostOrder) {
|
| | | String orderId = lostOrder.getOrderId();
|
| | |
| | | if (type == null) { // 默认为淘宝订单
|
| | | lostOrder.setType(1);
|
| | | type = 1;
|
| | | }
|
| | |
|
| | | // 查询是否提交
|
| | | List<LostOrder> orderList = lostOrderMapper.selectByOrderId(orderId);
|
| | | if (orderList != null && orderList.size() > 0) {
|
| | | if (orderList.get(0).getState() == 0) {
|
| | | return -2;
|
| | | } else {
|
| | | return -1;
|
| | | }
|
| | | }
|
| | |
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderId, type);
|
| | |
| | | return lostOrderDao.find(LostOrder.class, id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<LostOrder> getLostOrderListByUid(Long uid, int page, int pageSize) {
|
| | |
|
| | | return lostOrderDao.list("from LostOrder lo where lo.userInfo.id=? order by lo.createTime desc",
|
| | | (page - 1) * pageSize, pageSize, new Serializable[] { uid });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long getLostOrderCountByUid(Long uid) {
|
| | | return lostOrderDao.getCount("select count(*) from LostOrder lo where lo.userInfo.id=?",
|
| | | new Serializable[] { uid });
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void processSuceess(String orderId) {
|
| | | // 查询订单号是否在申诉列表中
|
| | | List<LostOrder> list = lostOrderMapper.selectByOrderId(orderId);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | for (LostOrder lo : list) {
|
| | | if (lo.getState() == 1 && lo.getResultCode() != null
|
| | | && lo.getResultCode() == LostOrder.RESULT_CODE_VERFING) {
|
| | | LostOrder update = new LostOrder();
|
| | | update.setId(lo.getId());
|
| | | update.setResultCode(LostOrder.RESULT_CODE_SUCCESS);
|
| | | lostOrderMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void processFail(String orderId) {
|
| | | lostOrderDao.update("update LostOrder lo set lo.resultCode=? where lo.orderId=?",
|
| | | new Serializable[] { LostOrder.RESULT_CODE_FAIL, orderId });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void processFail() {
|
| | | // 订单申诉人工通过后,但是隔了3天还未处理成功就视为该订单申诉失败
|
| | | lostOrderDao.update(
|
| | | "update LostOrder lo set lo.resultCode=? where lo.state=1 and lo.resultCode=? and lo.handleTime<?",
|
| | | new Serializable[] { LostOrder.RESULT_CODE_FAIL, LostOrder.RESULT_CODE_VERFING,
|
| | | System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 3L });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteLostOrder(long id) {
|
| | | LostOrder lostOrder = new LostOrder();
|
| | | lostOrder.setId(id);
|
| | | lostOrderDao.delete(lostOrder);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteLostOrderByUid(long uid) {
|
| | | lostOrderDao.update("delete from LostOrder lo where lo.userInfo.id=?", new Serializable[] { uid });
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderItemServcie;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Override
|
| | | public void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | |
| | |
|
| | | /**
|
| | | * 利用redis的原子性将订单号锁住,不让其他处理
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | private void redisLockOrder(String orderId) {
|
| | |
| | |
|
| | | /**
|
| | | * 订单解锁
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | private void redisUnlockOrder(String orderId) {
|
| | |
| | |
|
| | | /**
|
| | | * 订单是否被锁住了
|
| | | * |
| | | * @param orderId
|
| | | * @return
|
| | | */
|
| | |
| | | try {
|
| | | String orderId = its.next();
|
| | | // 处理红包与子红包
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | processShopingFanliOrder(orderId, orders.get(orderId));
|
| | | // redisUnlockOrder(orderId);
|
| | | // redisUnlockOrder(orderId);
|
| | | // 出错了就不处理该订单了,需要定期检查
|
| | |
|
| | | // 更改丢失订单的状态
|
| | | lostOrderService.processSuceess(orderId);
|
| | |
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | | } catch (OrderItemException e2) {
|
| | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | // @Resource
|
| | | // private LostOrderService lostOrderService;
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void addPidOrderFromTaoBao(Map<String, List<PidOrder>> map) {
|
| | |
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | | // 订单锁定
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | doPidOrder(orderId);
|
| | | // redisUnlockOrder(orderId);
|
| | | // 处理订单找回
|
| | | // lostOrderService.processSuceess(orderId);
|
| | | // redisUnlockOrder(orderId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | public interface LostOrderService {
|
| | |
|
| | | static final ReentrantReadWriteLock lostOrderLock = new ReentrantReadWriteLock(true); |
| | | |
| | | static final ReentrantReadWriteLock lostOrderLock = new ReentrantReadWriteLock(true);
|
| | |
|
| | | int addLostOrder(LostOrder lostOrder);
|
| | |
|
| | | void pass(LostOrder lostOrder);
|
| | |
|
| | | void reject(LostOrder lostOrder);
|
| | |
|
| | | List<LostOrder> findLostOrderList(String key, int page);
|
| | |
|
| | | int getCount(String key);
|
| | |
|
| | | LostOrder getOne(long id);
|
| | |
|
| | | /**
|
| | | * 按用户查找丢失订单
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | List<LostOrder> getLostOrderListByUid(Long uid, int page, int pageSize);
|
| | |
|
| | | /**
|
| | | * 获取丢失订单数量
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long getLostOrderCountByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * 订单处理成功
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | void processSuceess(String orderId);
|
| | |
|
| | | /**
|
| | | * 订单处理失败
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | void processFail(String orderId);
|
| | |
|
| | | /**
|
| | | * 订单处理失败批量处理
|
| | | */
|
| | | void processFail();
|
| | |
|
| | | /**
|
| | | * 删除记录
|
| | | * |
| | | * @param id
|
| | | */
|
| | | void deleteLostOrder(long id);
|
| | |
|
| | | /**
|
| | | * 删除用户的所有记录
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | void deleteLostOrderByUid(long uid);
|
| | |
|
| | | }
|