| @@ -62,6 +62,7 @@ public class BaseController { | |||
| /** | |||
| * 返回租户信息 | |||
| * 集团版帐号tenantId为空,parentTenantId为集团tenantId | |||
| * @return | |||
| */ | |||
| public TenantEntity getTenantInfo(){ | |||
| @@ -76,6 +77,7 @@ public class BaseController { | |||
| /** | |||
| * 处理集团新增修改所需租户信息(广场独立修改,集团修改全部) | |||
| * 处理集团版 tenantId为空,parentTenantId为集团tenantId | |||
| * ifParentUpdateTenantInfo | |||
| */ | |||
| public TenantEntity ifParentUpdateTenantInfo() { | |||
| @@ -2,6 +2,7 @@ package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| @@ -10,6 +11,7 @@ import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -146,4 +148,20 @@ public class WxCreditHistoryController extends BaseController { | |||
| return wxCreditHistoryService.getCreditSummary(wxCreditHistory); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("积分清零计划") | |||
| @GetMapping("clearCreditByYear") | |||
| @SystemControllerLog(description = "积分清零计划") | |||
| public ResultData clearCreditByYear(@ModelAttribute WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::clearCreditByYear"); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCreditHistory.setTenantId(tenantInfo.getFinalTenantId()); | |||
| wxCreditHistory.setFinalTenantId(tenantInfo.getFinalTenantId()); | |||
| wxCreditHistory.setOperatorId(getUserId()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| wxCreditHistoryService.clearCreditByYear(wxCreditHistory); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| } | |||
| @@ -68,7 +68,7 @@ public class WxPressOrderController extends BaseController { | |||
| @ApiOperation(value = "参与砍价", notes = "{\"orderId\":\"String\"}") | |||
| @PostMapping("pressOrderJoin") | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public ResultData pressOrderJoin(@RequestBody Map<String, String> paramMap) { | |||
| Date curDate = new Date(); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| @@ -32,4 +32,13 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon | |||
| long getPeopleCount(WxCreditHistory wxCreditHistory); | |||
| int deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void createCreditClearMDTable(@Param("tableSuffix")String tableSuffix); | |||
| void backUpHandleCreditClearDate(@Param("wxCreditHistory")WxCreditHistory wxCreditHistory, @Param("tableSuffix")String tableSuffix); | |||
| void updateHistoryCreditClear(@Param("wxCreditHistory")WxCreditHistory wxCreditHistory, @Param("tableSuffix")String tableSuffix); | |||
| void updateUserCreditClear(@Param("wxCreditHistory")WxCreditHistory wxCreditHistory, @Param("tableSuffix")String tableSuffix); | |||
| } | |||
| @@ -8,6 +8,7 @@ import com.iformall.domain.vo.WxCreditHistoryVo; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| public interface WxCreditHistoryService { | |||
| @@ -72,6 +73,8 @@ public interface WxCreditHistoryService { | |||
| void clearCreditByYear(); | |||
| void clearCreditByYear(WxCreditHistory wxCreditHistory); | |||
| void exportData(HttpServletRequest request, HttpServletResponse response, WxCreditHistory wxCreditHistory); | |||
| ResultData getCreditSummary(WxCreditHistory wxCreditHistory); | |||
| @@ -17,6 +17,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| import com.iformall.utils.CreditUtil; | |||
| import com.iformall.utils.RedisLock; | |||
| @@ -33,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.math.BigDecimal; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| @@ -43,8 +45,11 @@ import java.util.stream.Collectors; | |||
| @Service | |||
| @Slf4j | |||
| public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); | |||
| @Autowired | |||
| WxCreditHistoryMapper wxCreditHistoryMapper; | |||
| @@ -78,6 +83,9 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| @Autowired | |||
| WxLevelConfigMapper wxLevelConfigMapper; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Override | |||
| public void clearCreditByYear() { | |||
| WxScoreRules wxScoreRules = new WxScoreRules(); | |||
| @@ -87,6 +95,29 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| } | |||
| /** | |||
| * @param | |||
| */ | |||
| @Override | |||
| @Transactional(rollbackFor=Exception.class) | |||
| public void clearCreditByYear(WxCreditHistory wxCreditHistory) { | |||
| Date now = new Date(); | |||
| wxCreditHistory.setTenantId(wxCreditHistory.getFinalTenantId()); | |||
| String tableSuffix = "_" + Integer.parseInt(wxCreditHistory.getTenantId())%100 | |||
| + "_" + dateFormat.format(now); | |||
| wxCreditHistoryMapper.createCreditClearMDTable(tableSuffix); | |||
| wxCreditHistoryMapper.backUpHandleCreditClearDate(wxCreditHistory, tableSuffix); | |||
| wxCreditHistory.setCreditType(EnumScoreType.CLEAN_CREDIT.getCode()); | |||
| wxCreditHistory.setCreateDate(now); | |||
| // wxCreditHistory.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| wxCreditHistoryMapper.updateHistoryCreditClear(wxCreditHistory,tableSuffix); | |||
| wxCreditHistoryMapper.updateUserCreditClear(wxCreditHistory,tableSuffix); | |||
| } | |||
| @Override | |||
| public void exportData(HttpServletRequest request, HttpServletResponse response, WxCreditHistory wxCreditHistory) { | |||
| List<WxCreditHistoryVo> wxCreditHistoryVoList = wxCreditHistoryMapper.findListMore(wxCreditHistory); | |||
| @@ -39,7 +39,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||
| WxMsgConfigMapper wxMsgConfigMapper; | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void wxMsgValidationcodeModelInit(String tenantId, String signature, String emailBgImg) { | |||
| DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| String nowTimestr = format.format(new Date()); | |||
| @@ -69,7 +69,7 @@ public class WxParkServiceImpl implements WxParkService { | |||
| } | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void saveOrUpdate(WxPark record) { | |||
| Date now = new Date(); | |||
| if (record.getId() == null) { | |||
| @@ -69,7 +69,7 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||
| MallUserInfoService userInfoService; | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void initProjectConfig(Long id) { | |||
| // WxProjectConfig wxProjectConfig = wxProjectConfigMapper.selectById(id); | |||
| // if(wxProjectConfig!=null && wxProjectConfig.getDelType()<10000){ | |||
| @@ -131,7 +131,7 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||
| } | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void initMall(WxMall wxMall) { | |||
| if(wxMall.getId() == null){ | |||
| wxMall.setTenantId("-1"); | |||
| @@ -157,7 +157,7 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||
| } | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void initBuilding(List<WxMallBuilding> wxMallBuildings) { | |||
| wxMallBuildingService.deleteByTenantId(wxMallBuildings.get(0).getTenantId()); | |||
| wxMallFloorService.deleteByTenantId(wxMallBuildings.get(0).getTenantId()); | |||
| @@ -185,7 +185,7 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||
| } | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void initPayAccount(WxPayAccount wxPayAccount) { | |||
| wxPayAccountService.saveOrUpdate(wxPayAccount); | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(wxPayAccount.getTenantId()); | |||
| @@ -218,7 +218,7 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||
| @Override | |||
| @Transactional | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public void initUserInfo(MallUserInfo userInfo) { | |||
| userInfoService.saveOrUpdate(userInfo); | |||
| //创建角色 | |||
| @@ -262,4 +262,47 @@ | |||
| delete from wx_credit_history where id = #{id} and tenant_id = #{tenantId} | |||
| </delete> | |||
| <update id="createCreditClearMDTable" parameterType="String"> | |||
| CREATE TABLE `wx_credit_clear_md${tableSuffix}` ( | |||
| `id` bigint(20) NOT NULL, | |||
| `user_id` bigint(20) DEFAULT NULL, | |||
| `final_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `credit` int(11) DEFAULT NULL COMMENT '用户当前总积分', | |||
| `sum_credit` int(11) DEFAULT NULL COMMENT '用户当前清零截止时间后总积分', | |||
| `credit_amount` int(11) DEFAULT NULL COMMENT '用户清零扣减积分', | |||
| `cut_off_date` datetime(0) DEFAULT NULL COMMENT '清零截止时间', | |||
| PRIMARY KEY (`id`) USING BTREE | |||
| ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; | |||
| </update> | |||
| <update id="backUpHandleCreditClearDate"> | |||
| insert into `wx_credit_clear_md${tableSuffix}` | |||
| (`id`, `user_id`, `final_tenant_id`, `credit`, `sum_credit`, `credit_amount`, `cut_off_date`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id,wcubi.id user_id,wcubi.final_tenant_id,wcubi.credit,sum(wch.credit_amount) sum_credit,(sum(wch.credit_amount)-wcubi.credit) credit_amount,#{wxCreditHistory.endTime} cut_off_date | |||
| from wx_c_user_basic_info wcubi | |||
| left join wx_credit_history wch on wch.c_user_id = wcubi.id | |||
| where wcubi.final_tenant_id = #{wxCreditHistory.tenantId} and wch.credit_amount > 0 and wch.create_date >= #{wxCreditHistory.endTime} | |||
| group by wcubi.id | |||
| having credit > sum_credit; | |||
| </update> | |||
| <update id="updateHistoryCreditClear"> | |||
| insert into `wx_credit_history` | |||
| (`id`, `tenant_id`, `c_user_id`, `credit_amount`, `credit_num`, `credit_type`, `create_date`, `operator_type`, `operator_id`) | |||
| select id,final_tenant_id,user_id,sum_credit,credit_amount,#{wxCreditHistory.creditType},#{wxCreditHistory.createDate},#{wxCreditHistory.operatorType},#{wxCreditHistory.operatorId} | |||
| from `wx_credit_clear_md${tableSuffix}`; | |||
| </update> | |||
| <update id="updateUserCreditClear"> | |||
| update wx_c_user_basic_info wcubi | |||
| left join `wx_credit_clear_md${tableSuffix}` wccm on wcubi.id = wccm.user_id | |||
| set wcubi.credit = (wcubi.credit + wccm.credit_amount), wcubi.update_date = now() | |||
| where wcubi.final_tenant_id = #{wxCreditHistory.tenantId} and wccm.id is not null; | |||
| </update> | |||
| </mapper> | |||