嗨森逛服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hai-server/hai-service/src/main/java/com/hai/etc/impl/EtcCustMsgServiceImpl.java

106 lines
3.5 KiB

package com.hai.etc.impl;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.EtcService;
import com.hai.dao.EtcCustMsgMapper;
import com.hai.entity.BsMsgExample;
import com.hai.entity.EtcCustMsg;
import com.hai.entity.EtcCustMsgExample;
import com.hai.etc.EtcCustMsgService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("etcCustMsgService")
public class EtcCustMsgServiceImpl implements EtcCustMsgService {
@Resource
private EtcCustMsgMapper etcCustMsgMapper;
@Override
public void insertEtcCust(EtcCustMsg etcCustMsg) {
etcCustMsgMapper.insert(etcCustMsg);
}
@Override
public void updateEtcCust(EtcCustMsg etcCustMsg) throws Exception {
// 提交实名认证
JSONObject jsonObject = EtcService.submitCustInfo(etcCustMsg);
if (jsonObject.getString("errCode").equals("0")) {
etcCustMsg.setCustId(jsonObject.getJSONObject("result").getString("custId"));
etcCustMsg.setCustIdNo(jsonObject.getJSONObject("result").getString("custIdNo"));
etcCustMsg.setStatus(jsonObject.getJSONObject("result").getInteger("realStatus"));
}
etcCustMsg.setExt1(jsonObject.getString("errMsg"));
etcCustMsgMapper.updateByPrimaryKey(etcCustMsg);
}
@Override
public void editEtcCust(EtcCustMsg etcCustMsg) throws Exception {
etcCustMsgMapper.updateByPrimaryKey(etcCustMsg);
}
@Override
public List<EtcCustMsg> getEtcCustList(Map<String, Object> map) {
EtcCustMsgExample example = new EtcCustMsgExample();
EtcCustMsgExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map , "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId"));
}
if (MapUtils.getString(map , "custName") != null) {
criteria.andCustNameEqualTo(MapUtils.getString(map , "custName"));
}
if (MapUtils.getString(map , "phone") != null) {
criteria.andPhoneEqualTo(MapUtils.getString(map , "phone"));
}
example.setOrderByClause("create_time desc");
return etcCustMsgMapper.selectByExample(example);
}
@Override
public EtcCustMsg findEtcCustByMap(Map<String, Object> map) {
EtcCustMsgExample example = new EtcCustMsgExample();
EtcCustMsgExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map , "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId"));
}
if (MapUtils.getString(map , "custName") != null) {
criteria.andCustNameEqualTo(MapUtils.getString(map , "custName"));
}
if (MapUtils.getString(map , "phone") != null) {
criteria.andPhoneEqualTo(MapUtils.getString(map , "phone"));
}
if (MapUtils.getInteger(map , "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map , "status"));
}
if (MapUtils.getString(map , "custIdNo") != null) {
criteria.andCustIdNoEqualTo(MapUtils.getString(map , "custIdNo"));
}
List<EtcCustMsg> list = etcCustMsgMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public EtcCustMsg findEtcCustById(Long id) {
return etcCustMsgMapper.selectByPrimaryKey(id);
}
}