developrelease_toaliyun_real
| @@ -44,12 +44,14 @@ public class WxBillDailyController extends BaseController | |||||
| public ResultData add(@RequestBody WxBillDaily wxBillDaily) { | public ResultData add(@RequestBody WxBillDaily wxBillDaily) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::add"); | logger.debug("[" + getIpAddr() + "] WxBillDailyController::add"); | ||||
| wxBillDaily.setTenantId(getTenantId()); | wxBillDaily.setTenantId(getTenantId()); | ||||
| wxBillDaily.setUserId(getUser().getId()); | |||||
| return wxBillDailyService.saveOrUpdate(wxBillDaily); | return wxBillDailyService.saveOrUpdate(wxBillDaily); | ||||
| } | } | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxBillDaily wxBillDaily) { | public ResultData update(@RequestBody WxBillDaily wxBillDaily) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::update"); | logger.debug("[" + getIpAddr() + "] WxBillDailyController::update"); | ||||
| wxBillDaily.setUserId(getUser().getId()); | |||||
| return wxBillDailyService.saveOrUpdate(wxBillDaily); | return wxBillDailyService.saveOrUpdate(wxBillDaily); | ||||
| } | } | ||||
| @@ -44,12 +44,14 @@ public class WxBillOtherController extends BaseController | |||||
| public ResultData add(@RequestBody WxBillOther wxBillOther) { | public ResultData add(@RequestBody WxBillOther wxBillOther) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::add"); | logger.debug("[" + getIpAddr() + "] WxBillOtherController::add"); | ||||
| wxBillOther.setTenantId(getTenantId()); | wxBillOther.setTenantId(getTenantId()); | ||||
| wxBillOther.setUserId(getUser().getId()); | |||||
| return wxBillOtherService.saveOrUpdate(wxBillOther); | return wxBillOtherService.saveOrUpdate(wxBillOther); | ||||
| } | } | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxBillOther wxBillOther) { | public ResultData update(@RequestBody WxBillOther wxBillOther) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::update"); | logger.debug("[" + getIpAddr() + "] WxBillOtherController::update"); | ||||
| wxBillOther.setUserId(getUser().getId()); | |||||
| return wxBillOtherService.saveOrUpdate(wxBillOther); | return wxBillOtherService.saveOrUpdate(wxBillOther); | ||||
| } | } | ||||
| @@ -1,5 +1,10 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| @@ -8,14 +13,19 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.impl.WxCUserBasicInfoServiceImpl; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -57,7 +67,10 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| WxLevelConfigService wxLevelConfigService; | |||||
| private WxLevelConfigService wxLevelConfigService; | |||||
| @Autowired | |||||
| private WxTagsService wxTagsService; | |||||
| @Autowired | @Autowired | ||||
| StringRedisTemplate stringRedisTemplate; | StringRedisTemplate stringRedisTemplate; | ||||
| @@ -252,6 +265,18 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| } | } | ||||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||||
| @Override | |||||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| @RequestMapping("/importTemplate") | @RequestMapping("/importTemplate") | ||||
| public ResultData importTemplate(@RequestParam("file") MultipartFile file) { | public ResultData importTemplate(@RequestParam("file") MultipartFile file) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate"); | logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate"); | ||||
| @@ -259,7 +284,8 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | throw new MallinkException(Result.ERROR, "上传文件不能为空"); | ||||
| } | } | ||||
| //得到当前用户ID | //得到当前用户ID | ||||
| String userId = "" + getUser().getId(); | |||||
| final MallUserInfo user = getUser(); | |||||
| String userId = "" + user.getId(); | |||||
| String importKey = importMemPrev + userId; | String importKey = importMemPrev + userId; | ||||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | ||||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | ||||
| @@ -270,7 +296,68 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | ||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | ||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | ||||
| wxCUserBasicInfoService.importTemplate(file, getTenantId(), importKey); | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); | |||||
| IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[] { "手机号" }); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| } | |||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| } | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + total); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "" + all_success); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "" + all_fail); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||||
| final String tenantId = getTenantId(); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| // 异步无法获取到原有的session,所以再注入一下session | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.userInfo, user); | |||||
| session.setAttribute(UserSession.userId, user.getId()); | |||||
| session.setAttribute(UserSession.tenantId, tenantId); | |||||
| wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase); | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + all_fail); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| } | |||||
| stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES); | stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES); | ||||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | return new ResultData(Result.SUCCESS, "模板正在导入"); | ||||
| } | } | ||||
| @@ -96,7 +96,7 @@ public class WxMerchantController extends BaseController { | |||||
| public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) { | public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) { | ||||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); | logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); | ||||
| wxMerchant.setTenantId(getTenantId()); | wxMerchant.setTenantId(getTenantId()); | ||||
| return wxMerchantService.addMerchant(wxMerchant); | |||||
| return wxMerchantService.addMerchant(wxMerchant, getUser().getId()); | |||||
| } | } | ||||
| @ApiOperation("更新商户接口") | @ApiOperation("更新商户接口") | ||||
| @@ -45,14 +45,14 @@ public class WxPropertyContractController extends BaseController | |||||
| public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) { | public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::add"); | logger.debug("[" + getIpAddr() + "] WxPropertyContractController::add"); | ||||
| wxPropertyContract.setTenantId(getTenantId()); | wxPropertyContract.setTenantId(getTenantId()); | ||||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract); | |||||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId()); | |||||
| } | } | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { | public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::update"); | logger.debug("[" + getIpAddr() + "] WxPropertyContractController::update"); | ||||
| wxPropertyContract.setTenantId(getTenantId()); | wxPropertyContract.setTenantId(getTenantId()); | ||||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract); | |||||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId()); | |||||
| } | } | ||||
| @GetMapping("/del") | @GetMapping("/del") | ||||
| @@ -44,28 +44,28 @@ public class WxRentContractController extends BaseController { | |||||
| public ResultData add(@RequestBody WxRentContract wxRentContract) { | public ResultData add(@RequestBody WxRentContract wxRentContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::add"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::add"); | ||||
| wxRentContract.setTenantId(getTenantId()); | wxRentContract.setTenantId(getTenantId()); | ||||
| return wxRentContractService.save(wxRentContract); | |||||
| return wxRentContractService.save(wxRentContract, getUser().getId()); | |||||
| } | } | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxRentContract wxRentContract) { | public ResultData update(@RequestBody WxRentContract wxRentContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::update"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::update"); | ||||
| wxRentContract.setTenantId(getTenantId()); | wxRentContract.setTenantId(getTenantId()); | ||||
| return wxRentContractService.update(wxRentContract); | |||||
| return wxRentContractService.update(wxRentContract, getUser().getId()); | |||||
| } | } | ||||
| @PostMapping("updateMoney") | @PostMapping("updateMoney") | ||||
| public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) { | public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMoney"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMoney"); | ||||
| wxRentContract.setTenantId(getTenantId()); | wxRentContract.setTenantId(getTenantId()); | ||||
| return wxRentContractService.update(wxRentContract); | |||||
| return wxRentContractService.update(wxRentContract, getUser().getId()); | |||||
| } | } | ||||
| @PostMapping("updateFile") | @PostMapping("updateFile") | ||||
| public ResultData updateFile(@RequestBody WxRentContract wxRentContract) { | public ResultData updateFile(@RequestBody WxRentContract wxRentContract) { | ||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateFile"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::updateFile"); | ||||
| wxRentContract.setTenantId(getTenantId()); | wxRentContract.setTenantId(getTenantId()); | ||||
| return wxRentContractService.updateFile(wxRentContract); | |||||
| return wxRentContractService.updateFile(wxRentContract, getUser().getId()); | |||||
| } | } | ||||
| @@ -130,7 +130,7 @@ public class WxRentContractController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData updateRentContractStatus(Long id) { | public ResultData updateRentContractStatus(Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentContractStatus"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentContractStatus"); | ||||
| return wxRentContractService.updateRentContractStatus(id); | |||||
| return wxRentContractService.updateRentContractStatus(id, getUser().getId()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,10 +1,10 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import com.iformall.domain.po.WxTags; | |||||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -103,7 +103,7 @@ public interface WxCUserBasicInfoService { | |||||
| void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId); | void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId); | ||||
| ResultData importTemplate(MultipartFile file, String tenantId, String importKey); | |||||
| void importOneMem(String tenantId, String importKey, List<WxTags> tagList, CUserBaseInfoT uBase); | |||||
| long findCount(WxCUserBasicInfoDto dto); | long findCount(WxCUserBasicInfoDto dto); | ||||
| @@ -65,7 +65,7 @@ public interface WxMerchantService { | |||||
| void disable(Long id); | void disable(Long id); | ||||
| ResultData addMerchant(WxMerchant wxMerchant); | |||||
| ResultData addMerchant(WxMerchant wxMerchant, Long userId); | |||||
| ResultData updateMerchant(WxMerchant wxMerchant); | ResultData updateMerchant(WxMerchant wxMerchant); | ||||
| @@ -35,7 +35,7 @@ public interface WxPropertyContractService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| ResultData saveOrUpdate(WxPropertyContract record); | |||||
| ResultData saveOrUpdate(WxPropertyContract record, Long userId); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -34,10 +34,11 @@ public interface WxRentContractService { | |||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| * @param id | |||||
| */ | */ | ||||
| ResultData save(WxRentContract record); | |||||
| ResultData save(WxRentContract record, Long userId); | |||||
| ResultData update(WxRentContract record); | |||||
| ResultData update(WxRentContract record, Long userId); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -59,8 +60,8 @@ public interface WxRentContractService { | |||||
| void exportContract(HttpServletRequest request, HttpServletResponse response, String tenantId, Long id); | void exportContract(HttpServletRequest request, HttpServletResponse response, String tenantId, Long id); | ||||
| ResultData updateFile(WxRentContract wxRentContract); | |||||
| ResultData updateFile(WxRentContract wxRentContract, Long userId); | |||||
| ResultData updateRentContractStatus(Long id); | |||||
| ResultData updateRentContractStatus(Long id, Long userId); | |||||
| } | } | ||||
| @@ -6,7 +6,6 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBillDaily; | import com.iformall.domain.po.WxBillDaily; | ||||
| import com.iformall.domain.po.WxShop; | import com.iformall.domain.po.WxShop; | ||||
| import com.iformall.enums.EnumBillDailyStatus; | import com.iformall.enums.EnumBillDailyStatus; | ||||
| @@ -16,7 +15,6 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxBillDailyMapper; | import com.iformall.mapper.WxBillDailyMapper; | ||||
| import com.iformall.mapper.WxShopMapper; | import com.iformall.mapper.WxShopMapper; | ||||
| import com.iformall.service.WxBillDailyService; | import com.iformall.service.WxBillDailyService; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -117,7 +115,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(),"实收金额不能大于实际应收金额"); | return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(),"实收金额不能大于实际应收金额"); | ||||
| } | } | ||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| logger.info("新增日常账单"); | logger.info("新增日常账单"); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -126,7 +123,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode()); | record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode()); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| record.setUpdatetime(date); | record.setUpdatetime(date); | ||||
| record.setUserId(user.getId()); | |||||
| record.setExpiredDay(0L); | record.setExpiredDay(0L); | ||||
| record.setOwe(record.getReceivePay()-record.getPay()); | record.setOwe(record.getReceivePay()-record.getPay()); | ||||
| record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| @@ -149,7 +145,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| wxBillDaily.setOwe(record.getReceivePay()-record.getPay()); | wxBillDaily.setOwe(record.getReceivePay()-record.getPay()); | ||||
| wxBillDaily.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillDaily.getStatus()); | wxBillDaily.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillDaily.getStatus()); | ||||
| wxBillDaily.setUpdatetime(new Date()); | wxBillDaily.setUpdatetime(new Date()); | ||||
| wxBillDaily.setUserId(user.getId()); | |||||
| try { | try { | ||||
| wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily); | wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -6,7 +6,6 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBillOther; | import com.iformall.domain.po.WxBillOther; | ||||
| import com.iformall.domain.po.WxShop; | import com.iformall.domain.po.WxShop; | ||||
| import com.iformall.enums.EnumBillDailyStatus; | import com.iformall.enums.EnumBillDailyStatus; | ||||
| @@ -16,7 +15,6 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxBillOtherMapper; | import com.iformall.mapper.WxBillOtherMapper; | ||||
| import com.iformall.mapper.WxShopMapper; | import com.iformall.mapper.WxShopMapper; | ||||
| import com.iformall.service.WxBillOtherService; | import com.iformall.service.WxBillOtherService; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -116,7 +114,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| if(pay>receivepay){ | if(pay>receivepay){ | ||||
| return new ResultData(ErrorCode.BILL_PAY_ERROR,"实收金额不能大于实际应收金额"); | return new ResultData(ErrorCode.BILL_PAY_ERROR,"实收金额不能大于实际应收金额"); | ||||
| } | } | ||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| logger.info("新增其他账单"); | logger.info("新增其他账单"); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -125,7 +122,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode()); | record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode()); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| record.setUpdatetime(date); | record.setUpdatetime(date); | ||||
| record.setUserId(user.getId()); | |||||
| record.setExpiredDay(0L); | record.setExpiredDay(0L); | ||||
| record.setOwe(record.getReceivePay()-record.getPay()); | record.setOwe(record.getReceivePay()-record.getPay()); | ||||
| record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| @@ -148,7 +144,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| wxBillOther.setOwe(record.getReceivePay()-record.getPay()); | wxBillOther.setOwe(record.getReceivePay()-record.getPay()); | ||||
| wxBillOther.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillOther.getStatus()); | wxBillOther.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillOther.getStatus()); | ||||
| wxBillOther.setUpdatetime(new Date()); | wxBillOther.setUpdatetime(new Date()); | ||||
| wxBillOther.setUserId(user.getId()); | |||||
| try { | try { | ||||
| wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther); | wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -1,16 +1,9 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| @@ -39,9 +32,7 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.redis.core.StringRedisTemplate; | import org.springframework.data.redis.core.StringRedisTemplate; | ||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -498,194 +489,126 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| return userBase; | return userBase; | ||||
| } | } | ||||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||||
| @Override | |||||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| @Override | @Override | ||||
| public ResultData importTemplate(MultipartFile file, String tenantId, String importKey) { | |||||
| public void importOneMem(String tenantId, String importKey, List<WxTags> tagList, CUserBaseInfoT uBase) { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); | |||||
| IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[] { "手机号" }); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| if (StringUtils.isBlank(uBase.getPhone())) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("手机号为空", uBase.toString()); | |||||
| return; | |||||
| } | } | ||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||||
| WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId); | |||||
| if (userBase == null) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("userBase为null", uBase.toString()); | |||||
| return; | |||||
| } | } | ||||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + total); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "" + all_success); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", "0"); | |||||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", "" + all_fail); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsMapper.findList(wxTagsQ); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| WxCUserBasicInfo oldUserBase = null; | |||||
| WxCUserBasicInfo userBaseQ = new WxCUserBasicInfo(); | |||||
| userBaseQ.setTenantId(tenantId); | |||||
| userBaseQ.setPhone(userBase.getPhone()); | |||||
| List<WxCUserBasicInfo> userBList = wxCUserBasicInfoMapper.select(userBaseQ); | |||||
| if (userBList.size() > 0) { | |||||
| oldUserBase = userBList.get(0); | |||||
| } | |||||
| if (StringUtils.isBlank(uBase.getPhone())) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("手机号为空", uBase.toString()); | |||||
| return; | |||||
| } | |||||
| WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId); | |||||
| if (userBase == null) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("userBase为null", uBase.toString()); | |||||
| return; | |||||
| } | |||||
| if (oldUserBase != null) { | |||||
| oldUserBase.setName(userBase.getName()); | |||||
| oldUserBase.setSex(userBase.getSex()); | |||||
| oldUserBase.setNickName(userBase.getNickName()); | |||||
| oldUserBase.setEducation(userBase.getEducation()); | |||||
| oldUserBase.setBirthdate(userBase.getBirthdate()); | |||||
| oldUserBase.setAddress(userBase.getAddress()); | |||||
| oldUserBase.setUpdateDate(new Date()); | |||||
| oldUserBase.setCreateDate(userBase.getCreateDate()); | |||||
| } else { | |||||
| userBase.setId(idWorker.nextId()); | |||||
| } | |||||
| WxCUserBasicInfo oldUserBase = null; | |||||
| WxCUserBasicInfo userBaseQ = new WxCUserBasicInfo(); | |||||
| userBaseQ.setTenantId(tenantId); | |||||
| userBaseQ.setPhone(userBase.getPhone()); | |||||
| List<WxCUserBasicInfo> userBList = wxCUserBasicInfoMapper.select(userBaseQ); | |||||
| if (userBList.size() > 0) { | |||||
| oldUserBase = userBList.get(0); | |||||
| } | |||||
| // update 昵称 | |||||
| { | |||||
| // check c_user 是否存在 | |||||
| WxCUser cUserQ = new WxCUser(); | |||||
| cUserQ.setTenantId(tenantId); | |||||
| cUserQ.setPhone(userBase.getPhone()); | |||||
| List<WxCUser> userList = wxCUserMapper.select(cUserQ); | |||||
| if (userList.size() > 0) { | |||||
| WxCUser user = userList.get(0); | |||||
| if (user != null) { | |||||
| if (oldUserBase != null) { | |||||
| if(oldUserBase != null) { | |||||
| oldUserBase.setNickName(user.getNickName()); | |||||
| } | |||||
| userBase.setId(user.getId()); | |||||
| userBase.setNickName(user.getNickName()); | |||||
| } else { | |||||
| if (oldUserBase != null) { | |||||
| oldUserBase.setName(userBase.getName()); | |||||
| oldUserBase.setSex(userBase.getSex()); | |||||
| oldUserBase.setNickName(userBase.getNickName()); | |||||
| oldUserBase.setEducation(userBase.getEducation()); | |||||
| oldUserBase.setBirthdate(userBase.getBirthdate()); | |||||
| oldUserBase.setAddress(userBase.getAddress()); | |||||
| oldUserBase.setUpdateDate(new Date()); | |||||
| oldUserBase.setCreateDate(userBase.getCreateDate()); | |||||
| } else { | |||||
| userBase.setId(idWorker.nextId()); | |||||
| userBase.setNickName(user.getNickName()); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| } | |||||
| // update 昵称 | |||||
| { | |||||
| // check c_user 是否存在 | |||||
| WxCUser cUserQ = new WxCUser(); | |||||
| cUserQ.setTenantId(tenantId); | |||||
| cUserQ.setPhone(userBase.getPhone()); | |||||
| List<WxCUser> userList = wxCUserMapper.select(cUserQ); | |||||
| if (userList.size() > 0) { | |||||
| WxCUser user = userList.get(0); | |||||
| if (user != null) { | |||||
| if (oldUserBase != null) { | |||||
| if(oldUserBase != null) { | |||||
| oldUserBase.setNickName(user.getNickName()); | |||||
| } | |||||
| userBase.setId(user.getId()); | |||||
| userBase.setNickName(user.getNickName()); | |||||
| } else { | |||||
| userBase.setNickName(user.getNickName()); | |||||
| } | |||||
| if (oldUserBase != null) { | |||||
| logger.info("update user base: " + oldUserBase.getId()); | |||||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase); | |||||
| } else { | |||||
| logger.info("insert user base: " + userBase.getId()); | |||||
| try { | |||||
| wxCUserBasicInfoMapper.insertSelective(userBase); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error(e.getMessage()); | |||||
| return; | |||||
| } | |||||
| } | |||||
| // update tags | |||||
| try { | |||||
| if (StringUtils.isNotBlank(userBase.getTagNames())) { | |||||
| // get tag ids | |||||
| String tagNames = userBase.getTagNames(); | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (String tagName : tagNames.split("/")) { | |||||
| for(WxTags tag: tagList) { | |||||
| if(tagName.equals(tag.getName())) { | |||||
| tagIdList.add(Long.valueOf(tag.getId())); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (oldUserBase != null) { | |||||
| logger.info("update user base: " + oldUserBase.getId()); | |||||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase); | |||||
| } else { | |||||
| logger.info("insert user base: " + userBase.getId()); | |||||
| try { | |||||
| wxCUserBasicInfoMapper.insertSelective(userBase); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error(e.getMessage()); | |||||
| return; | |||||
| } | |||||
| if (oldUserBase != null){ | |||||
| wxCUserTagsService.assignTags(tagIdList,oldUserBase); | |||||
| }else{ | |||||
| wxCUserTagsService.assignTags(tagIdList,userBase); | |||||
| } | } | ||||
| // update tags | |||||
| try { | |||||
| if (StringUtils.isNotBlank(userBase.getTagNames())) { | |||||
| // get tag ids | |||||
| String tagNames = userBase.getTagNames(); | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| for (String tagName : tagNames.split("/")) { | |||||
| for(WxTags tag: tagList) { | |||||
| if(tagName.equals(tag.getName())) { | |||||
| tagIdList.add(Long.valueOf(tag.getId())); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (oldUserBase != null){ | |||||
| wxCUserTagsService.assignTags(tagIdList,oldUserBase); | |||||
| }else{ | |||||
| wxCUserTagsService.assignTags(tagIdList,userBase); | |||||
| } | |||||
| } | |||||
| } | |||||
| //触发自动打标签 | |||||
| if (oldUserBase != null) { | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase); | |||||
| } | |||||
| else{ | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | |||||
| } | |||||
| //触发自动打标签 | |||||
| if (oldUserBase != null) { | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase); | |||||
| } | |||||
| else{ | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | |||||
| } | |||||
| // 成长值 | |||||
| if (StringUtils.isNotBlank(uBase.getPoins())) { | |||||
| if (oldUserBase != null) { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins()); | |||||
| } else { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins()); | |||||
| } | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| logger.error("打标签+成长值失败--继续导入"); | |||||
| // 成长值 | |||||
| if (StringUtils.isNotBlank(uBase.getPoins())) { | |||||
| if (oldUserBase != null) { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins()); | |||||
| } else { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins()); | |||||
| } | } | ||||
| //记数 | |||||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||||
| }); | |||||
| } | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + all_fail); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| logger.error(e.getMessage()); | |||||
| logger.error("打标签+成长值失败--继续导入"); | |||||
| } | } | ||||
| return new ResultData(); | |||||
| //记数 | |||||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -14,7 +14,6 @@ import com.iformall.mapper.*; | |||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.service.WxProfitSharingReceiverService; | import com.iformall.service.WxProfitSharingReceiverService; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -220,6 +219,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop); | wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop); | ||||
| //更新商铺状态 | //更新商铺状态 | ||||
| WxShop wxShop = new WxShop(); | WxShop wxShop = new WxShop(); | ||||
| wxShop.setTenantId(wxMerchant.getTenantId()); | |||||
| wxShop.setId(wxMerchantShop.getShopId()); | wxShop.setId(wxMerchantShop.getShopId()); | ||||
| wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); | wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); | ||||
| wxShopMapper.updateByPrimaryKeySelective(wxShop); | wxShopMapper.updateByPrimaryKeySelective(wxShop); | ||||
| @@ -234,12 +234,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| } | } | ||||
| //作废卡券 | //作废卡券 | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| wxCouponMerchant.setTenantId(wxMerchant.getTenantId()); | |||||
| wxCouponMerchant.setMerchantId(wxMerchant.getId()); | wxCouponMerchant.setMerchantId(wxMerchant.getId()); | ||||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | ||||
| List<Long> couponIds = wxCouponMerchantList.stream().map(cm->cm.getProductId()).collect(Collectors.toList()); | List<Long> couponIds = wxCouponMerchantList.stream().map(cm->cm.getProductId()).collect(Collectors.toList()); | ||||
| WxCoupon wxCoupon = new WxCoupon(); | |||||
| couponIds.parallelStream().filter(cid->!isCouponMerchantValid(cid)).forEach(cid->{ | |||||
| couponIds.stream().filter(cid->!isCouponMerchantValid(cid)).forEach(cid->{ | |||||
| WxCoupon wxCoupon = new WxCoupon(); | |||||
| wxCoupon.setId(cid); | wxCoupon.setId(cid); | ||||
| wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()); | wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()); | ||||
| wxCouponService.saveOrUpdate(wxCoupon); | wxCouponService.saveOrUpdate(wxCoupon); | ||||
| @@ -248,7 +250,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public ResultData addMerchant(WxMerchant wxMerchant) { | |||||
| public ResultData addMerchant(WxMerchant wxMerchant, Long userId) { | |||||
| try { | try { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -309,9 +311,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); | wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); | ||||
| wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | ||||
| //创建账单 | //创建账单 | ||||
| buildRent(wxMerchant); | |||||
| buildRent(wxMerchant, userId); | |||||
| //创建押金 | //创建押金 | ||||
| buildDeposit(wxMerchant); | |||||
| buildDeposit(wxMerchant, userId); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "商户创建成功", merchantId); | return new ResultData(Result.SUCCESS, "商户创建成功", merchantId); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -507,8 +509,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildDeposit(WxMerchant wxMerchant) { | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| public void buildDeposit(WxMerchant wxMerchant, Long userId) { | |||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| wxRentContract.setMerchantId(wxMerchant.getId()); | wxRentContract.setMerchantId(wxMerchant.getId()); | ||||
| List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | ||||
| @@ -555,7 +556,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | ||||
| wxBillDeposit.setIsDel(0); | wxBillDeposit.setIsDel(0); | ||||
| wxBillDeposit.setMerchantId(wxMerchant.getId()); | wxBillDeposit.setMerchantId(wxMerchant.getId()); | ||||
| wxBillDeposit.setUserId(user.getId()); | |||||
| wxBillDeposit.setUserId(userId); | |||||
| wxBillDeposit.setShopId(wxRentContract.getShopId()); | wxBillDeposit.setShopId(wxRentContract.getShopId()); | ||||
| wxBillDeposit.setCreatetime(date); | wxBillDeposit.setCreatetime(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| @@ -569,10 +570,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildRent(WxMerchant wxMerchant) { | |||||
| public void buildRent(WxMerchant wxMerchant, Long userId) { | |||||
| //获取用户 | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| wxRentContract.setMerchantId(wxMerchant.getId()); | wxRentContract.setMerchantId(wxMerchant.getId()); | ||||
| //根据商户ID找出合同 | //根据商户ID找出合同 | ||||
| @@ -653,7 +652,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxBillRent.setTenantId(wxRentContract.getTenantId()); | wxBillRent.setTenantId(wxRentContract.getTenantId()); | ||||
| wxBillRent.setIsDel(0); | wxBillRent.setIsDel(0); | ||||
| wxBillRent.setMerchantId(wxRentContract.getMerchantId()); | wxBillRent.setMerchantId(wxRentContract.getMerchantId()); | ||||
| wxBillRent.setUserId(user.getId()); | |||||
| wxBillRent.setUserId(userId); | |||||
| wxBillRent.setShopId(wxRentContract.getShopId()); | wxBillRent.setShopId(wxRentContract.getShopId()); | ||||
| wxBillRent.setCreatetime(date); | wxBillRent.setCreatetime(date); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| @@ -15,7 +15,6 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxPropertyContractService; | import com.iformall.service.WxPropertyContractService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -100,7 +99,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData saveOrUpdate(WxPropertyContract record) { | |||||
| public ResultData saveOrUpdate(WxPropertyContract record, Long userId) { | |||||
| if (null == record.getShopId()) { | if (null == record.getShopId()) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "shopId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "shopId不能为空"); | ||||
| @@ -188,9 +187,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxMerchant.setId(record.getMerchantId()); | wxMerchant.setId(record.getMerchantId()); | ||||
| wxMerchant.setTenantId(record.getTenantId()); | wxMerchant.setTenantId(record.getTenantId()); | ||||
| //物业账单 | //物业账单 | ||||
| buildProperty(wxMerchant); | |||||
| buildProperty(wxMerchant, userId); | |||||
| //物业押金账单 | //物业押金账单 | ||||
| buildDeposit(wxMerchant); | |||||
| buildDeposit(wxMerchant, userId); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -231,8 +230,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildDeposit(WxMerchant wxMerchant) { | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| public void buildDeposit(WxMerchant wxMerchant, Long userId) { | |||||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | WxPropertyContract wxPropertyContract = new WxPropertyContract(); | ||||
| wxPropertyContract.setMerchantId(wxMerchant.getId()); | wxPropertyContract.setMerchantId(wxMerchant.getId()); | ||||
| List<WxPropertyContract> list = wxPropertyContractMapper.findList(wxPropertyContract); | List<WxPropertyContract> list = wxPropertyContractMapper.findList(wxPropertyContract); | ||||
| @@ -276,7 +274,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | ||||
| wxBillDeposit.setIsDel(0); | wxBillDeposit.setIsDel(0); | ||||
| wxBillDeposit.setMerchantId(wxMerchant.getId()); | wxBillDeposit.setMerchantId(wxMerchant.getId()); | ||||
| wxBillDeposit.setUserId(user.getId()); | |||||
| wxBillDeposit.setUserId(userId); | |||||
| wxBillDeposit.setShopId(wxPropertyContract.getShopId()); | wxBillDeposit.setShopId(wxPropertyContract.getShopId()); | ||||
| wxBillDeposit.setCreatetime(date); | wxBillDeposit.setCreatetime(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| @@ -291,9 +289,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildProperty(WxMerchant wxMerchant) { | |||||
| //获取用户 | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| public void buildProperty(WxMerchant wxMerchant, Long userId) { | |||||
| //根据商户ID找出合同 | //根据商户ID找出合同 | ||||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | WxPropertyContract wxPropertyContract = new WxPropertyContract(); | ||||
| wxPropertyContract.setMerchantId(wxMerchant.getId()); | wxPropertyContract.setMerchantId(wxMerchant.getId()); | ||||
| @@ -371,7 +367,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillProperty.setTenantId(wxMerchant.getTenantId()); | wxBillProperty.setTenantId(wxMerchant.getTenantId()); | ||||
| wxBillProperty.setIsDel(0); | wxBillProperty.setIsDel(0); | ||||
| wxBillProperty.setMerchantId(wxMerchant.getId()); | wxBillProperty.setMerchantId(wxMerchant.getId()); | ||||
| wxBillProperty.setUserId(user.getId()); | |||||
| wxBillProperty.setUserId(userId); | |||||
| wxBillProperty.setShopId(wxPropertyContract.getShopId()); | wxBillProperty.setShopId(wxPropertyContract.getShopId()); | ||||
| wxBillProperty.setCreatetime(date); | wxBillProperty.setCreatetime(date); | ||||
| wxBillProperty.setUpdatetime(date); | wxBillProperty.setUpdatetime(date); | ||||
| @@ -18,7 +18,6 @@ import com.iformall.utils.DateUtils; | |||||
| import org.apache.commons.io.FileUtils; | import org.apache.commons.io.FileUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.poi.xwpf.usermodel.XWPFDocument; | import org.apache.poi.xwpf.usermodel.XWPFDocument; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -116,7 +115,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public ResultData save(WxRentContract record) { | |||||
| public ResultData save(WxRentContract record, Long userId) { | |||||
| //保存租赁合同信息 | //保存租赁合同信息 | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| @@ -176,9 +175,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxMerchant.setId(record.getMerchantId()); | wxMerchant.setId(record.getMerchantId()); | ||||
| wxMerchant.setTenantId(record.getTenantId()); | wxMerchant.setTenantId(record.getTenantId()); | ||||
| //租金 | //租金 | ||||
| buildRent(wxMerchant); | |||||
| buildRent(wxMerchant, userId); | |||||
| //押金 | //押金 | ||||
| buildDeposit(wxMerchant); | |||||
| buildDeposit(wxMerchant, userId); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -190,11 +189,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public ResultData update(WxRentContract record) { | |||||
| return getResultDataForUpdate(record); | |||||
| public ResultData update(WxRentContract record, Long userId) { | |||||
| return getResultDataForUpdate(record, userId); | |||||
| } | } | ||||
| public ResultData getResultDataForUpdate(WxRentContract record) { | |||||
| public ResultData getResultDataForUpdate(WxRentContract record, Long userId) { | |||||
| //更新租赁合同信息 | //更新租赁合同信息 | ||||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); | WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); | ||||
| if (wxRentContract == null) { | if (wxRentContract == null) { | ||||
| @@ -252,9 +251,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxMerchant.setId(record.getMerchantId()); | wxMerchant.setId(record.getMerchantId()); | ||||
| wxMerchant.setTenantId(record.getTenantId()); | wxMerchant.setTenantId(record.getTenantId()); | ||||
| //租金 | //租金 | ||||
| buildRent(wxMerchant); | |||||
| buildRent(wxMerchant, userId); | |||||
| //押金 | //押金 | ||||
| buildDeposit(wxMerchant); | |||||
| buildDeposit(wxMerchant, userId); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -266,8 +265,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildDeposit(WxMerchant wxMerchant) { | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| public void buildDeposit(WxMerchant wxMerchant, Long userId) { | |||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| wxRentContract.setMerchantId(wxMerchant.getId()); | wxRentContract.setMerchantId(wxMerchant.getId()); | ||||
| List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | ||||
| @@ -316,7 +314,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | ||||
| wxBillDeposit.setIsDel(0); | wxBillDeposit.setIsDel(0); | ||||
| wxBillDeposit.setMerchantId(wxMerchant.getId()); | wxBillDeposit.setMerchantId(wxMerchant.getId()); | ||||
| wxBillDeposit.setUserId(user.getId()); | |||||
| wxBillDeposit.setUserId(userId); | |||||
| wxBillDeposit.setShopId(wxRentContract.getShopId()); | wxBillDeposit.setShopId(wxRentContract.getShopId()); | ||||
| wxBillDeposit.setCreatetime(date); | wxBillDeposit.setCreatetime(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| @@ -332,10 +330,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildRent(WxMerchant wxMerchant) { | |||||
| //获取用户 | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| public void buildRent(WxMerchant wxMerchant, Long userId) { | |||||
| //根据商户ID找出合同 | //根据商户ID找出合同 | ||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| @@ -417,7 +412,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillRent.setTenantId(wxMerchant.getTenantId()); | wxBillRent.setTenantId(wxMerchant.getTenantId()); | ||||
| wxBillRent.setIsDel(0); | wxBillRent.setIsDel(0); | ||||
| wxBillRent.setMerchantId(wxMerchant.getId()); | wxBillRent.setMerchantId(wxMerchant.getId()); | ||||
| wxBillRent.setUserId(user.getId()); | |||||
| wxBillRent.setUserId(userId); | |||||
| wxBillRent.setShopId(wxRentContract.getShopId()); | wxBillRent.setShopId(wxRentContract.getShopId()); | ||||
| wxBillRent.setCreatetime(date); | wxBillRent.setCreatetime(date); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| @@ -712,12 +707,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData updateFile(WxRentContract record) { | |||||
| return getResultDataForUpdate(record); | |||||
| public ResultData updateFile(WxRentContract record, Long userId) { | |||||
| return getResultDataForUpdate(record, userId); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData updateRentContractStatus(Long id) { | |||||
| public ResultData updateRentContractStatus(Long id, Long userId) { | |||||
| if(id == null) { | if(id == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } | } | ||||
| @@ -742,9 +737,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxMerchant.setId(record.getMerchantId()); | wxMerchant.setId(record.getMerchantId()); | ||||
| wxMerchant.setTenantId(record.getTenantId()); | wxMerchant.setTenantId(record.getTenantId()); | ||||
| //租金 | //租金 | ||||
| buildRent(wxMerchant); | |||||
| buildRent(wxMerchant, userId); | |||||
| //押金 | //押金 | ||||
| buildDeposit(wxMerchant); | |||||
| buildDeposit(wxMerchant, userId); | |||||
| } | } | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "操作成功"); | return new ResultData(Result.SUCCESS, "操作成功"); | ||||