package com.yihu.jw.service; import com.alibaba.fastjson.JSONObject; import com.yihu.jw.dao.ActivityDao; import com.yihu.jw.dao.ActivityRuleDao; import com.yihu.jw.dao.TaskGoodsDao; import com.yihu.jw.entity.health.bank.ActivityDO; import com.yihu.jw.entity.health.bank.ActivityRuleDO; import com.yihu.jw.entity.health.bank.TaskGoodsDO; import com.yihu.jw.restmodel.web.MixEnvelop; import com.yihu.mysql.query.BaseJpaService; import org.apache.catalina.LifecycleState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.transaction.Transactional; import java.util.ArrayList; import java.util.List; /** * Created by wzn54 on 2019/1/4. */ @Service @Transactional public class ActivityRuleService extends BaseJpaService { @Autowired private ActivityRuleDao activityRuleDao; @Autowired private TaskGoodsDao taskGoodsDao; /** * 根据id获取活动id * @param id * @return */ public MixEnvelop selectByActivityId(String id){ MixEnvelop envelop = new MixEnvelop<>(); ActivityRuleDO ruleDO = activityRuleDao.selectByActivityId(id); if (ruleDO.getValue3() != null && ruleDO.getValue3() != ""){ JSONObject object = JSONObject.parseObject(ruleDO.getValue3()); Integer exchangeType = object.getInteger("exchangeType"); List taskGoodsDOS = null; if (exchangeType == 2){ taskGoodsDOS = taskGoodsDao.selectByActivityId(id); } ruleDO.setTaskGoodsDOS(taskGoodsDOS); } envelop.setObj(ruleDO); return envelop; } }