| | |
| | | import com.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper;
|
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
|
| | | import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
|
| | | import com.yeshi.fanli.manager.util.AtomMethodCallInterface;
|
| | | import com.yeshi.fanli.manager.util.AtomMethodCallManager;
|
| | | import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Service
|
| | | public class UserGetIntegralFromOrderRecordServiceImpl implements UserGetIntegralFromOrderRecordService {
|
| | |
|
| | | @Resource
|
| | | private UserGetIntegralFromOrderRecordMapper userGetIntegralFromOrderRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private AtomMethodCallManager atomMethodCallManager;
|
| | |
|
| | | @Override
|
| | | public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType) {
|
| | |
| | | || StringUtil.isNullOrEmpty(record.getOrderNo()) || record.getOrderSourceType() == null)
|
| | | throw new UserGetIntegralFromOrderRecordException(1, "信息不完整");
|
| | |
|
| | | long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(), record.getOrderNo(),
|
| | | record.getOrderSourceType());
|
| | | if (count > 0)
|
| | | throw new UserGetIntegralFromOrderRecordException(2, "记录已存在");
|
| | | String key = String.format("rs-%s",
|
| | | StringUtil.Md5(String.format("UserGetIntegralFromOrderRecord-addRecord-%s-%s-%s-%s", record.getUid(),
|
| | | record.getEventType(), record.getOrderNo(), record.getOrderSourceType())));
|
| | |
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | userGetIntegralFromOrderRecordMapper.insertSelective(record);
|
| | | atomMethodCallManager.excute(key, new AtomMethodCallInterface() {
|
| | |
|
| | | @Override
|
| | | public void excute() {
|
| | | long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(),
|
| | | record.getOrderNo(), record.getOrderSourceType());
|
| | | if (count > 0)
|
| | | return;
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | userGetIntegralFromOrderRecordMapper.insertSelective(record);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|