数据同步
parent
1e44f55bc8
commit
60317b725d
@ -0,0 +1,45 @@
|
|||||||
|
package com.nmgs.controller;
|
||||||
|
|
||||||
|
import com.nmgs.config.ResultData;
|
||||||
|
import com.nmgs.service.UserTableService;
|
||||||
|
import com.nmgs.service.impl.IntegralRebatSolveServiceImpl;
|
||||||
|
import com.nmgs.util.LogUtil;
|
||||||
|
import com.nmgs.util.PubTools;
|
||||||
|
import com.nmgs.util.redisConfigUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("solveIntegral")
|
||||||
|
@Api(tags = "用户积分异常数据处理")
|
||||||
|
public class SolveIntegralController {
|
||||||
|
|
||||||
|
public IntegralRebatSolveServiceImpl integralRebatSolveServiceImpl;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserTableService(IntegralRebatSolveServiceImpl userTableServiceT) {
|
||||||
|
this.integralRebatSolveServiceImpl = userTableServiceT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "startSolve",
|
||||||
|
method = {RequestMethod.POST}
|
||||||
|
)
|
||||||
|
@ApiOperation(value = "积分处理", httpMethod = "POST")
|
||||||
|
public ResultData<String> startSolve(@RequestParam("userId") String userId, @RequestParam("startTime") String startTime) {
|
||||||
|
LogUtil.WriteLog_Info("用户积分处理开始======={userId:" + userId + ",startTime:" + startTime + "}", "SolveIntegralController");
|
||||||
|
int i1 = integralRebatSolveServiceImpl.solveIntegralRebat(userId, startTime);
|
||||||
|
if (i1 < 0) {
|
||||||
|
return ResultData.fail("人员积分处理失败");
|
||||||
|
}
|
||||||
|
return ResultData.success(1, "积分处理成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,166 @@
|
|||||||
|
package com.nmgs.service.impl;
|
||||||
|
|
||||||
|
import com.nmgs.mappercommon.Mapper;
|
||||||
|
import com.nmgs.mapperset.mysqlmapper.IntegrationListMyMapper;
|
||||||
|
import com.nmgs.mapperset.mysqlmapper.UserTableMysqlMapper;
|
||||||
|
import com.nmgs.mapperset.oraclemapper.IntegrationListMapper;
|
||||||
|
import com.nmgs.mapperset.oraclemapper.UserTableMapper;
|
||||||
|
import com.nmgs.util.PropertiesUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分核销处理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class IntegralRebatSolveServiceImpl {
|
||||||
|
@Autowired
|
||||||
|
public Mapper imapper;
|
||||||
|
|
||||||
|
|
||||||
|
public UserTableMapper userTableMapper;
|
||||||
|
|
||||||
|
public UserTableMysqlMapper userTableMysqlMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserTableMapper(UserTableMapper userTableMapper) {
|
||||||
|
this.userTableMapper = userTableMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserTableMysqlMapper(UserTableMysqlMapper userTableMysqlMapper) {
|
||||||
|
this.userTableMysqlMapper = userTableMysqlMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegrationListMapper integrationListMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setIntegrationListMapper(IntegrationListMapper integrationListMapper) {
|
||||||
|
this.integrationListMapper = integrationListMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegrationListMyMapper integrationListMyMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setIntegrationListMyMapper(IntegrationListMyMapper integrationListMyMapper) {
|
||||||
|
this.integrationListMyMapper = integrationListMyMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(value = "jtatransactionManager", timeout = 100)
|
||||||
|
public int solveIntegralRebat(String userIdParam, String startTime) {
|
||||||
|
int ret = -1;
|
||||||
|
String sqlUserId = "select distinct USERID from integration_list_table " +
|
||||||
|
"where PAYTIME >=to_date('" + startTime + "','yyyy-mm-dd HH24:mi:ss') AND userID='" + userIdParam + "' " +
|
||||||
|
"and PAYTYPE in('FP','FG','FC','FS','TK','FCA') ";
|
||||||
|
List selectforlist = this.imapper.selectforlist(sqlUserId);
|
||||||
|
System.out.println("总次数===" + selectforlist.size());
|
||||||
|
for (int i = 0; i < selectforlist.size(); i++) {
|
||||||
|
Map<String, Object> userIdO = (Map<String, Object>) selectforlist.get(i);
|
||||||
|
String userId = userIdO.get("USERID").toString();
|
||||||
|
//人员截止到2025-07-21 17:15:00的积分流水中最新数据情况,查询出来 最新的积分数据当成初始数据
|
||||||
|
|
||||||
|
String sql = "select LASTINTEGRATION,PAYINTEGRATION,RESTINTEGRATION,OGENABLEINTEGRATION,CPENABLEINTEGRATION,PAYTYPE from integration_list_table where ID =(select max(ID) from integration_list_table where USERID='" + userId + "' AND PAYTIME < to_date('" + startTime + "','yyyy-mm-dd HH24:mi:ss')) ";
|
||||||
|
List selectforlist1 = this.imapper.selectforlist(sql);
|
||||||
|
if (!selectforlist1.isEmpty()) {
|
||||||
|
Map<String, Object> o = (Map<String, Object>) selectforlist1.get(0);
|
||||||
|
BigDecimal LASTINTEGRATION = (BigDecimal) o.get("LASTINTEGRATION");//上次总积分
|
||||||
|
BigDecimal RESTINTEGRATION = (BigDecimal) o.get("RESTINTEGRATION");//剩余积分
|
||||||
|
BigDecimal OGENABLEINTEGRATION = (BigDecimal) o.get("OGENABLEINTEGRATION");//加油加气可用积分
|
||||||
|
BigDecimal CPENABLEINTEGRATION = (BigDecimal) o.get("CPENABLEINTEGRATION");//商超可用积分
|
||||||
|
//用户需要处理的数据
|
||||||
|
String sql1 = "select ID,LASTINTEGRATION,PAYINTEGRATION,RESTINTEGRATION,OGENABLEINTEGRATION,CPENABLEINTEGRATION,PAYTYPE from integration_list_table where USERID='" + userId + "' AND PAYTIME >=to_date('" + startTime + "','yyyy-mm-dd HH24:mi:ss') order by PAYTIME asc";
|
||||||
|
List selectforlist2 = this.imapper.selectforlist(sql1);
|
||||||
|
//处理逻辑
|
||||||
|
for (int k = 0; k < selectforlist2.size(); k++) {
|
||||||
|
Map<String, Object> o1 = (Map<String, Object>) selectforlist2.get(k);
|
||||||
|
String PAYTYPE = (String) o1.get("PAYTYPE");
|
||||||
|
String dataId = ((BigDecimal) o1.get("ID")).toString();
|
||||||
|
BigDecimal PAYINTEGRATION2 = (BigDecimal) o1.get("PAYINTEGRATION");
|
||||||
|
boolean updateCan = false;
|
||||||
|
if ("FC".equals(PAYTYPE) || "FS".equals(PAYTYPE) || "FCA".equals(PAYTYPE)) {//商超及餐饮预约
|
||||||
|
updateCan = true;
|
||||||
|
LASTINTEGRATION = RESTINTEGRATION;
|
||||||
|
RESTINTEGRATION = RESTINTEGRATION.subtract(PAYINTEGRATION2);
|
||||||
|
CPENABLEINTEGRATION = CPENABLEINTEGRATION.subtract(PAYINTEGRATION2);
|
||||||
|
|
||||||
|
} else if ("FP".equals(PAYTYPE) || "FG".equals(PAYTYPE)) {//加油加气
|
||||||
|
updateCan = true;
|
||||||
|
LASTINTEGRATION = RESTINTEGRATION;
|
||||||
|
RESTINTEGRATION = RESTINTEGRATION.subtract(PAYINTEGRATION2);
|
||||||
|
OGENABLEINTEGRATION = OGENABLEINTEGRATION.subtract(PAYINTEGRATION2);
|
||||||
|
} else if ("AM".equals(PAYTYPE)) {//里程积分
|
||||||
|
updateCan = true;
|
||||||
|
LASTINTEGRATION = RESTINTEGRATION;
|
||||||
|
RESTINTEGRATION = RESTINTEGRATION.add(PAYINTEGRATION2);
|
||||||
|
OGENABLEINTEGRATION = OGENABLEINTEGRATION.add(PAYINTEGRATION2.multiply(new BigDecimal("0.6")));
|
||||||
|
CPENABLEINTEGRATION = CPENABLEINTEGRATION.add(PAYINTEGRATION2.multiply(new BigDecimal("0.4")));
|
||||||
|
} else if ("GREENBAK".equals(PAYTYPE)) {//绿通核减
|
||||||
|
updateCan = true;
|
||||||
|
LASTINTEGRATION = RESTINTEGRATION;
|
||||||
|
RESTINTEGRATION = RESTINTEGRATION.add(PAYINTEGRATION2);
|
||||||
|
OGENABLEINTEGRATION = OGENABLEINTEGRATION.add(PAYINTEGRATION2.multiply(new BigDecimal("0.6")));
|
||||||
|
CPENABLEINTEGRATION = CPENABLEINTEGRATION.add(PAYINTEGRATION2.multiply(new BigDecimal("0.4")));
|
||||||
|
} else if ("TK".equals(PAYTYPE)) {//退款
|
||||||
|
updateCan = true;
|
||||||
|
LASTINTEGRATION = RESTINTEGRATION;
|
||||||
|
RESTINTEGRATION = RESTINTEGRATION.add(PAYINTEGRATION2);
|
||||||
|
List selectforlist3 = this.imapper.selectforlist("select ilt.ID,LASTINTEGRATION,ilt.PAYINTEGRATION,ilt.RESTINTEGRATION,ilt.OGENABLEINTEGRATION,ilt.CPENABLEINTEGRATION,ilt.PAYTYPE from integration_list_table ilt,CAFTER_TABLE ct where ilt.ID =ct.INTEGRATIONLISTID AND ct.INTEGRALROLLBACK='" + dataId + "'");
|
||||||
|
if (!selectforlist3.isEmpty()) {
|
||||||
|
Map<String, Object> tk1 = (Map<String, Object>) selectforlist3.get(0);
|
||||||
|
String PAYTYPE2 = (String) tk1.get("PAYTYPE");
|
||||||
|
if ("FC".equals(PAYTYPE2) || "FS".equals(PAYTYPE2)) {//商超
|
||||||
|
CPENABLEINTEGRATION = CPENABLEINTEGRATION.add(PAYINTEGRATION2);
|
||||||
|
} else if ("FP".equals(PAYTYPE2) || "FG".equals(PAYTYPE2)) {//加油加气
|
||||||
|
OGENABLEINTEGRATION = OGENABLEINTEGRATION.add(PAYINTEGRATION2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (updateCan) {
|
||||||
|
/* this.imapper.update("update integration_list_table set LASTINTEGRATION='" + LASTINTEGRATION + "'" +
|
||||||
|
",RESTINTEGRATION='" + RESTINTEGRATION + "' " +
|
||||||
|
",OGENABLEINTEGRATION='" + OGENABLEINTEGRATION + "' " +
|
||||||
|
",CPENABLEINTEGRATION='" + CPENABLEINTEGRATION + "' " +
|
||||||
|
" where ID='" + dataId + "'");*/
|
||||||
|
|
||||||
|
Map<String, Object> listParams = new HashMap<>();
|
||||||
|
listParams.put("lastintegration", LASTINTEGRATION);
|
||||||
|
listParams.put("restintegration", RESTINTEGRATION);
|
||||||
|
listParams.put("ogenableintegration", OGENABLEINTEGRATION);
|
||||||
|
listParams.put("cpenableintegration", CPENABLEINTEGRATION);
|
||||||
|
listParams.put("dataId", dataId);
|
||||||
|
ret = this.integrationListMapper.updateIntegralList(listParams);
|
||||||
|
if ("Y".equals(PropertiesUtil.getValue("BAKEnabled"))) {
|
||||||
|
String bakDBType = PropertiesUtil.getValue("BakDBType");
|
||||||
|
listParams.put("DBTYPEBAK", bakDBType);
|
||||||
|
ret = this.integrationListMyMapper.updateIntegralList(listParams);
|
||||||
|
}
|
||||||
|
updateCan = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* this.imapper.update("update WEIXN_USER_TABLE set ENABLEINTEGRATION='" + RESTINTEGRATION + "'" +
|
||||||
|
",OGENABLEINTEGRATION='" + OGENABLEINTEGRATION + "' " +
|
||||||
|
",CPENABLEINTEGRATION='" + CPENABLEINTEGRATION + "' " +
|
||||||
|
" where ID='" + userId + "'");*/
|
||||||
|
Map<String, Object> userParams = new HashMap<>();
|
||||||
|
userParams.put("enabledTICp", CPENABLEINTEGRATION);
|
||||||
|
userParams.put("enabledTIOG", OGENABLEINTEGRATION);
|
||||||
|
userParams.put("enabledTI", RESTINTEGRATION);
|
||||||
|
userParams.put("userId", userId);
|
||||||
|
ret = this.userTableMapper.updateUserByUserId(userParams);
|
||||||
|
if ("Y".equals(PropertiesUtil.getValue("BAKEnabled"))) {
|
||||||
|
String bakDBType = PropertiesUtil.getValue("BakDBType");
|
||||||
|
userParams.put("DBTYPEBAK", bakDBType);
|
||||||
|
ret = this.userTableMysqlMapper.updateUserByUserId(userParams);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue