Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
| | |
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
| | | import org.aspectj.lang.annotation.Around;
|
| | | import org.aspectj.lang.annotation.Aspect;
|
| | | import org.aspectj.lang.reflect.MethodSignature;
|
| | | import org.springframework.cache.Cache;
|
| | | import org.springframework.cache.Cache.ValueWrapper;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.core.DefaultParameterNameDiscoverer;
|
| | | import org.springframework.core.annotation.Order;
|
| | | import org.springframework.expression.EvaluationContext;
|
| | | import org.springframework.expression.Expression;
|
| | | import org.springframework.expression.ExpressionParser;
|
| | | import org.springframework.expression.spel.standard.SpelExpressionParser;
|
| | | import org.springframework.expression.spel.support.StandardEvaluationContext;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Component
|
| | | @Aspect
|
| | | @Order(4)
|
| | | public class RequestSerializableAspect {
|
| | | @Resource
|
| | | private EhCacheCacheManager cacheManager;
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | @Around("execution(public * com.yeshi.fanli.controller.client.*.*(..))")
|
| | | private ExpressionParser parser = new SpelExpressionParser();
|
| | |
|
| | | private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
|
| | |
|
| | | /**
|
| | | * 获取表达的值
|
| | | * |
| | | * @param spELString
|
| | | * @param joinPoint
|
| | | * @return
|
| | | */
|
| | | public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) {
|
| | | MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
| | | String[] paramNames = nameDiscoverer.getParameterNames(methodSignature.getMethod());
|
| | | Expression expression = parser.parseExpression(spELString);
|
| | | EvaluationContext context = new StandardEvaluationContext();
|
| | | Object[] args = joinPoint.getArgs();
|
| | | for (int i = 0; i < args.length; i++) {
|
| | | context.setVariable(paramNames[i], args[i]);
|
| | | }
|
| | | return expression.getValue(context).toString();
|
| | | }
|
| | |
|
| | | @Around("execution(public * com.yeshi.fanli.controller.client.*.*.*(..))")
|
| | | public Object requestSerializable(ProceedingJoinPoint joinPoint) throws IOException {
|
| | | Signature signature = joinPoint.getSignature();
|
| | | MethodSignature methodSignature = (MethodSignature) signature;
|
| | |
| | | try {
|
| | | Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(joinPoint.getSignature().getName(),
|
| | | targetMethod.getParameterTypes());
|
| | | Object[] args = joinPoint.getArgs();
|
| | | PrintWriter out = null;
|
| | | String[] strings = methodSignature.getParameterNames();
|
| | | Map<String, ParamsTypeValue> map = new HashMap<>();
|
| | | Class<?>[] types = methodSignature.getParameterTypes();
|
| | | for (int i = 0; i < strings.length; i++) {
|
| | | map.put(strings[i], new ParamsTypeValue(types[i], args[i]));
|
| | | if (args[i] instanceof PrintWriter) {
|
| | | out = (PrintWriter) args[i];
|
| | | }
|
| | | }
|
| | |
|
| | | if (realMethod.isAnnotationPresent(RequestSerializableByKey.class)) {
|
| | | RequestSerializableByKey rs = realMethod.getAnnotation(RequestSerializableByKey.class);
|
| | | String[] strings = methodSignature.getParameterNames();
|
| | | Class<?>[] types = methodSignature.getParameterTypes();
|
| | | Map<String, ParamsTypeValue> map = new HashMap<>();
|
| | | Object[] args = joinPoint.getArgs();
|
| | | PrintWriter out = null;
|
| | | for (int i = 0; i < strings.length; i++) {
|
| | | map.put(strings[i], new ParamsTypeValue(types[i], args[i]));
|
| | | if (args[i] instanceof PrintWriter) {
|
| | | out = (PrintWriter) args[i];
|
| | | }
|
| | | }
|
| | |
|
| | | String key = rs.key();
|
| | | ParamsTypeValue tv = null;
|
| | | if (key.indexOf(".") > -1) {
|
| | | tv = map.get(key.split("\\.")[0]);
|
| | | } else {
|
| | | tv = map.get(key);
|
| | | }
|
| | | Object value = tv.value;
|
| | | Class<?> type = tv.type;
|
| | | // 暂时只支持2层嵌套
|
| | | if (key.indexOf(".") > -1) {
|
| | | String child = key.split("\\.")[1];
|
| | | cacheKey = generateKeyBySpEL(key, joinPoint);
|
| | |
|
| | | try {// redis做原子性保护
|
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) {
|
| | | cacheKey = joinPoint.getTarget().getClass().getName() + "." + targetMethod.getName() + "-"
|
| | | + cacheKey;
|
| | | cacheKey = "rs-" + StringUtil.Md5(cacheKey);
|
| | | // jiedis原子性做拦截
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | Constant.waitingThreadSet.add(Thread.currentThread().getId());
|
| | | long result = 0;
|
| | | long startTime = System.currentTimeMillis();
|
| | | // 等待响应
|
| | | while (result <= 0) {
|
| | | result = jedis.setnx(cacheKey, "1");
|
| | | if (result <= 0) {
|
| | | try {
|
| | | Thread.sleep(50);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (System.currentTimeMillis() - startTime > 1000 * 60L) {
|
| | | Constant.waitingThreadSet.remove(Thread.currentThread().getId());
|
| | | out.print(JsonUtil.loadFalseResult("连接超时"));
|
| | | return null;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (result > 0) {
|
| | | try {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } finally {
|
| | | jedis.del(cacheKey);
|
| | | Constant.waitingThreadSet.remove(Thread.currentThread().getId());
|
| | | }
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {// 原子性保护出错
|
| | | try {
|
| | | Field f = type.getDeclaredField(child);
|
| | | f.setAccessible(true);
|
| | | Object obj = f.get(value);
|
| | | if (obj != null) {
|
| | | cacheKey = obj.toString();
|
| | | }
|
| | | } catch (NoSuchFieldException e) {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e1) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | } else {
|
| | | if (value != null) {
|
| | | cacheKey = value.toString();
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) {
|
| | | cacheKey = joinPoint.getTarget().getClass().getName() + "." + targetMethod.getName() + "-"
|
| | | + cacheKey;
|
| | | Cache cache = cacheManager.getCache("rsCache");
|
| | | ValueWrapper element = cache.get(cacheKey);
|
| | | if (element != null && element.get() != null) {
|
| | | // 服务器繁忙
|
| | | if (out != null) {
|
| | | out.print(JsonUtil.loadFalseResult(2001, "服务器繁忙"));
|
| | | }
|
| | | return null;
|
| | | } else {
|
| | | cache.put(cacheKey, "1");
|
| | | LogHelper.errorDetailInfo(e1);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | } catch (Throwable e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
|
| | | } finally {
|
| | | if (!StringUtil.isNullOrEmpty(cacheKey)) {
|
| | | Cache cache = cacheManager.getCache("rsCache");
|
| | | cache.put(cacheKey, null);
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 测试代码
|
| | | public void test() {
|
| | |
|
| | | }
|
| | |
|
| | | class ParamsTypeValue {
|
| | | Class<?> type;
|
| | | Object value;
|
| | |
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("test")
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private InviteMaterialService inviteMaterialService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private DynamicInfoDao dynamicInfoDao;
|
| | |
|
| | | |
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | | |
| | |
|
| | | @RequestMapping(value = "testimg")
|
| | | public void testImg(HttpServletRequest request, PrintWriter out) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getJingFenList")
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate);
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @RequestMapping(value = "getWaitingThreadsCount")
|
| | | public void getWaitingThreadsCount(PrintWriter out) {
|
| | | out.print(Constant.waitingThreadSet.size());
|
| | | |
| | | }
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | // 发送短信
|
| | |
|
| | | @RequestSerializableByKey(key = "#phone+'-'+#uid+'-'+#type")
|
| | | @RequestMapping(value = "sendSMS", method = RequestMethod.POST)
|
| | | public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, PrintWriter out) {
|
| | | sendMSM(acceptData, phone, uid, type, StringUtil.Md5(phone + "-" + "-" + uid + "-" + type), out);
|
| | | }
|
| | |
|
| | | @RequestSerializableByKey(key = "key")
|
| | | public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, String key, PrintWriter out) {
|
| | | try {
|
| | | if (phone.contains("**") && uid != null && uid > 0) {
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 1.5.3 登录发送短信
|
| | | * 1.5.3 登录发送短信
|
| | | * |
| | | * @param acceptData
|
| | | * @param phone
|
| | | * @param uid
|
| | |
| | | return;
|
| | | }
|
| | | phone = phone.replaceAll(" ", "");
|
| | | |
| | | sendMSNnew(phone,slideVerify, 1, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
|
| | |
|
| | | sendMSNnew(phone, slideVerify, 1, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 1.5.3 绑定发送短信
|
| | | * |
| | | * @param acceptData
|
| | | * @param phone
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "#acceptData.device+'-'+#phone")
|
| | | @RequestMapping(value = "sendMSMBind", method = RequestMethod.POST)
|
| | | public void sendMSMBind(AcceptData acceptData, String phone, boolean slideVerify, PrintWriter out) {
|
| | | if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
|
| | |
| | | return;
|
| | | }
|
| | | phone = phone.replaceAll(" ", "");
|
| | | |
| | |
|
| | | // 判断手机号码是否被封禁
|
| | | // ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService
|
| | | // .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
|
| | | // if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective()) {
|
| | | // out.print(JsonUtil.loadFalseResult(9001,"该电话号码被占用"));
|
| | | // return;
|
| | | // }
|
| | | // |
| | | // ForbiddenUserIdentifyCode identifyCode1 =
|
| | | // forbiddenUserIdentifyCodeService
|
| | | // .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone,
|
| | | // phone);
|
| | | // if (identifyCode1 != null && identifyCode1.getEffective() != null &&
|
| | | // identifyCode1.getEffective()) {
|
| | | // out.print(JsonUtil.loadFalseResult(9001,"该电话号码被占用"));
|
| | | // return;
|
| | | // }
|
| | | //
|
| | | // 判断手机号码是否被封禁
|
| | | UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone);
|
| | | if (phoneUser != null) {
|
| | | out.print(JsonUtil.loadFalseResult(9001,"该电话号码被占用"));
|
| | | out.print(JsonUtil.loadFalseResult(9001, "该电话号码被占用"));
|
| | | return;
|
| | | }
|
| | | |
| | | sendMSNnew(phone,slideVerify, 2, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
|
| | |
|
| | | sendMSNnew(phone, slideVerify, 2, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
|
| | | }
|
| | | |
| | | |
| | | @RequestSerializableByKey(key = "key")
|
| | |
|
| | | public void sendMSNnew(String phone, boolean slideVerify, int type, String key, PrintWriter out) {
|
| | | try {
|
| | | int count = 0;
|
| | |
| | | // 绑定验证码
|
| | | cachekey = "sendMSNBindCount" + phone;
|
| | | }
|
| | | |
| | |
|
| | | if (cachekey == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1,"发送失败"));
|
| | | out.print(JsonUtil.loadFalseResult(1, "发送失败"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | String cacheValue = redisManager.getCommonString(cachekey);
|
| | | if (!StringUtil.isNullOrEmpty(cacheValue)) {
|
| | | count = Integer.parseInt(cacheValue);
|
| | | // 限制3次
|
| | | if (count >= 3) {
|
| | | out.print(JsonUtil.loadFalseResult(3,"验证码次数超限,请稍后再试"));
|
| | | out.print(JsonUtil.loadFalseResult(3, "验证码次数超限,请稍后再试"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (count == 2 && !slideVerify) {
|
| | | out.print(JsonUtil.loadFalseResult(2,"需要滑动验证"));
|
| | | out.print(JsonUtil.loadFalseResult(2, "需要滑动验证"));
|
| | | return;
|
| | | } |
| | | }
|
| | | // 缓存一个小时
|
| | | count ++;
|
| | | count++;
|
| | | redisManager.cacheCommonString(cachekey, count + "", 60 * 60);
|
| | | |
| | | |
| | |
|
| | | if (type == 1) {
|
| | | // 登录验证码
|
| | | smsService.sendLoginVCode(phone, 4);
|
| | |
| | | // 绑定验证码
|
| | | smsService.sendBindVCode(phone, 4);
|
| | | }
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult("发送成功"));
|
| | | |
| | |
|
| | | } catch (SMSException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | |
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "uid")
|
| | | @RequestSerializableByKey(key = "#uid")
|
| | | @RequestMapping(value = "extractmoneynew", method = RequestMethod.POST)
|
| | | public void extractMoneyNew(AcceptData acceptData, long uid, BigDecimal money, String vcode,
|
| | | HttpServletRequest request, int type, PrintWriter out) {
|
| | |
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key="#acceptData.device")
|
| | | @RequestMapping(value = "getHomeMsgListNew", method = RequestMethod.POST)
|
| | | public void getHomeMsgListNew(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid != null && uid == 0)
|
| | |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsService daTaoKeGoodsService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SpecialService specialService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private JDGoodsService jdGoodsService;
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 京东专题分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | |
| | | root.put("jdLink", configService.get("jingdong_h5_link"));
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | | |
| | | |
| | |
|
| | |
|
| | | /**
|
| | | * 京东专题 + 商品列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | |
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | | root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
|
| | | |
| | |
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("jingdong_special_index");
|
| | | if (listSpecial == null) {
|
| | | listSpecial = new ArrayList<Special>();
|
| | | }
|
| | | root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | List<JDGoods> goodsList = jdGoodsService.specialSearch(page, cid);
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate);
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | root.put("list", array);
|
| | | root.put("count", 1000);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | |
| | | */ |
| | | Long countInviteOrderCountByUidAndSettleTime(@Param("uid") Long uid, @Param("state") int state, |
| | | @Param("minDate") Date minDate, @Param("maxDate") Date maxDate); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据用户ID,订单状态和结算时间统计分享赚的订单数量 |
| | | * |
| | |
| | | * @param stateList |
| | | * @return |
| | | */ |
| | | BigDecimal computeMoneyByUidAndState(@Param("uid") Long uid,@Param("stateList") List<Integer> stateList); |
| | | |
| | | BigDecimal computeMoneyByUidAndState(@Param("uid") Long uid, @Param("stateList") List<Integer> stateList); |
| | | |
| | | /** |
| | | * 最近30天内产生过分享订单的用户 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Long> getUidByNear30DayShareSucceed(); |
| | | |
| | | |
| | | /** |
| | | * 根据父用户ID,状态,类型查询 |
| | | * |
| | | * @param uid |
| | | * @param typeList |
| | | * @param stateList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listByParentUidAndTypeAndState(@Param("uid") Long uid, @Param("typeList") List<Integer> typeList, |
| | | @Param("stateList") List<Integer> stateList, @Param("start") long start, @Param("count") int count); |
| | | |
| | | /** |
| | | * 根据父用户ID,状态,类型查询数量 |
| | | * |
| | | * @param uid |
| | | * @param typeList |
| | | * @param stateList |
| | | * @return |
| | | */ |
| | | long countByParentUidAndTypeAndState(@Param("uid") Long uid, @Param("typeList") List<Integer> typeList, |
| | | @Param("stateList") List<Integer> stateList); |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dto.jd;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | public class JDPingouInfo {
|
| | | public class JDPingouInfo implements Serializable{
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | private BigDecimal pingouPrice;
|
| | | private Long pingouTmCount;
|
| | | private String pingouUrl;
|
New file |
| | |
| | | package com.yeshi.fanli.dto.taobao;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | |
|
| | | public class TaoBaoOrderResultDTO {
|
| | | private boolean hasNext;
|
| | | private boolean hasPre;
|
| | | private String positionIndex;
|
| | | private List<TaoBaoOrder> orderList;
|
| | |
|
| | | public TaoBaoOrderResultDTO(boolean hasNext, boolean hasPre, String positionIndex, List<TaoBaoOrder> orderList) {
|
| | | this.hasNext = hasNext;
|
| | | this.hasPre = hasPre;
|
| | | this.positionIndex = positionIndex;
|
| | | this.orderList = orderList;
|
| | | }
|
| | |
|
| | | public boolean isHasNext() {
|
| | | return hasNext;
|
| | | }
|
| | |
|
| | | public void setHasNext(boolean hasNext) {
|
| | | this.hasNext = hasNext;
|
| | | }
|
| | |
|
| | | public boolean isHasPre() {
|
| | | return hasPre;
|
| | | }
|
| | |
|
| | | public void setHasPre(boolean hasPre) {
|
| | | this.hasPre = hasPre;
|
| | | }
|
| | |
|
| | | public String getPositionIndex() {
|
| | | return positionIndex;
|
| | | }
|
| | |
|
| | | public void setPositionIndex(String positionIndex) {
|
| | | this.positionIndex = positionIndex;
|
| | | }
|
| | |
|
| | | public List<TaoBaoOrder> getOrderList() {
|
| | | return orderList;
|
| | | }
|
| | |
|
| | | public void setOrderList(List<TaoBaoOrder> orderList) {
|
| | | this.orderList = orderList;
|
| | | }
|
| | | }
|
| | |
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | long endTime = System.currentTimeMillis() - 1000 * 60;
|
| | | ;
|
| | | updateOrder(endTime - 1000 * 60 * 20L, endTime);
|
| | | }
|
| | |
|
| | |
| | | public void doJob2() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | doTaoBaoWeiQuan();
|
| | |
|
| | | doTaoBaoWeiQuanOrder(2);
|
| | | orderProcessService.fanli();
|
| | | }
|
| | |
|
| | |
| | | orderProcessService.fanliInvaiteAndShare();
|
| | | }
|
| | |
|
| | | // 维权订单处理-处理最近60天的
|
| | | // 30分钟一次
|
| | | @Scheduled(cron = "0 0/30 * * * ? ")
|
| | | public void doTaoBaoWeiQuan() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | // 新版维权订单处理
|
| | | for (int i = 0; i < 60; i++) {
|
| | | private void doTaoBaoWeiQuanOrder(int day) {
|
| | |
|
| | | for (int i = 0; i < day; i++) {
|
| | | List<TaoBaoWeiQuanOrder> orderList = new ArrayList<>();
|
| | |
|
| | | // 按照维权发起时间查询
|
| | | WeiQuanOrderResult result = TaoKeOrderApiUtil
|
| | | .getTaoBaoSpecialWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, false);
|
| | | "yyyy-MM-dd")), 1, 1, false);
|
| | | orderList.addAll(result.orderList);
|
| | | // 第三方
|
| | | result = TaoKeOrderApiUtil.getTaoBaoSpecialWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, 1, true);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | result = TaoKeOrderApiUtil.getTaoBaoRelationWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, 1, false);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | // 第三方
|
| | | result = TaoKeOrderApiUtil.getTaoBaoRelationWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, 1, true);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | /**
|
| | | * 按照维权完成时间查询
|
| | | */
|
| | |
|
| | | result = TaoKeOrderApiUtil.getTaoBaoSpecialWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, true);
|
| | | "yyyy-MM-dd")), 3, 1, false);
|
| | | orderList.addAll(result.orderList);
|
| | | // 第三方
|
| | | result = TaoKeOrderApiUtil.getTaoBaoSpecialWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 3, 1, true);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | result = TaoKeOrderApiUtil.getTaoBaoRelationWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, false);
|
| | | "yyyy-MM-dd")), 3, 1, false);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | // 第三方
|
| | | result = TaoKeOrderApiUtil.getTaoBaoRelationWeiQuanOrderList(new Date(TimeUtil.convertToTimeTemp(
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * i, "yyyy-MM-dd"),
|
| | | "yyyy-MM-dd")), 1, true);
|
| | | "yyyy-MM-dd")), 3, 1, true);
|
| | | orderList.addAll(result.orderList);
|
| | |
|
| | | for (TaoBaoWeiQuanOrder order : orderList)
|
| | |
| | | // 处理维权订单
|
| | | orderProcessService.weiQuanOrder(orderList);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | // 维权订单处理-处理最近60天的
|
| | | // 30分钟一次
|
| | | @Scheduled(cron = "0 0/30 * * * ? ")
|
| | | public void doTaoBaoWeiQuan() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | doTaoBaoWeiQuanOrder(5);
|
| | | }
|
| | |
|
| | | // 每6个小时执行一次
|
| | |
| | | h.`hb_pre_get_time` IS NOT |
| | | NULL AND h.`hb_pre_get_time` |
| | | <![CDATA[ <]]> |
| | | NOW() order by hb_pre_get_time desc limit #{count} |
| | | NOW() order by hb_pre_get_time desc limit #{count} |
| | | </select> |
| | | |
| | | <!-- 获取用户奖金列表 --> |
| | |
| | | co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate} |
| | | and #{maxDate}>co.`co_settle_time`; |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="countShareOrderCountByUidAndSettleTime" resultType="java.lang.Long"> |
| | | SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN |
| | | yeshi_ec_hongbao_order ho ON h.`hb_id`=ho.`ho_hongbao_id` LEFT JOIN |
| | |
| | | |
| | | <select id="getUidByNear30DayShareSucceed" resultType="java.lang.Long"> |
| | | SELECT v2.`hb_uid` FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_type` = 20 AND v2.`hb_state`<![CDATA[<>]]> 4 |
| | | AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <![CDATA[<=]]>DATE(v2.`hb_create_time`) |
| | | WHERE v2.`hb_type` = 20 |
| | | AND v2.`hb_state`<![CDATA[<>]]> |
| | | 4 |
| | | AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <![CDATA[<=]]>DATE(v2.`hb_create_time`) |
| | | GROUP BY v2.`hb_uid` |
| | | ORDER BY v2.`hb_create_time`; |
| | | </select> |
| | | |
| | | |
| | | <select id="listByParentUidAndTypeAndState" resultMap="BaseResultMap"> |
| | | SELECT v.* FROM yeshi_ec_hongbao_v2 v LEFT JOIN yeshi_ec_hongbao_v2 p |
| | | ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid} |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" item="type" open=" and (" |
| | | separator=" or " close=")"> |
| | | v.hb_type=#{type} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" item="state" open=" and (" |
| | | separator=" or " close=")"> |
| | | v.hb_state=#{state} |
| | | </foreach> |
| | | </if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countByParentUidAndTypeAndState" resultType="java.lang.Long"> |
| | | SELECT count(v.hb_id) FROM yeshi_ec_hongbao_v2 v LEFT JOIN |
| | | yeshi_ec_hongbao_v2 p |
| | | ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid} |
| | | <if test="typeList!=null"> |
| | | <foreach collection="typeList" item="type" open=" and (" |
| | | separator=" or " close=")"> |
| | | v.hb_type=#{type} |
| | | </foreach> |
| | | </if> |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" item="state" open=" and (" |
| | | separator=" or " close=")"> |
| | | v.hb_state=#{state} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT} |
| | |
| | | <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 ">AND co.co_order_no = ${key}</if> |
| | | <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | |
| | | <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 ">AND co.co_order_no = ${key}</if> |
| | | <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | |
| | | <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 ">AND co.co_order_no = ${key}</if> |
| | | <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | |
| | | <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 ">AND co.co_order_no = ${key}</if> |
| | | <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | |
| | |
|
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | public class JDCommonTemplateContentServiceImpl implements JDCommonTemplateContentService {
|
| | |
|
| | | private Map<String, Long> countMap = new HashMap<String, Long>();
|
| | | |
| | |
|
| | | @Cacheable(value = "jdCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private JDSearchResult get9K9Content(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {10, 17};
|
| | | return getJingFenGoods(page, pageSize, "9k9-", arrayId);
|
| | | int[] arrayId = { 10, 17 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "9k9-", arrayId);
|
| | |
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult filterGoods(JDSearchResult result) {
|
| | | List<Long> skuIds = new ArrayList<>();
|
| | | if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
|
| | | for (JDGoods goods : result.getGoodsList()) {
|
| | | skuIds.add(goods.getSkuId());
|
| | | }
|
| | | List<JDGoods> goodsList = JDApiUtil.listGoodsDetail(skuIds);
|
| | | result.setGoodsList(goodsList);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | private JDSearchResult getJDPeiSongContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {15, 18};
|
| | | return getJingFenGoods(page, pageSize, "peisong-", arrayId);
|
| | | int[] arrayId = { 15, 18 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "peisong-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getJiaDianContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {5, 2};
|
| | | return getJingFenGoods(page, pageSize, "jiadian-", arrayId);
|
| | | int[] arrayId = { 5, 2 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "jiadian-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getBaiHuoContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {6, 3};
|
| | | return getJingFenGoods(page, pageSize, "baihuo-", arrayId);
|
| | | int[] arrayId = { 6, 3 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "baihuo-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getJuJiaContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {7, 4};
|
| | | return getJingFenGoods(page, pageSize, "jujia-", arrayId);
|
| | | int[] arrayId = { 7, 4 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "jujia-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 9快9包邮
|
| | | *
|
| | |
| | | if (count != null) {
|
| | | addCount += count;
|
| | | }
|
| | | |
| | |
|
| | | if (count != null && totalCount > addCount) {
|
| | | pageTemp = (int)(addCount / Constant.PAGE_SIZE);
|
| | | pageTemp = (int) (addCount / Constant.PAGE_SIZE);
|
| | | continue; // 当前分类商品不足
|
| | | } else {
|
| | | page = page - pageTemp; |
| | | page = page - pageTemp;
|
| | | categoryId = arrayId[i];
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (categoryId == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | JDSearchResult result = JDApiUtil.getJingFenGoods(page, categoryId);
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | | }
|
| | | |
| | | long mcount = (count/Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | |
|
| | | long mcount = (count / Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | | if (mcount == 0) {
|
| | | mcount = 20;
|
| | | }
|
| | |
| | |
|
| | | if (finalList != null && finalList.size() > 0) {
|
| | | Collections.shuffle(finalList);
|
| | | if (finalList.size() >= 3)
|
| | | finalList = finalList.subList(0, 3);
|
| | | if (finalList.size() >= 10)
|
| | | finalList = finalList.subList(0, 10);
|
| | | list = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : finalList) {
|
| | | list.add(map.get(goods.getAuctionId()));
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTLJShareRate() {
|
| | | public BigDecimal getTLJShareRate(long time) {
|
| | | String key = "tlj_share_proportion";
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | |
| | | public List<Long> getUidByNear30DayShareSucceed() {
|
| | | return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void invalidInviteHongBaoByParentUid(Long parentUid, String beiZhu) {
|
| | | List<Integer> typeList = new ArrayList<>();
|
| | | typeList.add(HongBaoV2.TYPE_YIJI);
|
| | | typeList.add(HongBaoV2.TYPE_ERJI);
|
| | | typeList.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | typeList.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | List<Integer> stateList = new ArrayList<>();
|
| | | stateList.add(HongBaoV2.STATE_KELINGQU);
|
| | | stateList.add(HongBaoV2.STATE_BUKELINGQU);
|
| | | long count = hongBaoV2Mapper.countByParentUidAndTypeAndState(parentUid, typeList, stateList);
|
| | | int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
|
| | | for (int i = 1; i <= page; i++) {
|
| | | List<HongBaoV2> list = hongBaoV2Mapper.listByParentUidAndTypeAndState(parentUid, typeList, stateList,
|
| | | 0, 100);
|
| | | if (list != null)
|
| | | for (HongBaoV2 v2 : list) {
|
| | | HongBaoV2 update = new HongBaoV2(v2.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu(beiZhu);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (result == null) {
|
| | | return null;
|
| | | } else {
|
| | | return result.getGoodsList();
|
| | | return filterJDGoods(result.getGoodsList());
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | list.addAll(listGoods);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | return filterJDGoods(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 过滤商品
|
| | | * |
| | | * @param goodsList
|
| | | * @return
|
| | | */
|
| | | private List<JDGoods> filterJDGoods(List<JDGoods> goodsList) {
|
| | | List<Long> skuIds = new ArrayList<>();
|
| | | for (JDGoods goods : goodsList) {
|
| | | skuIds.add(goods.getSkuId());
|
| | | }
|
| | | List<JDGoods> newGoodsList = JDApiUtil.listGoodsDetail(skuIds);
|
| | | if (newGoodsList != null && newGoodsList.size() > 0)
|
| | | return newGoodsList;
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | private List<JDGoods> search(int page, int pageSize, String jdcid) {
|
| | |
| | | @Service
|
| | | public class BusinessEmergent110ServiceImpl implements BusinessEmergent110Service {
|
| | |
|
| | | String[] phones = new String[] { "18581318252", "15025351808", "18696787365" };
|
| | | String[] phones = new String[] { "18581318252", "15025351808" };
|
| | |
|
| | | private static Map<String, List<String>> map = new HashMap<>();
|
| | | private static long shareTime = 0L;
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | |
| | |
|
| | | @Override
|
| | | public void fanli() {
|
| | | LogHelper.test("处理返利到账");
|
| | | // 获取主红包
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBaoV2.TYPE_ZIGOU, 1000);
|
| | | //
|
| | |
| | | return;
|
| | | String uidStr = order.getExt1();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr))
|
| | | if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | Long positionId = order.getOrderItemList().get(0).getPositionId();
|
| | | if (positionId == JDApiUtil.POSITION_FANLI)// 返利订单
|
| | |
| | | List<TLJBuyGoods> goodsList = new ArrayList<>();
|
| | | for (TaoBaoUnionConfig appInfo : configList) {
|
| | | List<TLJBuyGoods> list = listByDay(appInfo.getAppKey(), day, 10);
|
| | | if (list != null)
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | // 过滤淘礼金大于10块钱的
|
| | | BigDecimal hongBao = TaoBaoUtil.getGoodsHongBaoMoney(list.get(i).getGoods(),
|
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | if (hongBao.compareTo(new BigDecimal(10)) > 0) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | if (list != null && list.size() > 0)
|
| | | goodsList.addAll(list);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyCanCreateTLJ(Long auctionId,TaoKeAppInfo app) {
|
| | | public boolean verifyCanCreateTLJ(Long auctionId, TaoKeAppInfo app) {
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "淘礼金验证", new BigDecimal("1.00"), 1, new Date(),
|
| | |
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Service
|
| | | public class DaTaoKeGoodsDetailV2ServiceImpl implements DaTaoKeGoodsDetailV2Service {
|
| | |
| | | return finalList;
|
| | | }
|
| | |
|
| | | private boolean canAddToTLJBuyGoods(DaTaoKeDetailV2 v2) {
|
| | | return TaoBaoUtil.canAddToTLJBuyGoods(TaoBaoUtil.convert(v2));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DaTaoKeDetailV2> listPreTLJBuyGoods(int page) {
|
| | | if (page == 1) {
|
| | | List<DaTaoKeDetailV2> listPreGoodsList = new ArrayList<>();
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_HOT, null);
|
| | | List<DaTaoKeDetailV2> goodsList = new ArrayList<>();
|
| | | for (DaTaoKeDetailV2 v2 : result.getGoodsList()) {
|
| | | BigDecimal commision = MoneyBigDecimalUtil
|
| | | .div(MoneyBigDecimalUtil.mul(v2.getActualPrice(), v2.getCommissionRate()), new BigDecimal(100));
|
| | | if (result != null && result.getGoodsList() != null)
|
| | | listPreGoodsList.addAll(result.getGoodsList());
|
| | |
|
| | | if (commision.multiply(new BigDecimal("0.7")).compareTo(new BigDecimal("1.01")) >= 0
|
| | | && v2.getActualPrice().compareTo(new BigDecimal(30)) < 0 && v2.getMonthSales() >= 5000) {
|
| | | result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_REBUY, null);
|
| | | if (result != null && result.getGoodsList() != null)
|
| | | listPreGoodsList.addAll(result.getGoodsList());
|
| | |
|
| | | List<DaTaoKeDetailV2> goodsList = new ArrayList<>();
|
| | | for (DaTaoKeDetailV2 v2 : listPreGoodsList) {
|
| | | if (canAddToTLJBuyGoods(v2)) {
|
| | | Date time = new Date(TimeUtil.convertToTimeTemp(v2.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | |
|
| | | Date targetTime = new Date(TimeUtil
|
| | |
| | | goodsList.add(v2);
|
| | | }
|
| | | }
|
| | |
|
| | | // 去重
|
| | | Map<Long, DaTaoKeDetailV2> goodsMap = new HashMap<>();
|
| | | for (DaTaoKeDetailV2 v2 : goodsList) {
|
| | | goodsMap.put(v2.getGoodsId(), v2);
|
| | | }
|
| | | goodsList.clear();
|
| | | for (Iterator<Long> its = goodsMap.keySet().iterator(); its.hasNext();) {
|
| | | goodsList.add(goodsMap.get(its.next()));
|
| | | }
|
| | | Comparator<DaTaoKeDetailV2> cm = new Comparator<DaTaoKeDetailV2>() {
|
| | |
|
| | | @Override
|
| | | public int compare(DaTaoKeDetailV2 o1, DaTaoKeDetailV2 o2) {
|
| | | return o1.getActualPrice().compareTo(o2.getActualPrice());
|
| | | }
|
| | | };
|
| | | Collections.sort(goodsList, cm);
|
| | | return goodsList;
|
| | | } else
|
| | | return new ArrayList<>();
|
| | |
| | | *
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTLJShareRate();
|
| | | public BigDecimal getTLJShareRate(long time);
|
| | | |
| | | |
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException;
|
| | |
|
| | |
|
| | | /**
|
| | | * 奖金列表(1.4.9之前的版本)
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | BigDecimal getUnRecievedMoneyWithPreGetTime(Long uid, Date minDate, Date maxDate);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 计算资金
|
| | | * |
| | | * @param uid
|
| | | * @param state
|
| | | * @return
|
| | | */
|
| | | BigDecimal computeMoneyByUidAndState(Long uid,int state);
|
| | | BigDecimal computeMoneyByUidAndState(Long uid, int state);
|
| | |
|
| | | /**
|
| | | * 查询子红包
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 最近30天内产生过分享订单的用户
|
| | | * |
| | | * @return
|
| | | */
|
| | | public List<Long> getUidByNear30DayShareSucceed();
|
| | |
|
| | | /**
|
| | | * 让邀请赚失效(根据下级用户ID)
|
| | | * @param parentUid
|
| | | * @param beiZhu
|
| | | */
|
| | | public void invalidInviteHongBaoByParentUid(Long parentUid, String beiZhu);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.tag;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | public class PageEntity {
|
| | | public class PageEntity implements Serializable{
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | private String url; //
|
| | | @Expose
|
| | | private int pageIndex;//
|
| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.Properties;
|
| | | import java.util.Set;
|
| | |
|
| | | import org.yeshi.utils.annotation.MapUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.config.AlipayConfig;
|
| | | import com.yeshi.fanli.entity.config.ConstantConfig;
|
| | |
| | | import com.yeshi.fanli.entity.config.WXGZConfig;
|
| | | import com.yeshi.fanli.entity.config.ZNXConfig;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import org.yeshi.utils.annotation.MapUtil;
|
| | |
|
| | | public class Constant {
|
| | | public static boolean IS_TASK = false;
|
| | |
| | |
|
| | | public static final String WEBPAGE_SIGN_KEY = "@?,223Hbb88lll";
|
| | |
|
| | | // public static final String TAOKE_ANDROID_APPKEY = "24587154";
|
| | | // public static final String TAOKE_IOS_APPKEY = "24838852";
|
| | |
|
| | | // 新人抽奖-最大次数
|
| | | public static final int MAX_COUNT_LOTTERY_NEWBIES = 5;
|
| | |
|
| | | // 线程等待数量
|
| | | public static Set<Long> waitingThreadSet = new HashSet<>();
|
| | |
|
| | | static {
|
| | |
|
| | | if (smsConfig == null) {
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | |
|
| | | public class TaoBaoConstant {
|
| | | // 淘宝第三方授权
|
| | | public static final String TAOBAO_AUTH_APPKEY = "24980167";
|
| | |
| | | public static int RANK_TYPE_TIME = 1;// 实时
|
| | | public static int RANK_TYPE_DAY = 2;// 全天榜
|
| | | public static int RANK_TYPE_HOT = 3;// 热推榜
|
| | | public static int RANK_TYPE_REBUY = 4;// 复购榜
|
| | |
|
| | | /**
|
| | | * 各大榜单
|
| | |
| | | if (cid != null)
|
| | | params.put("cid", cid + "");
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | | String result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-ranking-list", params, new HashMap<>());
|
| | | // 做2次请求
|
| | | String result = null;
|
| | | try {
|
| | | result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-ranking-list", params, new HashMap<>());
|
| | | } catch (Exception e) {
|
| | | result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-ranking-list", params, new HashMap<>());
|
| | | }
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | if (json != null) {
|
| | | JSONArray array = json.optJSONArray("data");
|
| | |
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class JDApiUtil {
|
| | | public static String APP_ID = "1774659094";
|
| | | public static String APP_KEY = "7ba8e06b7d6fde3d6bd5db4b0026ecd7";
|
| | | public static String SECRET_KEY = "fb49bc6ecac5458ba5394fc2969d7c56";
|
| | | public static String APP_ID = "1864778416";
|
| | | public static String APP_KEY = "388f5133d13a5ea290aa5c44f3ebcc00";
|
| | | public static String SECRET_KEY = "e22367fc866746d98b50d47b4c521781";
|
| | | private static String SERVER_URL = "https://router.jd.com/api";
|
| | |
|
| | | public static long POSITION_FANLI = 1834339426L;
|
| | | public static long POSITION_SHARE = 1834289924L;
|
| | | public static long POSITION_COUPON = 1859510742L;
|
| | | public static long POSITION_FANLI = 1869704794L;
|
| | | public static long POSITION_SHARE = 1869542990L;
|
| | | public static long POSITION_COUPON = 1869704796L;
|
| | |
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | | public static int ORDER_TYPE_FINISHTIME = 2;// 完成时间
|
| | | public static int ORDER_TYPE_UPDATETIME = 3;// 更新时间
|
| | |
|
| | |
|
| | |
|
| | | private static String post2(String url, Map<String, String> params) {
|
| | | String baseUrl = url;
|
| | |
| | | return list.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过商品搜索接口批量获取详情
|
| | | * |
| | | * @param skuIds
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> listGoodsDetail(List<Long> skuIds) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setListId(skuIds);
|
| | | JDSearchResult result = queryByKey(filter);
|
| | | return result.getGoodsList();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | | root = JSONObject.fromObject(root.optString("result"));
|
| | | if (root.optInt("code") == 200&&root.optJSONArray("data")!=null) {
|
| | | |
| | | if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
|
| | |
|
| | | String date = root.optJSONArray("data").toString();
|
| | | Type typeToken = new TypeToken<List<JDOrder>>() {
|
| | | }.getType();
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TaoBaoHttpUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | return "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + sellerId;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否可以加入淘礼金的预选商品库
|
| | | * |
| | | * @param v2
|
| | | * @return
|
| | | */
|
| | | public static boolean canAddToTLJBuyGoods(TaoBaoGoodsBrief goods) {
|
| | | BigDecimal tljMoney = getShareGoodsHongBaoInfo(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | // 不能小于1块
|
| | | if (tljMoney.compareTo(new BigDecimal(1)) < 0 || tljMoney.compareTo(new BigDecimal(10)) > 0)
|
| | | return false;
|
| | |
|
| | | // 券后价不能大于150
|
| | | if (getAfterUseCouplePrice(goods).compareTo(new BigDecimal(150)) > 0)
|
| | | return false;
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | String s = channelMap.get("3");
|
| | | System.out.println(s);
|
| | |
| | | return orderList;
|
| | | }
|
| | |
|
| | | public static WeiQuanOrderResult getTaoBaoRelationWeiQuanOrderList(Date startTime, int page, boolean third) {
|
| | | public static WeiQuanOrderResult getTaoBaoRelationWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, page, third, 1);
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 1);
|
| | | }
|
| | |
|
| | | public static WeiQuanOrderResult getTaoBaoSpecialWeiQuanOrderList(Date startTime, int page, boolean third) {
|
| | | public static WeiQuanOrderResult getTaoBaoSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, page, third, 2);
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 2);
|
| | | }
|
| | |
|
| | | private static WeiQuanOrderResult getRelationAndSpecialWeiQuanOrderList(Date startTime, int page, boolean third,
|
| | | int bizType) {
|
| | | private static WeiQuanOrderResult getRelationAndSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third, int bizType) {
|
| | | WeiQuanOrderResult finalResult = new WeiQuanOrderResult();
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> list = new ArrayList<>();
|
| | |
| | | map.put("method", "taobao.tbk.relation.refund");
|
| | |
|
| | | JSONObject option = new JSONObject();
|
| | | option.put("search_type", 2);
|
| | | option.put("search_type", searchType);
|
| | | option.put("refund_type", third ? 2 : 1);
|
| | | option.put("start_time", TimeUtil.getGernalTime(startTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | option.put("page_no", page);
|
| | |
| | | order.setGoodsName(item.optString("tb_auction_title"));
|
| | | BigDecimal fanMoney = new BigDecimal(0);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund3rd_pub"))) {
|
| | | fanMoney= fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund3rd_pub")));
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund3rd_pub"))) {
|
| | | fanMoney= fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund3rd_pub")));
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund_pub"))) {
|
| | | fanMoney= fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund_pub")));
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund_pub"))) {
|
| | | fanMoney= fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund_pub")));
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund_pub")));
|
| | | }
|
| | |
|
| | | if (fanMoney.compareTo(new BigDecimal(0)) == 0)
|
| | |
| | | import org.yeshi.utils.mybatis.MyBatisMapperUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.jd.JDOrderItem;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | |
|
| | | //@Ignore
|
| | | public class MyBatisProduce {
|
| | |
| | |
|
| | | @Test
|
| | | public void test1() {
|
| | | ColumnParseUtil.parseColumn(UserMoneyDetail.class,
|
| | | "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\money\\UserMoneyDetailMapper.xml");
|
| | | ColumnParseUtil.parseColumn(TaoBaoOrder.class,
|
| | | "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\taobao\\TaoBaoOrderMapper.xml");
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Test
|
| | | public void test1() {
|
| | | TaoKeApiUtil.getQuanInfo(574147597194L, "69e82c923a044dcbae7f36c6608f57eb");
|
| | | TaoKeApiUtil.taoKeContent();
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | |
|
| | | public static String post(String url, Map<String, String> map, Map<String, String> headers) {
|
| | | HttpClient client = new HttpClient();
|
| | | // client.getHostConfiguration().setProxy("192.168.1.122", 8888);
|
| | | // client.getHostConfiguration().setProxy("192.168.1.122", 8888);
|
| | | PostMethod pm = new PostMethod(url);// 创建HttpPost对象
|
| | | NameValuePair[] ns = new NameValuePair[map.keySet().size()];
|
| | | Iterator<String> its = map.keySet().iterator();
|