| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @RequestMapping("getMianDanGoodsList")
|
| | | public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
|
| | |
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
|
| | | UserInfoExtra extraInfo=userInfoExtraService.getUserInfoExtra(uid);
|
| | | long integralCount=extraInfo!=null?extraInfo.getGoldCoin():0L;
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("couponCount", couponCount);
|
| | | data.put("integralCount", integralCount);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getExchangeDetail")
|
| | | public void getExchangeDetail(AcceptData acceptData, Long id, String callback, PrintWriter out) {
|
| | | if (id == null || id <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "兑换ID有误"));
|
| | | return;
|
| | | }
|
| | | IntegralExchange exchange = integralExchangeService.selectByPrimaryKey(id);
|
| | | if (exchange != null) {
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(exchange)));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(exchange))));
|
| | | } else {
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadFalseResult("未找到"));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未找到")));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 兑换金币检验
|
| | | *
|
| | |
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "verifyExchange", method = RequestMethod.POST)
|
| | | public void verifyExchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | @RequestMapping(value = "verifyExchange")
|
| | | public void verifyExchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
|
| | | try {
|
| | | ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id);
|
| | |
|
| | |
| | | Gson gson = gsonBuilder.create();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | if (StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } else {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | | } catch (IntegralExchangeException e) {
|
| | | if (StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | } else {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "'integralexchange-'+#uid")
|
| | | @RequestMapping(value = "exchange", method = RequestMethod.POST)
|
| | | public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | @RequestMapping(value = "exchange")
|
| | | public void exchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
|
| | | try {
|
| | | IntegralExchange exchange = integralExchangeService.exchange(uid, id);
|
| | |
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | data.put("goldCoin", extraVO.getGoldCoin() + "枚");
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } catch (IntegralExchangeException e) {
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | else
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(`joi_id`),0) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id WHERE jo_order_time IS NOT NULL |
| | | FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id WHERE jo_order_time IS NOT NULL and joi_valid_code!=2 |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY jo_order_time |
| | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | |
|
| | | @Override
|
| | | public IntegralExchange selectByPrimaryKey(Long id) {
|
| | | return integralExchangeMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<IntegralExchange> listValidCache(long start, int count){
|
| | |
| | | public Long countValid(){
|
| | | return integralExchangeMapper.countValid();
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException{
|
| | |
| | | Integer state = exchange.getState();
|
| | | if (state == null || state != 1)
|
| | | throw new IntegralExchangeException(1, "兑换活动未开启");
|
| | | |
| | |
|
| | | Integer goldCoin = exchange.getGoldCoin();
|
| | |
|
| | |
| | | boolean once = false; // 兑换一次是否消失
|
| | | try {
|
| | | if (ExchangeTypeEnum.freeCouponBuy == type) {
|
| | | List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name());
|
| | | List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid,
|
| | | CouponTypeEnum.freeCouponBuy.name());
|
| | | if (listCoupon != null && listCoupon.size() > 0)
|
| | | throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次");
|
| | |
|
| | | thing = "自购免单券";
|
| | | thingNum = "1张";
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(),
|
| | | UserSystemCoupon.SOURCE_EXCHANGE, null);
|
| | | once = true;
|
| | | couponNews = 1;
|
| | | } else if (ExchangeTypeEnum.freeCouponGive == type) {
|
| | | thing = "赠送免单券";
|
| | | thingNum = "1张";
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_EXCHANGE, null);
|
| | | couponNews = 1;
|
| | | } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
|
| | | thing = "返利奖励券";
|
| | | thingNum = "1张";
|
| | | String percent = configService.get("exchange_rebate_percent");
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
|
| | | userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
|
| | | couponNews = 1;
|
| | | } else if (ExchangeTypeEnum.inviteCodePublish == type) {
|
| | | thing = "邀请码发布卡";
|
| | |
| | | exchangeCount ++;
|
| | | String progress = exchange.getProgress();
|
| | | if (!StringUtil.isNullOrEmpty(progress))
|
| | | progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + "");
|
| | | progress = progress.replace("{已兑换}", exchangeCount + "").replace("{上限数}",
|
| | | exchange.getUpperLimit() + "");
|
| | | exchange.setProgress(progress);
|
| | |
|
| | | // 剩余金币
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{
|
| | | if (uid == null || uid <= 0)
|
| | |
| | | return exchangeTip;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
|
| | | if (uid == null || uid <= 0)
|
| | |
| | | Integer goldCoinHas = extraVO.getGoldCoin();
|
| | | if (goldCoin.intValue() > goldCoinHas.intValue())
|
| | | throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
|
| | | |
| | |
|
| | | try {
|
| | | UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid());
|
| | |
| | | throw new IntegralExchangeException(1, "兑换失败");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public List<IntegralExchange> listExchange(long start, int count, Long uid);
|
| | | |
| | |
|
| | | /**
|
| | | * 今日任务统计
|
| | |
| | | import com.yeshi.fanli.vo.integral.ExchangeTipVO;
|
| | |
|
| | | public interface IntegralExchangeService {
|
| | | |
| | | /**
|
| | | * 根据主键查询
|
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public IntegralExchange selectByPrimaryKey(Long id);
|
| | |
|
| | | /**
|
| | | * 查询有效的
|
| | |
| | | Map<String, Order> map = PlaceOrderCMQManager.getInstance()
|
| | | .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
|
| | | if (map != null) {
|
| | | // 是否是首单
|
| | |
|
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
|
| | | try {
|
| | | String key = its.next();
|
| | | Order order = map.get(key);
|
| | | // 是否是首单
|
| | | if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
|
| | | order.getUserInfo().getId())) {
|
| | | // 统计订单下的用户所获得的返利金额
|
| | | List<CommonOrder> list = commonOrderService
|
| | | .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId());
|
| | |
| | | // 获取上两级数据
|
| | | UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
|
| | | if (boss != null) {// 判断上级的红包
|
| | | if (hongBaoMoney.get(boss.getId()) == null
|
| | | || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
|
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
|
| | | .compareTo(new BigDecimal("0")) <= 0) {
|
| | | // 补偿金币
|
| | | integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(),
|
| | | order.getUserInfo().getId(), null);
|
| | |
| | | } else {// 自购订单
|
| | | UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
|
| | | if (boss != null) {// 判断上级的红包
|
| | | if (hongBaoMoney.get(boss.getId()) == null
|
| | | || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
|
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
|
| | | .compareTo(new BigDecimal("0")) <= 0) {
|
| | | // 补偿金币1级
|
| | | integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(),
|
| | | order.getUserInfo().getId(), null);
|
| | |
| | |
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {// 判断上级的红包
|
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
|
| | | .compareTo(new BigDecimal("0")) <= 0) {
|
| | | if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney
|
| | | .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
|
| | | // 补偿金币2级
|
| | | integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(),
|
| | | order.getUserInfo().getId(), null);
|
| | | integralTaskRecordService.firstRebateOrderRewardBossSuper(
|
| | | boss.getId(), order.getUserInfo().getId(), null);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|