diff --git a/mallinkAdmin/src/main/java/com/simple/config/RestTemplateConfig.java b/mallinkAdmin/src/main/java/com/simple/config/RestTemplateConfig.java new file mode 100644 index 000000000..4fb4b4bda --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/config/RestTemplateConfig.java @@ -0,0 +1,24 @@ +package com.simple.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(ClientHttpRequestFactory factory) { + return new RestTemplate(factory); + } + + @Bean + public ClientHttpRequestFactory simpleClientHttpRequestFactory() { + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setReadTimeout(5000);//ms + factory.setConnectTimeout(10000);//ms + return factory; + } +} \ No newline at end of file diff --git a/mallinkAdmin/src/main/java/com/simple/controller/DataTowerController.java b/mallinkAdmin/src/main/java/com/simple/controller/DataTowerController.java index 281a96560..3ed0a4e0e 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/DataTowerController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/DataTowerController.java @@ -43,6 +43,14 @@ public class DataTowerController extends BaseController { return new ResultData(data); } + @ApiOperation("查询客流") + @PostMapping("/queryCustomer") + public ResultData queryCustomer() { + + Map data=dataTowerService.queryCustomer(getTenantId()); + + return new ResultData(data); + } } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/MarkingDataReportController.java b/mallinkAdmin/src/main/java/com/simple/controller/MarkingDataReportController.java new file mode 100644 index 000000000..a19a432cb --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/MarkingDataReportController.java @@ -0,0 +1,64 @@ +package com.simple.controller; + +import com.simple.common.Result; +import com.simple.common.ResultData; +import com.simple.domain.dto.MarkingCouponDataReportDto; +import com.simple.service.MarkingDataReportService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by syf on 2018/8/29. + */ +@RestController +@RequestMapping("markingDataReport") +@Api(description="营销报表接口") +public class MarkingDataReportController extends BaseController { + + @Autowired + private MarkingDataReportService markingDataReportService; + @ApiOperation("查询券数据") + @GetMapping("/couponData") + public ResultData findCouponData() { + return new ResultData(markingDataReportService.getCouponDate(getTenantId())); + } + + @ApiOperation("查询券数据列表") + @GetMapping("/couponDataList") + public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto,Integer pageNum, Integer pageSize) { + return new ResultData(markingDataReportService.getCouponDateList(getTenantId(),markingCouponDataReportDto,pageNum,pageSize)); + } + + @ApiOperation("查询场景投放券数据") + @GetMapping("/sceneData") + public ResultData findSceneData() { + return new ResultData(markingDataReportService.getSceneData(getTenantId())); + } + + @ApiOperation("查询场景营销数据列表") + @GetMapping("/sceneDataList") + public ResultData findSceneDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto,Integer pageNum, Integer pageSize) { + return new ResultData(markingDataReportService.getSceneDataList(getTenantId(),markingCouponDataReportDto,pageNum,pageSize)); + } + + @ApiOperation("查询触达用户数数据") + @GetMapping("/touchUsersData") + public ResultData touchUsersData() { + return new ResultData(markingDataReportService.getTouchUsersReportData(getTenantId())); + } + + @ApiOperation("查询触达用户数数据列表") + @GetMapping("/touchUsersDataList") + public ResultData touchUsersDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto,Integer pageNum, Integer pageSize) { + return new ResultData(markingDataReportService.getTouchUsersReportList(getTenantId(),markingCouponDataReportDto,pageNum,pageSize)); + } + + + +} diff --git a/mallinkAdmin/src/main/java/com/simple/controller/UploadController.java b/mallinkAdmin/src/main/java/com/simple/controller/UploadController.java index 6ef4d2605..f8db9e2b1 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/UploadController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/UploadController.java @@ -1,6 +1,7 @@ package com.simple.controller; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -50,7 +51,7 @@ public class UploadController { ) { ResultData data = new ResultData(); FileOutputStream fos=null; - FileInputStream fs=null; + BufferedInputStream fs=null; try { File targetFile = new File(filePath); if(!targetFile.exists()){ @@ -60,7 +61,7 @@ public class UploadController { int dot = multiReq.getOriginalFilename().lastIndexOf('.'); fileName=fileName+ multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); fos = new FileOutputStream(new File(filePath+File.separator+fileName)); - fs=(FileInputStream) multiReq.getInputStream(); + fs=(BufferedInputStream) multiReq.getInputStream(); byte[] buffer=new byte[1024]; int len=0; while((len=fs.read(buffer))!=-1){ @@ -75,6 +76,7 @@ public class UploadController { } catch (Exception e) { e.printStackTrace(); data.code=ResultData.ERROR; + data.message="上传失败"; }finally { if(fos!=null) { try { diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java index ba527055a..b281d108f 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java @@ -200,84 +200,5 @@ public class WxCUserBasicInfoController extends BaseController return new ResultData(Result.SUCCESS,"查询成功",page); } - @ApiOperation("查询会员性别结构") - @GetMapping("/findUserSexStructure") - public ResultData findUserSexStructure( - Date startTime,Date endTime - ) { - WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); - dto.setStartTime(startTime); - dto.setEndTime(endTime); - //保密 - dto.setSex(0); - long secrecy = getCount(dto); - dto.setSex(1); - long boy = getCount(dto); - dto.setSex(2); - long girl=getCount(dto); - Long all =secrecy+boy+girl; - List vos = new ArrayList<>(); - vos.add(getVo(boy, all, "男",1)); - vos.add(getVo(girl, all, "女",2)); - vos.add(getVo(secrecy, all, "保密",3)); - return new ResultData(vos); - } - - @ApiOperation("查询会员年龄结构") - @GetMapping("/findUserAgeStructure") - public ResultData findUserAgeStructure( Date startTime,Date endTime) { - WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); - dto.setStartTime(startTime); - dto.setEndTime(endTime); - long all =wxCUserBasicInfoService.findCountByAge(dto); - List vos = new ArrayList<>(); - Calendar c = Calendar.getInstance(); - for(EnumAgeInfo a:EnumAgeInfo.values()) { - c.clear(); - c.setTime(new Date()); - c.set(Calendar.HOUR_OF_DAY, 0); - c.set(Calendar.MINUTE,0); - c.set(Calendar.SECOND,0); - long count = getCountByAge(a, c,dto); - vos.add(getVo(count, all, a.getDesc(),a.getSortNum())); - } - return new ResultData(vos); - } - - - private long getCountByAge(EnumAgeInfo a,Calendar c, WxCuerBasicInfoDto dto ) { - c.add(Calendar.YEAR, -a.getEnd()); - Date startTime = c.getTime(); - c.clear(); - c.setTime(startTime); - c.add(Calendar.YEAR,a.getEnd()-a.getStart()); - Date endTime = c.getTime(); - dto.setBirthStartTime(startTime); - dto.setBirthEndTime(endTime); - return wxCUserBasicInfoService.findCountByAge(dto); - } - - - //通过性别获取数量 - private long getCount(WxCuerBasicInfoDto dto) { - //TODO 考虑性能问题,暂不处理少量重复问题,后续可考虑大数据处理 - return wxCUserBasicInfoService.findCountBySex(dto)+ - wxCUserService.findCountBySex(dto); - } - - private UserStructureVo getVo(long count,long all,String name,Integer num) { - UserStructureVo vo = new UserStructureVo(); - vo.setSortNum(num); - vo.setName(name); - vo.setCount(count+""); - NumberFormat nf = NumberFormat.getPercentInstance(); - nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 - if(all>0) { - vo.setPercentage(nf.format(new Long(count).doubleValue()/new Long(all).doubleValue())); - }else { - vo.setPercentage("0.00%"); - } - return vo; - } - + } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserDataController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserDataController.java new file mode 100644 index 000000000..cbb176207 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserDataController.java @@ -0,0 +1,209 @@ +package com.simple.controller; + +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.simple.common.ResultData; +import com.simple.domain.dto.WxCuerBasicInfoDto; +import com.simple.domain.vo.TouchUsersReportVo; +import com.simple.domain.vo.UserStructureVo; +import com.simple.service.WxCUserService; +import com.simple.service.WxUserVisitService; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("wxCUserData") +@Api(description="会员首页报表数据") +public class WxCUserDataController extends BaseController{ + + @Autowired + private WxCUserService wxCUserService; + @Autowired + private WxUserVisitService wxUserVisitService; + + @GetMapping("findUserCountData") + @ApiOperation("查询用户数量接口") + public ResultData findUserCountData() { + WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); + long allCount = wxCUserService.findCount(dto);//总数 + Calendar c = Calendar.getInstance(); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE,0); + c.set(Calendar.SECOND,0); + Date today = c.getTime(); +// dto.setStartTime(today); +// dto.setEndTime(null); +// long todayCount= wxCUserService.findCount( dto);//今天新增 +// System.out.println(todayCount); + long todayCount=0; + long yesterdayCount =0; + long dayOfWeekCount=0; + List newCountVos = new ArrayList<>();//每日新增会员数 + int j=0; + for(int i=7;i>=0;i--) { + c.clear(); + c.setTime(today); + c.add(Calendar.DAY_OF_YEAR, -i); + dto.setStartTime(c.getTime()); + c.add(Calendar.DAY_OF_YEAR, 1); + dto.setEndTime(c.getTime()); + long count= wxCUserService.findCount(dto); + UserStructureVo vo = new UserStructureVo(); + vo.setSortNum(j); + j++; + vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); + vo.setCount(count); + if(i==1) { + yesterdayCount= count; + } + if(i==0) { + todayCount=count; + } + if(i==7) { + dayOfWeekCount=count;//上周同比 + }else { + newCountVos.add(vo); + } + } + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2); + String dayPercentage =""; + if(yesterdayCount>0) { + Long count =todayCount-yesterdayCount; + dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue()); + }else { + dayPercentage= nf.format(new Double(todayCount).doubleValue()); + } + String weekPercentage =""; + if(dayOfWeekCount>0) { + Long count =todayCount-dayOfWeekCount; + weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); + }else { + weekPercentage= nf.format(new Double(todayCount).doubleValue()); + } + Map map = new HashMap<>(); + map.put("allCount", allCount); + map.put("todayCount", todayCount); + map.put("newCountVos", newCountVos); + map.put("dayPercentage",dayPercentage);//日环比 + map.put("weekPercentage",weekPercentage); //周同比 + return new ResultData(map); + } + + @GetMapping("findUserVisitData") + public ResultData findUserVisitData() { + HashMap params =new HashMap<>(); + Calendar c = Calendar.getInstance(); + c.add(Calendar.DAY_OF_YEAR, -1); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE,0); + c.set(Calendar.SECOND,0); + Date endTime = c.getTime(); + c.add(Calendar.DAY_OF_YEAR, -30); + Date startTime = c.getTime(); + params.put("startTime", startTime); + params.put("endTime", endTime); + params.put("tenantId", getTenantId()); + List list = wxUserVisitService.touchUsersReportList(params); + Map dateMap = new HashMap<>(); + for(TouchUsersReportVo vo :list) { + dateMap.put(vo.getxTime(), vo); + } + List weekVos = new ArrayList<>();//每周uv + List monthVos =new ArrayList<>();//每月uv + int j=1; + long yesterdayCount =0;//昨天活跃数 + long beforeYesterdayCount=0;//前天活跃数 + long thisMonthCount=0;//月总数 + long dayOfWeekCount=0;//上周周x数 + for(int i=6;i>=0;i--) { + c.clear(); + c.setTime(endTime); + c.add(Calendar.DAY_OF_YEAR, -i); + String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); + UserStructureVo vo = new UserStructureVo(); + vo.setName(dayStr); + vo.setSortNum(j); + j++; + if(dateMap.get(dayStr)!=null) { + TouchUsersReportVo rv = dateMap.get(dayStr); + Long l = new Long((long) rv.getUv()); + vo.setCount(l); + }else { + vo.setCount(0); + } + weekVos.add(vo); + } + + j=1; + for(int i=29;i>=0;i--) { + c.clear(); + c.setTime(endTime); + c.add(Calendar.DAY_OF_YEAR, -i); + String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); + UserStructureVo vo = new UserStructureVo(); + vo.setName(dayStr); + vo.setSortNum(j); + if(dateMap.get(dayStr)!=null) { + TouchUsersReportVo rv = dateMap.get(dayStr); + Long l = new Long((long) rv.getUv()); + vo.setCount(l); + }else { + vo.setCount(0); + } + thisMonthCount+=vo.getCount(); + if(i==0) { + yesterdayCount =vo.getCount(); + } + if(i==1) { + beforeYesterdayCount =vo.getCount(); + } + if(i==7) { + dayOfWeekCount=vo.getCount(); + } + + monthVos.add(vo); + j++; + } + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2); + String dayPercentage =""; + if(beforeYesterdayCount>0) { + Long count =yesterdayCount-beforeYesterdayCount; + dayPercentage=nf.format(count.doubleValue()/new Double(beforeYesterdayCount).doubleValue()); + }else { + dayPercentage= nf.format(new Double(yesterdayCount).doubleValue()); + } + String weekPercentage =""; + if(dayOfWeekCount>0) { + Long count =yesterdayCount-dayOfWeekCount; + weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); + }else { + weekPercentage= nf.format(new Double(yesterdayCount).doubleValue()); + } + Map mapVo =new HashMap<>(); + mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数 + mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数 + mapVo.put("weekVos", weekVos);//上周活跃数 + mapVo.put("monthVos", monthVos);//上月活跃数 + mapVo.put("dayPercentage",dayPercentage);//日环比 + mapVo.put("weekPercentage",weekPercentage); //周同比 + return new ResultData(mapVo); + } + + +} diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java index 6a2885621..05ec8091e 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCampaignController.java @@ -1,12 +1,18 @@ package com.simple.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.github.pagehelper.PageInfo; import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxCampaign; import com.simple.domain.po.WxCoupon; +import com.simple.domain.po.WxCouponChannel; +import com.simple.domain.vo.WxCouponChannelVo; +import com.simple.enums.EnumCouponChannelType; +import com.simple.enums.EnumCouponStatus; import com.simple.service.WxCampaignService; +import com.simple.service.WxCouponChannelService; import com.simple.service.WxCouponService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -29,9 +35,13 @@ public class WxCampaignController extends BaseController { @Autowired private WxCampaignService wxCampaignService; + @Autowired private WxCouponService wxCouponService; + @Autowired + private WxCouponChannelService wxCouponChannelService; + private Logger logger = Logger.getLogger(WxCampaignController.class); @ApiOperation("分页列表接口") @@ -59,6 +69,8 @@ public class WxCampaignController extends BaseController if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { String[] arys = wxCampaign.getCouponIds().split(","); wxCampaign.setCouponIds(JSON.toJSONString(arys)); + }else { + wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0])); } wxCampaign.setStatus(0); wxCampaign.setTenantId(getTenantId()); @@ -73,6 +85,8 @@ public class WxCampaignController extends BaseController if(StringUtils.isNotBlank(wxCampaign.getCouponIds())) { String[] arys = wxCampaign.getCouponIds().split(","); wxCampaign.setCouponIds(JSON.toJSONString(arys)); + }else { + wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0])); } wxCampaignService.saveOrUpdate(wxCampaign); return new ResultData(); @@ -92,18 +106,13 @@ public class WxCampaignController extends BaseController public ResultData findById(Long id) { WxCampaign wxCampaign = wxCampaignService.getById(id); if (wxCampaign != null) { - List list = new ArrayList<>(); - List templist = JSON.parseArray(wxCampaign.getCouponIds(), String.class); - for (String temp : templist - ) { - list.add(Long.parseLong(temp)); - } - WxCoupon wxCoupon = new WxCoupon(); - wxCoupon.setTenantId(getTenantId()); - wxCoupon.setIds(list); - wxCoupon.setStatus(0); - List couponlist = wxCouponService.findList(wxCoupon); - wxCampaign.setCoupons(couponlist); + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setTenantId(getTenantId()); + wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); + wxCouponChannel.setSubTargetId(wxCampaign.getId()); + wxCouponChannel.setStatus(0); + List couponList = wxCouponChannelService.listAPI(wxCouponChannel); + wxCampaign.setCoupons(couponList); } return new ResultData(Result.SUCCESS, "查询成功", wxCampaign); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCarCallBackController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCarCallBackController.java index 4a6b4f4da..3307ae6d4 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCarCallBackController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCarCallBackController.java @@ -145,7 +145,8 @@ public class WxCarCallBackController extends BaseController return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误"+paramMap.toString()); } - // TODO 发起 营销 -- 短信 + // TODO 如果此车关联了停车优免券,自动把优免券设为已使用 + return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java index dc320a020..2dcfbcf0c 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java @@ -6,20 +6,24 @@ import com.alibaba.fastjson.JSONObject; import com.simple.common.ErrorCode; import com.simple.common.Result; import com.simple.common.ResultData; +import com.simple.domain.dto.WxCounponDto; +import com.simple.domain.dto.WxCouponCarDto; import com.simple.domain.po.*; +import com.simple.domain.vo.WxCouponCarVo; import com.simple.enums.EnumCarCmd; import com.simple.enums.EnumCarVendor; -import com.simple.service.WxCUserCarService; -import com.simple.service.WxCarCmdLogService; -import com.simple.service.WxMerchantService; -import com.simple.service.WxParkService; +import com.simple.enums.EnumCouponStatus; +import com.simple.service.*; import com.simple.utils.ETCPUtil; import com.simple.utils.TJDCarUtil; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import org.apache.poi.hmef.attribute.MAPIAttribute; +import org.omg.PortableInterceptor.INACTIVE; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -50,6 +54,12 @@ public class WxCarController extends BaseController @Autowired WxCarCmdLogService wxCarCmdLogService; + @Autowired + WxCouponService wxCouponService; + + @Autowired + WxCouponCarService wxCouponCarService; + private WxPark getCurrentPark(MallUserInfo user) { WxPark parkQ = new WxPark(); parkQ.setTenantId(user.getTenantId()); @@ -142,6 +152,10 @@ public class WxCarController extends BaseController businessId = objParams.getString("businessId"); } String ret = etcp.getBCouponList(url, merchantNo, merchantKey, version, parkId, businessId); + if (ret == null) { + logger.error("quanTemplate failed, 优免券模板未发现"); + return new ResultData(ErrorCode.ETCP_CMD_FAIL.getCode(), "获取优免券模板异常"); + } JSONObject retObj = JSON.parseObject(ret); if (retObj.getIntValue("code") == 0) { return new ResultData(retObj.getJSONObject("data")); @@ -167,4 +181,154 @@ public class WxCarController extends BaseController businessId = objParams1.getString("businessId"); return businessId; } + + @ApiOperation("新增停车券接口") + @PostMapping("save") + public ResultData save(@RequestBody WxCouponCarVo coupon) { + logger.info(coupon.toString()); + //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + // Save to wx_counpon + Date curDate = new Date(); + MallUserInfo user = getUser(); + // check 同一个模板的券分配额是否超了 + if (StringUtils.isBlank(coupon.getVendorParams())) { + logger.error("请填充停车厂商优免券参数"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "停车厂商参数为空"); + } + JSONObject vendorParamsObj = JSON.parseObject(coupon.getVendorParams()); + Long templateId = vendorParamsObj.getLong("id"); + Integer amount = vendorParamsObj.getInteger("amount"); + Integer avaliavleNum = vendorParamsObj.getInteger("avaliavleNum"); + Integer amtCount = wxCouponCarService.getAmtCountByTemplateId(templateId); + Integer availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); + if (amtCount >= amount) { + logger.error("已达到停车厂商优免券数量限制"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); + } + if (availCount >= avaliavleNum) { + logger.error("已达到停车厂商优免券数量限制"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); + } + // check End + + + WxCoupon wxCoupon = new WxCoupon(); + wxCoupon.setTenantId(user.getTenantId()); + wxCoupon.setMerchantId(coupon.getMerchantId()); + if(StringUtils.isNotEmpty(coupon.getSalePriceStr())){ + wxCoupon.setSalePrice((int)Double.parseDouble(coupon.getSalePriceStr())*100); + } + if(StringUtils.isNotEmpty(coupon.getUsePriceStr())){ + wxCoupon.setUsePrice((int)Double.parseDouble(coupon.getUsePriceStr())*100); + } + if(StringUtils.isNotEmpty(coupon.getPriceStr())){ + wxCoupon.setPrice((int)Double.parseDouble(coupon.getPriceStr())*100); + } + if(StringUtils.isNotBlank(coupon.getBusiness())) { + String[] arys = coupon.getBusiness().split(","); + wxCoupon.setBusiness(JSON.toJSONString(arys)); + } + wxCoupon.setType(coupon.getType()); + wxCoupon.setCoverImg(coupon.getCoverImg()); + wxCoupon.setTitle(coupon.getTitle()); + wxCoupon.setSubTitle(coupon.getSubTitle()); + wxCoupon.setUseLimitQuantity(coupon.getUseLimitQuantity()); + wxCoupon.setTargetAd(coupon.getTargetAd()); + wxCoupon.setSendType(coupon.getSendType()); + wxCoupon.setValidType(coupon.getValidType()); + wxCoupon.setValidStartDate(coupon.getValidStartDate()); + wxCoupon.setValidEndDate(coupon.getValidEndDate()); + wxCoupon.setValidDays(coupon.getValidDays()); + wxCoupon.setDetail(coupon.getDetail()); + wxCoupon.setUnit(coupon.getUnit()); + wxCoupon.setRemainInventory(coupon.getRemainInventory()); + wxCoupon.setInventory(coupon.getInventory()); + wxCoupon.setRemark(coupon.getRemark()); + wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); + wxCoupon.setCreateDate(curDate); + wxCoupon.setUpdateDate(curDate); + wxCoupon.setChannels(""); + Long id = wxCouponService.saveOrUpdate(wxCoupon); + + // Save to wx_coupon_car + WxCouponCar couponCar = new WxCouponCar(); + couponCar.setId(id); + couponCar.setTenantId(user.getTenantId()); + couponCar.setMerchantId(coupon.getMerchantId()); + + WxPark park = getCurrentPark(user); + couponCar.setParkId(park.getId()); + couponCar.setVendorType(park.getVendorType()); + couponCar.setVendorParams(coupon.getVendorParams()); + couponCar.setCreateDate(curDate); + couponCar.setUpdateDate(curDate); + WxCouponCar newCouponCar = wxCouponCarService.getById(couponCar.getId()); + if (newCouponCar == null) { + wxCouponCarService.save(couponCar); + } else { + wxCouponCarService.update(couponCar); + } + + + return new ResultData(id); + } + + + @ApiOperation("优免券模板已分配总数") + @GetMapping("/templateAmtCount") + @ApiImplicitParams({ + @ApiImplicitParam(name="templateId",value="模板ID",dataType="Long", paramType = "query",required=true)}) + public ResultData getTemplateAmountSum(Long templateId) { + Map map = new HashMap(); + Integer amountCount = 0; + try { + amountCount = wxCouponCarService.getAmtCountByTemplateId(templateId); + } catch (Exception e) { + logger.error(e.getMessage()); + } + map.put("amountCount", amountCount); + return new ResultData(map); + } + + @ApiOperation("优免券模板库存总数") + @GetMapping("/templateAvaiCount") + @ApiImplicitParams({ + @ApiImplicitParam(name="templateId",value="模板ID",dataType="Long", paramType = "query",required=true)}) + public ResultData getTemplateAvailSum(Long templateId) { + Map map = new HashMap(); + Integer availCount = 0; + try { + availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); + } catch (Exception e) { + logger.error(e.getMessage()); + } + map.put("availCount", availCount); + return new ResultData(map); + } + + @ApiOperation("停车券detail") + @GetMapping("/detail") + public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) { + MallUserInfo user = getUser(); + coupon.setTenantId(user.getTenantId()); + try { + WxCouponCarVo couponCarVo = wxCouponCarService.getByCoupon(coupon); + if (couponCarVo != null) { + WxCouponCarDto dto = new WxCouponCarDto(); + org.springframework.beans.BeanUtils.copyProperties(couponCarVo, dto); + WxMerchant merchant = wxMerchantService.getById(couponCarVo.getMerchantId()); + dto.setWxMerchant(merchant); + return new ResultData(dto); + } else { + return new ResultData(ErrorCode.COUPON_IS_EMPTY); + } + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(ErrorCode.DB_FAIL.getCode(), e.getMessage()); + } + + } + + } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java index 6da6ef31d..bd347e99e 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java @@ -40,14 +40,14 @@ public class WxCouponCarController extends BaseController public ResultData add(@RequestBody WxCouponCar wxCouponCar) { //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.save(wxCouponCar); return new ResultData(); } @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody WxCouponCar wxCouponCar) { - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.update(wxCouponCar); return new ResultData(); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java index b86ea8ad5..ae2057233 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -1,7 +1,10 @@ package com.simple.controller; +import com.alibaba.fastjson.JSON; import com.simple.domain.dto.WxCouponChannelDto; import com.simple.domain.po.MallUserInfo; +import com.simple.domain.po.WxChannel; +import com.simple.domain.vo.WxCouponChannelVo; import io.swagger.annotations.Api; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +20,8 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import java.util.ArrayList; +import java.util.List; @RestController @@ -41,7 +46,8 @@ public class WxCouponChannelController extends BaseController wxCouponChannel.setStatus(null); } wxCouponChannel.setTenantId(getUser().getTenantId()); - final PageInfo page = wxCouponChannelService.listAsPage(wxCouponChannel, pageNum, pageSize); + wxCouponChannel.setSortColumns(WxCouponChannel.Field.Id_DESC); + final PageInfo page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); return new ResultData(page); } @@ -51,6 +57,23 @@ public class WxCouponChannelController extends BaseController @PostMapping("update") public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { wxCouponChannel.setTenantId(getUser().getTenantId()); + if(wxCouponChannel.getCouponId()!=null&&wxCouponChannel.getStatus()!=null){ + WxCouponChannel orignal = wxCouponChannelService.getById(wxCouponChannel.getId()); + if(orignal.getStatus()==1&&wxCouponChannel.getStatus()==0){ + //查找是否该券 在该频道有其他上架 + WxCouponChannel query = new WxCouponChannel(); + query.setTenantId(orignal.getTenantId()); + query.setCouponId(orignal.getCouponId()); + query.setStatus(0);//已上架 + query.setTargetAd(orignal.getTargetAd()); + List list = wxCouponChannelService.listAsPage(query,1,1).getList(); + if(list!=null&&list.size()>0){ + //不能修改 + return new ResultData(Result.ERROR,"不允许同一个券,多个投放"); + } + } + + } wxCouponChannelService.saveOrUpdate(wxCouponChannel); return new ResultData(); } @@ -76,10 +99,29 @@ public class WxCouponChannelController extends BaseController String[] ids = wxCouponChannelDto.getCouponIds().split(","); String[] channelId = wxCouponChannelDto.getChannelId().split(","); MallUserInfo user = getUser(); - wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime()); - return new ResultData(); + return wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime()); + } + + @ApiOperation("根据id查询接口") + @GetMapping("/findChannelByCouponId") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData findChannelByCouponId(Long id) { + List channellist = new ArrayList<>(); + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setTenantId(getTenantId()); + wxCouponChannel.setStatus(0); + wxCouponChannel.setCouponId(id); + List list = wxCouponChannelService.listAsPage(wxCouponChannel,1,5).getList(); + if(list.isEmpty()){ + return new ResultData(Result.SUCCESS,"查询成功", ""); + } + for (WxCouponChannel temp:list) { + channellist.add(temp.getTargetAd()); + } + return new ResultData(Result.SUCCESS,"查询成功", JSON.toJSONString(channellist)); } + diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java index 4e47f2e65..e62b9a77c 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java @@ -56,12 +56,12 @@ public class WxCouponController extends BaseController public ResultData list(@ModelAttribute WxCoupon wxCoupon,Integer pageNum, Integer pageSize) { if (null == wxCoupon) wxCoupon = new WxCoupon(); wxCoupon.setTenantId(getTenantId()); + wxCoupon.setSortColumns(WxCoupon.Field.Id_DESC); PageInfo page = null; - if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) { - page = wxCouponService.findEnableList(wxCoupon, pageNum, pageSize); - }else { - page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize); - } + if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) + wxCoupon.setStatus(null); + page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize); + List wxCouponList = page.getList(); if(wxCouponList.isEmpty()){ @@ -170,10 +170,8 @@ public class WxCouponController extends BaseController if (null == wxCoupon) wxCoupon = new WxCoupon(); wxCoupon.setTenantId(getTenantId()); wxCoupon.setStatus(0); - PageInfo page = null; - page = wxCouponService.findCanSendList(wxCoupon, pageNum, pageSize); - return new ResultData(page); + return new ResultData(wxCouponService.listAsPage(wxCoupon, pageNum, pageSize)); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponOrderController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponOrderController.java index bd546f0ea..df6a5fcea 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponOrderController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponOrderController.java @@ -1,10 +1,7 @@ package com.simple.controller; -import com.github.pagehelper.PageInfo; -import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxCouponOrder; -import com.simple.domain.vo.WxCouponOrderBVo; import com.simple.service.WxCouponOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -12,7 +9,13 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; @RestController @RequestMapping("wxCouponOrder") @@ -32,8 +35,17 @@ public class WxCouponOrderController extends BaseController public ResultData list(@ModelAttribute WxCouponOrder wxCouponOrder, Integer pageNum, Integer pageSize) { if (wxCouponOrder == null) wxCouponOrder= new WxCouponOrder(); wxCouponOrder.setTenantId(getTenantId()); + wxCouponOrder.setSortColumns(WxCouponOrder.Field.Id_DESC); return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize); } + @RequestMapping("/exportData") + public void exportData(HttpServletRequest request, HttpServletResponse response){ + + wxCouponOrderService.exportData(request,response,getTenantId()); + + } + + } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxOrderController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxOrderController.java index 403d43c65..d7b0cbf24 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxOrderController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxOrderController.java @@ -33,6 +33,8 @@ public class WxOrderController extends BaseController }) public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { if (null == wxOrder) wxOrder = new WxOrder(); + wxOrder.setTenantId(getTenantId()); + wxOrder.setSortColumns(WxOrder.Field.Id_DESC); final PageInfo page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java index b3ed1663a..67fb91914 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxPayController.java @@ -10,12 +10,16 @@ import com.simple.service.WxRefundOrderService; import com.simple.utils.XmlUtil; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; +import org.jdom.JDOMException; +import org.springframework.http.MediaType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.Charset; -import java.util.LinkedHashMap; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; @@ -40,22 +44,36 @@ public class WxPayController extends BaseController { * @return 接收微信异步通知 * @throws Exception 可能产生的任何异常 */ - @RequestMapping(value = "/pay") - public String _payNotify(HttpServletRequest request) throws Exception { + @RequestMapping(value = "/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String _payNotify(HttpServletRequest request) throws IOException, JDOMException { + logger.info("微信支付回调"); + InputStream inStream = request.getInputStream(); + ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + outSteam.write(buffer, 0, len); + } + String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); + logger.info(resultxml); + + outSteam.close(); + inStream.close(); Map paramMap = null; + try { - String xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); - paramMap = WxPayment.xmlToMap(xml); - logger.info("payment wxpay, notify, param: " + paramMap.toString() ); + paramMap = WxPayment.xmlToMap(resultxml); + logger.info("微信支付回调, notify, param: " + paramMap.toString() ); String response = wxPayOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); - logger.info("payment wxpay, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); + logger.info("微信支付回调, notify success, req : " + paramMap.toString() + ", resp: " + response.toString()); return response; } catch (BizMessageException e) { if (paramMap == null) { - logger.error("payment wxpay, order create error, e: " + e.getMessage()); + logger.error("微信支付回调, order create error, e: " + e.getMessage()); } else { - logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); + logger.error("微信支付回调, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); } SortedMap resultMap = new TreeMap<>(); resultMap.put("return_code", "FAIL"); @@ -63,9 +81,9 @@ public class WxPayController extends BaseController { return XmlUtil.getRequestXml(resultMap); } catch (MallinkException e) { if (paramMap == null) { - logger.error("payment wxpay, order create error, e: " + e.getMessage()); + logger.error("微信支付回调, order create error, e: " + e.getMessage()); } else { - logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); + logger.error("微信支付回调, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); } SortedMap resultMap = new TreeMap<>(); resultMap.put("return_code", "FAIL"); @@ -73,9 +91,9 @@ public class WxPayController extends BaseController { return XmlUtil.getRequestXml(resultMap); } catch (Exception e) { if (paramMap == null) { - logger.error("payment wxpay, order create error, e: " + e.getMessage()); + logger.error("微信支付回调, order create error, e: " + e.getMessage()); } else { - logger.error("payment wxpay, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); + logger.error("微信支付回调, order create error, req: " + paramMap.toString() + ", e: " + e.getMessage()); } SortedMap resultMap = new TreeMap(); resultMap.put("return_code", "FAIL"); diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java new file mode 100644 index 000000000..a986655c5 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxUserChannelController.java @@ -0,0 +1,71 @@ +package com.simple.controller; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; + +import com.github.pagehelper.PageInfo; +import com.simple.common.Result; +import com.simple.common.ResultData; + +import com.simple.domain.po.WxUserChannel; +import com.simple.service.WxUserChannelService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("wxUserChannel") +public class WxUserChannelController extends BaseController +{ + @Autowired + private WxUserChannelService wxUserChannelService; + + private Logger logger = Logger.getLogger(WxUserChannelController.class); + + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData list(@ModelAttribute WxUserChannel wxUserChannel,Integer pageNum, Integer pageSize) { + if (null == wxUserChannel) wxUserChannel = new WxUserChannel(); + final PageInfo page = wxUserChannelService.listAsPage(wxUserChannel, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增接口") + @PostMapping("add") + public ResultData add(@RequestBody WxUserChannel wxUserChannel) { + //Assert.notNull(wxUserChannel.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + wxUserChannelService.saveOrUpdate(wxUserChannel); + return new ResultData(); + } + + @ApiOperation("根据id更新接口") + @PostMapping("update") + public ResultData update(@RequestBody WxUserChannel wxUserChannel) { + wxUserChannelService.saveOrUpdate(wxUserChannel); + return new ResultData(); + } + + @ApiOperation("根据id删除接口") + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + wxUserChannelService.deleteById(id); + return new ResultData(Result.SUCCESS, "删除成功", null); + } + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData findById(Long id) { + return new ResultData(Result.SUCCESS,"查询成功",wxUserChannelService.getById(id)); + } + + + +} diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxUserStructureController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxUserStructureController.java new file mode 100644 index 000000000..007fcf1dc --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxUserStructureController.java @@ -0,0 +1,260 @@ +package com.simple.controller; + +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +import com.alibaba.fastjson.JSON; +import com.github.pagehelper.PageInfo; +import com.simple.common.ResultData; +import com.simple.domain.dto.WxCuerBasicInfoDto; +import com.simple.domain.po.WxCUser; +import com.simple.domain.po.WxUserChannel; +import com.simple.domain.vo.UserStructureVo; +import com.simple.enums.EnumAgeInfo; +import com.simple.service.WxCUserBasicInfoService; +import com.simple.service.WxCUserService; +import com.simple.service.WxUserChannelService; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +@RestController +@Api(description="会员洞察") +@RequestMapping("userAnalysis") +public class WxUserStructureController extends BaseController{ + + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + + @Autowired + private WxCUserService wxCUserService; + @Autowired + private WxUserChannelService wxUserChannelService; + + @ApiOperation("查询会员性别结构") + @GetMapping("/findUserSexStructure") + public ResultData findUserSexStructure( + Date startTime,Date endTime + ) { + WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); + dto.setTenantId(getTenantId()); + dto.setStartTime(startTime); + if(endTime!=null) { + Calendar c = Calendar.getInstance(); + c.setTime(endTime); + c.add(Calendar.DAY_OF_YEAR, 1); + endTime =c.getTime(); + } + //保密 + dto.setSex(0); + long secrecy = getCount(dto); + dto.setSex(1); + long boy = getCount(dto); + dto.setSex(2); + long girl=getCount(dto); + Long all =secrecy+boy+girl; + List vos = new ArrayList<>(); + vos.add(getVo(boy, all, "男",1)); + vos.add(getVo(girl, all, "女",2)); + vos.add(getVo(secrecy, all, "保密",3)); + return new ResultData(vos); + } + + @ApiOperation("查询会员年龄结构") + @GetMapping("/findUserAgeStructure") + public ResultData findUserAgeStructure( Date startTime,Date endTime) { + WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); + dto.setTenantId(getTenantId()); + dto.setStartTime(startTime); + if(endTime!=null) { + Calendar c = Calendar.getInstance(); + c.setTime(endTime); + c.add(Calendar.DAY_OF_YEAR, 1); + endTime =c.getTime(); + } + dto.setEndTime(endTime); + long all =wxCUserBasicInfoService.findCountByAge(dto); + List vos = new ArrayList<>(); + Calendar c = Calendar.getInstance(); + for(EnumAgeInfo a:EnumAgeInfo.values()) { + c.clear(); + c.setTime(new Date()); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE,0); + c.set(Calendar.SECOND,0); + long count = getCountByAge(a, c,dto); + vos.add(getVo(count, all, a.getDesc(),a.getSortNum())); + } + return new ResultData(vos); + } + + @ApiOperation("查询会员数量") + @GetMapping("/findUserDataCount") + public ResultData findUserCount(Date startTime,Date endTime) { + WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); + dto.setTenantId(getTenantId()); + dto.setStartTime(startTime); + if(endTime!=null) { + Calendar c = Calendar.getInstance(); + c.setTime(endTime); + c.add(Calendar.DAY_OF_YEAR, 1); + endTime =c.getTime(); + } + long allCount = wxCUserService.findCount(dto);//总量 + + Calendar c = Calendar.getInstance(); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE,0); + c.set(Calendar.SECOND,0); + Date today = c.getTime(); + dto.setStartTime(today); + dto.setEndTime(null); + long todayCount= wxCUserService.findCount( dto);//今天新增 + List newCountVos = new ArrayList<>();//每日新增会员数 + int j=1; + for(int i=29;i>=0;i--) { + c.clear(); + c.setTime(today); + c.add(Calendar.DAY_OF_YEAR, -i); + dto.setStartTime(c.getTime()); + c.add(Calendar.DAY_OF_YEAR, 1); + dto.setEndTime(c.getTime()); + long count= wxCUserService.findCount(dto); + UserStructureVo vo = new UserStructureVo(); + vo.setSortNum(j); + j++; + vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); + vo.setCount(count); + newCountVos.add(vo); + } + List allCountVos = new ArrayList<>();//累计会员数 + c.clear(); + c.setTime(today); + c.add(Calendar.DAY_OF_YEAR, -30); + dto.setEndTime(c.getTime()); + dto.setStartTime(null); + long firstDay = wxCUserService.findCount(dto);//统计的第一天总数 + int i =0; + long sumCount=0; + for(UserStructureVo v:newCountVos) { + UserStructureVo vo = new UserStructureVo(); + sumCount+=v.getCount(); + vo.setCount(firstDay+sumCount); + vo.setName(v.getName()); + vo.setSortNum(i+1); + allCountVos.add(vo); + i++; + } + Map map = new HashMap<>(); + map.put("allCount", allCount);//累计会员总数 + map.put("todayCount", todayCount);//今日新增会员数 + map.put("allCountVos", allCountVos);//累计会员列表( 日期和数量list) + map.put("newCountVos", newCountVos);//新增会员列表(日期和数量list) + return new ResultData(map); + } + + @ApiOperation("拓客分析") + @GetMapping("/findUserByChannel") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData findUserByChannel(String channelName,Integer pageNum, Integer pageSize) { + List sceneList =null; + if(StringUtils.isNotBlank(channelName)) { + WxUserChannel c= new WxUserChannel(); + c.setChannelName(channelName); + PageInfo page = wxUserChannelService.listAsPage(c, 1, 100); + if(page.getSize()>0) { + sceneList = new ArrayList<>(); + for(WxUserChannel wuc:page.getList()) { + sceneList.add(wuc.getSceneAddress()); + } + } + } + PageInfo page = wxCUserService.listByChannel(sceneList, pageNum, pageSize); + for(WxCUser u:page.getList()) { + WxUserChannel c= new WxUserChannel(); + c.setSceneAddress(u.getSceneAddress()); + PageInfo uc = wxUserChannelService.listAsPage(c, 1, 1); + if(uc.getSize()>0) { + u.setChannelName(uc.getList().get(0).getChannelName()); + }else { + u.setChannelName("其他来源"); + } + } + + return new ResultData(page); + } + + @ApiOperation("获取用户所有渠道") + @GetMapping("/findAllUserChannel") + public ResultData findAllUserChannel() { + List channels=wxUserChannelService.findDistinctChannel(); + List vos = new ArrayList<>(); + for(WxUserChannel w:channels) { + vos.add(w.getChannelName()); + } + return new ResultData(vos); + } + + + private long getCountByAge(EnumAgeInfo a,Calendar c, WxCuerBasicInfoDto dto ) { + c.add(Calendar.YEAR, -a.getEnd()); + Date startTime = c.getTime(); + c.clear(); + c.setTime(startTime); + c.add(Calendar.YEAR,a.getEnd()-a.getStart()); + Date endTime = c.getTime(); + dto.setBirthStartTime(startTime); + dto.setBirthEndTime(endTime); + return wxCUserBasicInfoService.findCountByAge(dto); + } + + + + + //通过性别获取数量 + private long getCount(WxCuerBasicInfoDto dto) { + // wxCUserBasicInfoService.findCountBySex(dto) basic表与cuser表示对应的,先有cuser 才有basic + //所有这里不需要再去查basic + return wxCUserService.findCount(dto); + } + + private UserStructureVo getVo(long count,long all,String name,Integer num) { + UserStructureVo vo = new UserStructureVo(); + vo.setSortNum(num); + vo.setName(name); + vo.setCount(count); + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 + if(all>0) { + vo.setPercentage(nf.format(new Long(count).doubleValue()/new Long(all).doubleValue())); + }else { + vo.setPercentage("0.00%"); + } + return vo; + } + + +} diff --git a/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java new file mode 100644 index 000000000..55d345ad0 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java @@ -0,0 +1,55 @@ +package com.simple.schedule; + +import com.simple.common.IdWorker; +import com.simple.domain.po.WxCouponOrder; +import com.simple.domain.po.WxDateAmountRecord; +import com.simple.domain.po.WxMall; +import com.simple.domain.po.WxMerchant; +import com.simple.enums.EnumDateAmtType; +import com.simple.mapper.*; +import com.simple.service.WxDateAmountRecordService; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +public class CouponExpiringSchedule { + + private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class); + + + @Autowired + private WxMallMapper wxMallMapper; + + @Autowired + private WxCouponChannelMapper wxCouponChannelMapper; + + @Autowired + private WxCouponMapper wxCouponMapper; + + + + @Scheduled(cron = "0 30 0 * * ?") // 每天凌晨 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void couponExpiringSchedule() { + + + + } + + @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + public void couponChannelExpiringSchedule() { + + wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(); + wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); + } +} \ No newline at end of file diff --git a/mallinkService/src/main/java/com/simple/schedule/DaliyAmountSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/DaliyAmountSchedule.java similarity index 91% rename from mallinkService/src/main/java/com/simple/schedule/DaliyAmountSchedule.java rename to mallinkAdmin/src/main/java/com/simple/schedule/DaliyAmountSchedule.java index 2bc4b4550..4756c78a5 100644 --- a/mallinkService/src/main/java/com/simple/schedule/DaliyAmountSchedule.java +++ b/mallinkAdmin/src/main/java/com/simple/schedule/DaliyAmountSchedule.java @@ -5,13 +5,15 @@ import com.simple.domain.po.WxCouponOrder; import com.simple.domain.po.WxDateAmountRecord; import com.simple.domain.po.WxMall; import com.simple.domain.po.WxMerchant; +import com.simple.enums.EnumDateAmtType; import com.simple.mapper.*; import com.simple.service.WxDateAmountRecordService; -import com.simple.utils.*; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -42,6 +44,7 @@ public class DaliyAmountSchedule { @Scheduled(cron = "0 0 23 * * ?") // 每天晚上11点盘点 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public void daliyAmountSchedule() { @@ -80,7 +83,7 @@ public class DaliyAmountSchedule { dateMap.put("endDate", new Date()); dateMap.put("merchantID",merchant.getId()); - List list = wxCouponOrderMapper.findListOfUnverifiedByDate(dateMap); + List list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); int total_price = 0; for(WxCouponOrder couponOrder : list) { @@ -108,7 +111,7 @@ public class DaliyAmountSchedule { dateAmountRecord.setPayPrice(total_price); dateAmountRecord.setMerchantId(merchant.getId()); dateAmountRecord.setTenantId(merchant.getTenantId()); - dateAmountRecord.setType(0); + dateAmountRecord.setType(EnumDateAmtType.PAY_RECORD.getCode()); dateAmountRecord.setDate(now); dateAmountRecord.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK)); dateAmountRecord.setMonth(cal.get(Calendar.MONTH)); @@ -129,7 +132,7 @@ public class DaliyAmountSchedule { dateAmountRecord.setId(IdWorker.get().nextId()); dateAmountRecord.setPayPrice(total_price); - dateAmountRecord.setType(1); + dateAmountRecord.setType(EnumDateAmtType.VERIFY_RECORD.getCode()); wxDateAmountRecordService.saveDaliyAmount(dateAmountRecord); } diff --git a/mallinkService/src/main/java/com/simple/schedule/MsgSendingSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/MsgSendingSchedule.java similarity index 98% rename from mallinkService/src/main/java/com/simple/schedule/MsgSendingSchedule.java rename to mallinkAdmin/src/main/java/com/simple/schedule/MsgSendingSchedule.java index bb711d476..fc157bb55 100644 --- a/mallinkService/src/main/java/com/simple/schedule/MsgSendingSchedule.java +++ b/mallinkAdmin/src/main/java/com/simple/schedule/MsgSendingSchedule.java @@ -48,7 +48,7 @@ public class MsgSendingSchedule { public void sendmsg(WxMsg wxMsg){ //从短信配置中查询密钥 bid 等信息 WxMsgConfig wxMsgConfig = new WxMsgConfig(); - wxMsgConfig.setTenantId("1"); + wxMsgConfig.setTenantId(wxMsg.getTenantId()); List wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); if (wxMsgConfigs.size() == 0) return; wxMsgConfig = wxMsgConfigs.get(0); diff --git a/mallinkService/src/main/java/com/simple/schedule/OrderExpireSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/OrderExpireSchedule.java similarity index 100% rename from mallinkService/src/main/java/com/simple/schedule/OrderExpireSchedule.java rename to mallinkAdmin/src/main/java/com/simple/schedule/OrderExpireSchedule.java diff --git a/mallinkAdmin/src/main/java/com/simple/schedule/SchedulingConfig.java b/mallinkAdmin/src/main/java/com/simple/schedule/SchedulingConfig.java new file mode 100644 index 000000000..f8c5d0fff --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/schedule/SchedulingConfig.java @@ -0,0 +1,21 @@ +package com.simple.schedule; + +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +@Configuration +@EnableScheduling +public class SchedulingConfig implements SchedulingConfigurer { + + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); + scheduler.setPoolSize(10); + scheduler.initialize(); + taskRegistrar.setTaskScheduler(scheduler); + } + +} \ No newline at end of file diff --git a/mallinkAdmin/src/main/java/com/simple/schedule/WxAppVisitSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/WxAppVisitSchedule.java new file mode 100644 index 000000000..39c93d2b4 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/schedule/WxAppVisitSchedule.java @@ -0,0 +1,108 @@ +package com.simple.schedule; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.simple.domain.po.WxUserVisit; +import com.simple.service.WxUserVisitService; + +@Component +public class WxAppVisitSchedule { + + private Logger logger = Logger.getLogger(WxAppVisitSchedule.class); + + private static String token="https://api.weixin.qq.com/cgi-bin/token?"+ + "grant_type=client_credential&appid=APPID&secret=APPSECRET"; + + private static String visit = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token="; + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private WxUserVisitService wxUserVisitService; + + +// @Scheduled(cron = "0 */1 * * * *?") + @Scheduled(cron = "0 0 4 * * ? ") + public void start() { + try { + Calendar c =Calendar.getInstance(); + c.add(Calendar.DAY_OF_YEAR, -1); + Date time = c.getTime(); + String yesterday = new SimpleDateFormat("yyyyMMdd").format(time); + getData(yesterday); + }catch(Exception e) { + logger.error("获取微信访问数据失败",e); + } + } + + private void getData(String yesterday) throws Exception { + String accessToken = getAccessToken("wx8eb8275b78db4ede", "76c43df01296998d8ce12383f213ac10"); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + Map map = new HashMap(); + map.put("begin_date", yesterday); + map.put("end_date",yesterday); + RestTemplate restTemplate = new RestTemplate(); + HttpEntity> entity = new HttpEntity>(map, headers); + String reqUrl =visit+accessToken; + ResponseEntity responseEntity = restTemplate.postForEntity(reqUrl, entity, String.class); + logger.info("获取wx访问数据:"+JSON.toJSONString(responseEntity)); + if(responseEntity.hasBody()) { + String body = responseEntity.getBody(); + Map maps = (Map)JSON.parse(body); + JSONArray jSONArray = (JSONArray)maps.get("list"); + if(jSONArray==null || jSONArray.isEmpty()) { + logger.info("获取失败"); + return; + } + JSONObject jsonObject = jSONArray.getJSONObject(0); + Map itemMap = JSONObject.toJavaObject(jsonObject, Map.class); + //{"visit_uv":6,"stay_time_uv":1178.3333,"stay_time_session":115.9016,"ref_date":"20180828", + // "visit_depth":3.1311,"session_cnt":61,"visit_pv":645,"visit_uv_new":3} + logger.info(JSON.toJSONString(itemMap)); + WxUserVisit v = new WxUserVisit(); + v.setAppId("wx8eb8275b78db4ede"); + String time = itemMap.get("ref_date")+""; + Date date = new SimpleDateFormat("yyyyMMdd").parse(time); + v.setDayDate(date); + v.setRefDate(time); + v.setSessionCnt(Integer.valueOf(itemMap.get("session_cnt")+"")); + v.setVisitPv(Integer.valueOf(itemMap.get("visit_pv")+"")); + v.setVisitUv(Integer.valueOf(itemMap.get("visit_uv")+"")); + v.setVisitUvNew(Integer.valueOf(itemMap.get("visit_uv_new")+"")); + v.setStayTimeSession(itemMap.get("stay_time_session")+""); + v.setVisitDepth(itemMap.get("visit_depth")+""); + v.setStayTimeUv(itemMap.get("stay_time_uv")+""); + wxUserVisitService.saveOrUpdate(v); + } + + } + + private String getAccessToken(String appId,String appSecret) { +// return "13_rBo3ajS3jjd8OXZ2MLd4HfLrmt78gvaCeRtu-Xme0iC0fhs_lNS47aLPEwI8kfZQIMKnWYshY5wpaf2IoSI7tgVBm7WwVrm_Bg96J31VPKi8pEp8yB6JiTpDcWkpwv5GngiH2vDkwz7VHOsPLBYcAGAZPM"; + String url = token.replace("APPID", appId). + replace("APPSECRET", appSecret); + Map map = restTemplate.getForObject(url,Map.class); + logger.info("获取access_token返回:"+JSON.toJSONString(map)); + return (String)map.get("access_token"); + } + +} diff --git a/mallinkAdmin/src/main/resources/application.yml b/mallinkAdmin/src/main/resources/application.yml index bbe11e8d8..d0ab85172 100644 --- a/mallinkAdmin/src/main/resources/application.yml +++ b/mallinkAdmin/src/main/resources/application.yml @@ -39,4 +39,4 @@ mapper: - com.simple.common.CommonMapper pay: - real: false \ No newline at end of file + real: true \ No newline at end of file diff --git a/mallinkBApi/src/main/resources/application.yml b/mallinkBApi/src/main/resources/application.yml index 979ecee43..663167d37 100644 --- a/mallinkBApi/src/main/resources/application.yml +++ b/mallinkBApi/src/main/resources/application.yml @@ -39,4 +39,4 @@ mapper: - com.simple.common.CommonMapper pay: - real: false \ No newline at end of file + real: true \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCampaignController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCampaignController.java index f60988ad2..c28ef7d45 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCampaignController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCampaignController.java @@ -6,7 +6,11 @@ import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxCampaign; import com.simple.domain.po.WxCoupon; +import com.simple.domain.po.WxCouponChannel; +import com.simple.domain.vo.WxCouponChannelVo; +import com.simple.enums.EnumCouponChannelType; import com.simple.service.WxCampaignService; +import com.simple.service.WxCouponChannelService; import com.simple.service.WxCouponService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -31,6 +35,8 @@ public class WxCampaignController extends BaseController private WxCampaignService wxCampaignService; @Autowired private WxCouponService wxCouponService; + @Autowired + private WxCouponChannelService wxCouponChannelService; private Logger logger = Logger.getLogger(WxCampaignController.class); @@ -54,18 +60,13 @@ public class WxCampaignController extends BaseController public ResultData findById(Long id) { WxCampaign wxCampaign = wxCampaignService.getById(id); if (wxCampaign != null) { - List list = new ArrayList<>(); - List templist = JSON.parseArray(wxCampaign.getCouponIds(), String.class); - for (String temp : templist - ) { - list.add(Long.parseLong(temp)); - } - WxCoupon wxCoupon = new WxCoupon(); - wxCoupon.setTenantId(getTenantId()); - wxCoupon.setIds(list); - wxCoupon.setStatus(1); - List couponlist = wxCouponService.findList(wxCoupon); - wxCampaign.setCoupons(couponlist); + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setTenantId(getTenantId()); + wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); + wxCouponChannel.setSubTargetId(wxCampaign.getId()); + wxCouponChannel.setStatus(0); + List couponList = wxCouponChannelService.listAPI(wxCouponChannel); + wxCampaign.setCoupons(couponList); } return new ResultData(Result.SUCCESS, "查询成功", wxCampaign); } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java index c0a37482a..092b6460e 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java @@ -1,73 +1,68 @@ package com.simple.controller; -import io.swagger.annotations.Api; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.*; - import com.github.pagehelper.PageInfo; import com.simple.common.Result; import com.simple.common.ResultData; - import com.simple.domain.po.WxCouponCar; import com.simple.service.WxCouponCarService; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("wxCouponCar") @Api(description = "停车发券相关接口") -public class WxCouponCarController extends BaseController -{ - @Autowired +public class WxCouponCarController extends BaseController { + @Autowired private WxCouponCarService wxCouponCarService; private Logger logger = Logger.getLogger(WxCouponCarController.class); - - @ApiOperation("分页列表接口") + + @ApiOperation("分页列表接口") @GetMapping("list") - @ApiImplicitParams({ - @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), - @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) - public ResultData list(@ModelAttribute WxCouponCar wxCouponCar,Integer pageNum, Integer pageSize) { - if (null == wxCouponCar) wxCouponCar = new WxCouponCar(); + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute WxCouponCar wxCouponCar, Integer pageNum, Integer pageSize) { + if (null == wxCouponCar) wxCouponCar = new WxCouponCar(); final PageInfo page = wxCouponCarService.listAsPage(wxCouponCar, pageNum, pageSize); return new ResultData(page); } - @ApiOperation("新增接口") + @ApiOperation("新增接口") @PostMapping("add") public ResultData add(@RequestBody WxCouponCar wxCouponCar) { //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.save(wxCouponCar); return new ResultData(); } @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody WxCouponCar wxCouponCar) { - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.update(wxCouponCar); return new ResultData(); } @ApiOperation("根据id删除接口") @GetMapping("/del") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData delete(Long id) { wxCouponCarService.deleteById(id); return new ResultData(Result.SUCCESS, "删除成功", null); } - - @ApiOperation("根据id查询接口") - @GetMapping("/findById") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData findById(Long id) { - return new ResultData(Result.SUCCESS,"查询成功",wxCouponCarService.getById(id)); + return new ResultData(Result.SUCCESS, "查询成功", wxCouponCarService.getById(id)); } - - - + + } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponChannelController.java index 5dda26037..13cd9183c 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -38,18 +38,9 @@ public class WxCouponChannelController extends BaseController if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); wxCouponChannel.setTenantId(getTenantId()); wxCouponChannel.setStatus(0); + wxCouponChannel.setSortColumns(WxCouponChannel.Field.CreateDate_DESC); final PageInfo page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); return new ResultData(page); } - - @ApiOperation("根据id查询接口") - @GetMapping("/findById") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) - public ResultData findById(Long id) { - return new ResultData(Result.SUCCESS,"查询成功",wxCouponChannelService.getById(id)); - } - - - } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java index 082651d95..d42da68d7 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java @@ -4,6 +4,7 @@ import com.simple.common.ErrorCode; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponCVo; import io.swagger.annotations.Api; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; @@ -28,10 +29,50 @@ public class WxCouponController extends BaseController { @Autowired private WxCouponService wxCouponService; - @ApiOperation("根据id查询接口") + @ApiOperation("根据id(coupon)查询接口") + @GetMapping("/detailC") + @ApiImplicitParams({ + @ApiImplicitParam(name = "couponId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) + public ResultData detail(String couponId) { + if (StringUtils.isBlank(couponId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); + } + Long couponIdL = 0L; + try { + couponIdL = Long.valueOf(couponId); + } catch (NumberFormatException e) { + logger.error("id转换失败" + couponId); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponId); + } + WxCoupon wxCoupon = new WxCoupon(); + wxCoupon.setId(couponIdL); + wxCoupon.setTenantId(getTenantId()); + WxCouponCVo wxCouponCVo = wxCouponService.selectDetailForCUser(wxCoupon); + if (wxCouponCVo == null) + return new ResultData(ErrorCode.COUPON_IS_EMPTY); + + return new ResultData(wxCouponCVo); + + } + + + @ApiOperation("根据id(couponChannel)查询接口") @GetMapping("/detail") - public ResultData detail(@ModelAttribute WxCouponChannel wxCouponChannel) { - if(wxCouponChannel == null) wxCouponChannel = new WxCouponChannel(); + @ApiImplicitParams({ + @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) + public ResultData detailC(String couponChannelId) { + if (StringUtils.isBlank(couponChannelId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); + } + Long couponChannelIdL = 0L; + try { + couponChannelIdL = Long.valueOf(couponChannelId); + } catch (NumberFormatException e) { + logger.error("id转换失败" + couponChannelId); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); + } + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setId(couponChannelIdL); wxCouponChannel.setTenantId(getTenantId()); WxCouponCVo wxCouponCVo = wxCouponService.selectDetailForCUser(wxCouponChannel); if (wxCouponCVo == null) diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java index b2aa9231c..9f7cbc007 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java @@ -7,6 +7,7 @@ import com.simple.common.ResultData; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxCouponOrder; import com.simple.domain.vo.WxCouponOrderCVo; +import com.simple.enums.EnumCouponOrderStatus; import com.simple.exception.MallinkException; import com.simple.service.WxCouponOrderService; import io.swagger.annotations.Api; @@ -62,14 +63,21 @@ public class WxCouponOrderController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), - @ApiImplicitParam(name = "couponOrderStatus", value="券状态状态:0,待使用 1,已核销 2,已过期 3,已作废", dataType="int", paramType = "query",required=false) }) - public ResultData list(Integer couponOrderStatus, Integer pageNum, Integer pageSize) { + public ResultData list(@ModelAttribute WxCouponOrder wxCouponOrder, Integer pageNum, Integer pageSize) { if(pageNum == null || pageSize == null) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } - return wxCouponOrderService.listCUserVoAsPage(getUser().getId(), couponOrderStatus, pageNum, pageSize); + if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrder(); + wxCouponOrder.setCUserId(getUser().getId()); + if (wxCouponOrder.getCouponOrderStatus() == null) + wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); + else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()) + wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); + else + wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); + return wxCouponOrderService.listCUserVoAsPage(wxCouponOrder, pageNum, pageSize); } @ApiOperation(value = "卡券详情接口") diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxMallController.java b/mallinkCApi/src/main/java/com/simple/controller/WxMallController.java new file mode 100644 index 000000000..9e2679de3 --- /dev/null +++ b/mallinkCApi/src/main/java/com/simple/controller/WxMallController.java @@ -0,0 +1,71 @@ +package com.simple.controller; + +import com.simple.annotation.AuthIgnore; +import com.simple.common.ErrorCode; +import com.simple.common.Result; +import com.simple.common.ResultData; +import com.simple.domain.po.WxAppinfo; +import com.simple.domain.po.WxMall; +import com.simple.service.WxAppinfoService; +import com.simple.service.WxMallService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/api/mall") +@Api(description="商场信息相关接口") +public class WxMallController extends BaseController { + private Logger logger = Logger.getLogger(WxMallController.class); + + @Autowired + private WxMallService wxMallService; + + @Autowired + private WxAppinfoService wxAppinfoService; + + + @AuthIgnore + @ApiOperation("根据appId获取") + @GetMapping("/getAppIcon") + @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) + public ResultData getAppIcon(String appId) { + WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); + if (appInfo == null) { + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + WxMall mall = wxMallService.getByTenantId(appInfo.getTenantId()); + if (mall==null) { + return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); + } + Map resultMap = new HashMap(); + resultMap.put("mallImgUrl", mall.getImgUrl()); + resultMap.put("mallName", mall.getName()); + return new ResultData(Result.SUCCESS, "查询成功", resultMap); + } + + @ApiOperation("根据appId获取") + @GetMapping("/mallInfo") + @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) + public ResultData getMallInfo(String appId) { + WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); + if (appInfo == null) { + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + WxMall mall = wxMallService.getByTenantId(appInfo.getTenantId()); + if (mall==null) { + return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); + } + return new ResultData(Result.SUCCESS, "查询成功", mall); + } + + +} diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java b/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java index 05ee45d5e..7957e3152 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java @@ -88,32 +88,53 @@ public class WxOrderController extends BaseController { @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}") @PostMapping("save") public ResultData saveOrder(@RequestBody Map paramMap) { + logger.info("OrderSave: " + paramMap.toString()); //Assert.notNull(wxOrders.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); String couponChannelIdStr = paramMap.get("couponChannelId"); String couponIdStr = paramMap.get("couponId"); + /* + // TODO 修改支持banner图,获取不到couponChannelId问题 if (StringUtils.isBlank(couponChannelIdStr)) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空"); } + */ Long couponChannelId = 0L, couponId = 0L; - try { - couponChannelId = Long.valueOf(couponChannelIdStr); - } catch (NumberFormatException e) { - logger.error("couponChannelId convert error, " + couponChannelIdStr + ", e:" + e.getMessage()); - return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponChannelId: " + couponChannelIdStr + ", e:" + e.getMessage()); - } - WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId); - if (wxCouponChannel == null) { - logger.error("couponChannelId convert error, " + couponChannelIdStr); - return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "找不到发布的频道"); + + if (!StringUtils.isBlank(couponChannelIdStr)) { + try { + couponChannelId = Long.valueOf(couponChannelIdStr); + } catch (NumberFormatException e) { + logger.error("couponChannelId convert error, " + couponChannelIdStr + ", e:" + e.getMessage()); + return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponChannelId: " + couponChannelIdStr + ", e:" + e.getMessage()); + } + WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId); + if (wxCouponChannel == null) { + logger.error("couponChannelId convert error, " + couponChannelIdStr); + return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "找不到发布的频道"); + } + if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { + logger.error("此券已下架:" + couponChannelIdStr); + return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), "此券已下架"); + } + if (StringUtils.isBlank(couponIdStr)) { + couponId = wxCouponChannel.getCouponId(); + } } - if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { - logger.error("此券已下架:" + couponChannelIdStr); - return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), "此券已下架"); + if (couponId <= 0 && !StringUtils.isBlank(couponIdStr)) { + try { + couponId = Long.valueOf(couponIdStr); + } catch (NumberFormatException e) { + logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage()); + return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage()); + } } - if (StringUtils.isBlank(couponIdStr)) { - couponId = wxCouponChannel.getCouponId(); + + if (couponId <= 0) { + logger.error("couponChannelId或者couponId不能为空"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId或者couponId不能为空"); } + WxCUser user = getUser(); try { @@ -197,15 +218,27 @@ public class WxOrderController extends BaseController { // c端用户应该只能看到自己的订单 if (wxOrder == null) wxOrder = new WxOrder(); wxOrder.setCUserId(getUser().getId()); + wxOrder.setSortColumns(WxOrder.Field.CreateDate_DESC); final PageInfo page = wxOrderService.listCUserVoAsPage(wxOrder, pageNum, pageSize); return new ResultData(page); } @ApiOperation("订单详情接口") @GetMapping("detail") - public ResultData list(@ModelAttribute WxOrder wxOrder) { + @ApiImplicitParams({ + @ApiImplicitParam(name="orderId",value="订单id",dataType="String", paramType = "query",required=true) + }) + public ResultData detail(String orderId) { // c端用户应该只能看到自己的订单细节 - if (wxOrder == null) wxOrder = new WxOrder(); + WxOrder wxOrder = new WxOrder(); + Long id = 0L; + try { + id = Long.valueOf(orderId); + } catch (NumberFormatException e) { + logger.error("parse orderId failed"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "订单ID转换异常"); + } + wxOrder.setId(id); wxOrder.setCUserId(getUser().getId()); WxOrderCVo wxOrderCVo = wxOrderService.detailCUserVo(wxOrder); if (wxOrderCVo == null) diff --git a/mallinkCApi/src/main/resources/application.yml b/mallinkCApi/src/main/resources/application.yml index cfcc52773..6f51968a0 100644 --- a/mallinkCApi/src/main/resources/application.yml +++ b/mallinkCApi/src/main/resources/application.yml @@ -39,4 +39,4 @@ mapper: - com.simple.common.CommonMapper pay: - real: false + real: true diff --git a/mallinkService/src/main/java/com/simple/common/ErrorCode.java b/mallinkService/src/main/java/com/simple/common/ErrorCode.java index 48c82883e..b66a68d66 100644 --- a/mallinkService/src/main/java/com/simple/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/simple/common/ErrorCode.java @@ -71,6 +71,7 @@ public enum ErrorCode{ COUPON_IS_NOT_FREE(2021, "券不免费"), COUPON_IS_TAKE_OFF(2022, "此券已下架"), + COUPON_CHANNEL_IS_EXISTED(2023, "券已投放过"), /** * 车流 2040 */ @@ -83,6 +84,7 @@ public enum ErrorCode{ ETCP_STOP_FEE_FAIL(2054, "ETCP停车费失败"), ETCP_QUAN_TEMP_FAIL(2055, "ETCP优免券模板失败"), ETCP_QUAN_SEND_FAIL(2056, "ETCP优免券发放失败"), + ETCP_CMD_FAIL(2057, "ETCP网络异常"), TJD_BIND_FAIL(2060,"TJD绑车牌失败"), TJD_UNBIND_FAIL(2061,"TJD解绑车牌失败"), @@ -99,10 +101,14 @@ public enum ErrorCode{ ORDER_IS_FAIL(3002, "订单失败"), ORDER_IS_NOT_FIND(3003, "订单不存在"), ORDER_IS_NOT_PAY(3004, "订单已不能进行支付"), + ORDER_SAVE_ERR(3005,"订单保存失败"), + ORDER_UPDATE_ERR(3006,"订单更新失败"), + REMAIN_BACK_FAIL(3007, "库存恢复失败"), /** * 卡券 */ + COUPON_ORDER_SAVE_ERR(3999, "卡券保存失败"), COUPON_ORDER_IS_NULL(4000, "卡券不存在"), COUPON_ORDER_IS_USED(4001, "卡券已核销"), COUPON_ORDER_IS_OVER_TIME(4002, "卡券已过期"), diff --git a/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java b/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java new file mode 100644 index 000000000..86c5aa8a3 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java @@ -0,0 +1,37 @@ +package com.simple.domain.dto; + +import java.util.Date; + +/** + * Created by syf on 2018/8/30. + */ +public class MarkingCouponDataReportDto { + + private Date startTime; + private Date endTime; + private Integer type; + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/dto/MarkingSceneDataReportDto.java b/mallinkService/src/main/java/com/simple/domain/dto/MarkingSceneDataReportDto.java new file mode 100644 index 000000000..1998c2498 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/dto/MarkingSceneDataReportDto.java @@ -0,0 +1,36 @@ +package com.simple.domain.dto; + +import java.util.Date; + +/** + * Created by syf on 2018/8/30. + */ +public class MarkingSceneDataReportDto { + private Date startTime; + private Date endTime; + private Integer type; + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/dto/WxCouponCarDto.java b/mallinkService/src/main/java/com/simple/domain/dto/WxCouponCarDto.java new file mode 100644 index 000000000..895cb9f42 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/dto/WxCouponCarDto.java @@ -0,0 +1,20 @@ +package com.simple.domain.dto; + +import com.simple.domain.po.WxMerchant; +import com.simple.domain.vo.WxCouponCarVo; + +import javax.persistence.Transient; + +public class WxCouponCarDto extends WxCouponCarVo { + private static final long serialVersionUID = -5721410270215370223L; + @Transient + private WxMerchant wxMerchant; + + public WxMerchant getWxMerchant() { + return wxMerchant; + } + + public void setWxMerchant(WxMerchant wxMerchant) { + this.wxMerchant = wxMerchant; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java b/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java index aa53e96c7..cc72ec3e8 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java @@ -116,6 +116,20 @@ public class WxCUser implements Serializable { /*用户过期时间**/ @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") private Date expireTime; + + //渠道名称 + @Transient + private String channelName; + + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + public String getTenantId() { return tenantId; } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java b/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java index ced30a5d3..0f1d35af8 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCampaign.java @@ -1,5 +1,7 @@ package com.simple.domain.po; +import com.simple.domain.vo.WxCouponChannelVo; + import javax.persistence.*; import java.util.*; import java.math.*; @@ -20,13 +22,13 @@ public class WxCampaign implements Serializable { @Transient protected String sortColumns; @Transient - protected List coupons; + protected List coupons; - public List getCoupons() { + public List getCoupons() { return coupons; } - public void setCoupons(List coupons) { + public void setCoupons(List coupons) { this.coupons = coupons; } @@ -211,23 +213,23 @@ public class WxCampaign implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") - ,CoverImg_ASC("`coverImg` ASC"),CoverImg_DESC("`coverImg` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,CoverImg_ASC("`cover_img` ASC"),CoverImg_DESC("`cover_img` DESC") ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") - ,SubTitle_ASC("`subTitle` ASC"),SubTitle_DESC("`subTitle` DESC") - ,UsePrice_ASC("`usePrice` ASC"),UsePrice_DESC("`usePrice` DESC") - ,DiscountPrice_ASC("`discountPrice` ASC"),DiscountPrice_DESC("`discountPrice` DESC") + ,SubTitle_ASC("`sub_title` ASC"),SubTitle_DESC("`sub_title` DESC") + ,UsePrice_ASC("`use_price` ASC"),UsePrice_DESC("`use_price` DESC") + ,DiscountPrice_ASC("`discount_price` ASC"),DiscountPrice_DESC("`discount_price` DESC") ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") - ,ValidStartDate_ASC("`validStartDate` ASC"),ValidStartDate_DESC("`validStartDate` DESC") - ,ValidEndDate_ASC("`validEndDate` ASC"),ValidEndDate_DESC("`validEndDate` DESC") - ,ImgDetail_ASC("`imgDetail` ASC"),ImgDetail_DESC("`imgDetail` DESC") + ,ValidStartDate_ASC("`valid_start_date` ASC"),ValidStartDate_DESC("`valid_start_date` DESC") + ,ValidEndDate_ASC("`valid_end_date` ASC"),ValidEndDate_DESC("`valid_end_date` DESC") + ,ImgDetail_ASC("`img_detail` ASC"),ImgDetail_DESC("`img_detail` DESC") ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") - ,CouponIds_ASC("`couponIds` ASC"),CouponIds_DESC("`couponIds` DESC") - ,MechantId_ASC("`mechantId` ASC"),MechantId_DESC("`mechantId` DESC") - ,SortNum_ASC("`sortNum` ASC"),SortNum_DESC("`sortNum` DESC") + ,CouponIds_ASC("`coupon_ids` ASC"),CouponIds_DESC("`coupon_ids` DESC") + ,MechantId_ASC("`mechant_id` ASC"),MechantId_DESC("`mechantId` DESC") + ,SortNum_ASC("`sort_num` ASC"),SortNum_DESC("`sortNum` DESC") ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") - ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") - ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") + ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") + ,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC") ; private String value; Field(String value){ @@ -260,7 +262,7 @@ public class WxCampaign implements Serializable { sb.append(","); sb.append(fields[k].toString()); } - + this.sortColumns = sb.toString(); } public void setSortColumns(String sortColumns) diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java index b654829dc..79584bb4f 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java @@ -105,6 +105,9 @@ public class WxCoupon implements Serializable { /*面额**/ @io.swagger.annotations.ApiModelProperty(value="面额",name="price") private Integer price; + /*单位**/ + @io.swagger.annotations.ApiModelProperty(value="单位(0:rmb分 1:小时)",name="unit") + private Integer unit; /*剩余库存**/ @io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory") private Integer remainInventory; @@ -228,6 +231,12 @@ public class WxCoupon implements Serializable { public void setPrice(Integer _price) { price = _price; } + public Integer getUnit() { + return unit; + } + public void setUnit(Integer _unit) { + unit = _unit; + } public Integer getRemainInventory() { return remainInventory; } @@ -318,31 +327,31 @@ public class WxCoupon implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") - ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC") ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") - ,CoverImg_ASC("`coverImg` ASC"),CoverImg_DESC("`coverImg` DESC") + ,CoverImg_ASC("`cover_img` ASC"),CoverImg_DESC("`cover_img` DESC") ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") - ,SubTitle_ASC("`subTitle` ASC"),SubTitle_DESC("`subTitle` DESC") - ,SalePrice_ASC("`salePrice` ASC"),SalePrice_DESC("`salePrice` DESC") - ,UsePrice_ASC("`usePrice` ASC"),UsePrice_DESC("`usePrice` DESC") - ,UseLimitQuantity_ASC("`useLimitQuantity` ASC"),UseLimitQuantity_DESC("`useLimitQuantity` DESC") - ,TargetAd_ASC("`targetAd` ASC"),TargetAd_DESC("`targetAd` DESC") - ,SendType_ASC("`sendType` ASC"),SendType_DESC("`sendType` DESC") - ,SendStartDate_ASC("`sendStartDate` ASC"),SendStartDate_DESC("`sendStartDate` DESC") - ,SendEndDate_ASC("`sendEndDate` ASC"),SendEndDate_DESC("`sendEndDate` DESC") - ,ValidType_ASC("`validType` ASC"),ValidType_DESC("`validType` DESC") - ,ValidStartDate_ASC("`validStartDate` ASC"),ValidStartDate_DESC("`validStartDate` DESC") - ,ValidEndDate_ASC("`validEndDate` ASC"),ValidEndDate_DESC("`validEndDate` DESC") - ,ValidDays_ASC("`validDays` ASC"),ValidDays_DESC("`validDays` DESC") + ,SubTitle_ASC("`sub_title` ASC"),SubTitle_DESC("`sub_title` DESC") + ,SalePrice_ASC("`sale_price` ASC"),SalePrice_DESC("`sale_price` DESC") + ,UsePrice_ASC("`use_price` ASC"),UsePrice_DESC("`use_price` DESC") + ,UseLimitQuantity_ASC("`use_limit_quantity` ASC"),UseLimitQuantity_DESC("`use_limit_quantity` DESC") + ,TargetAd_ASC("`target_ad` ASC"),TargetAd_DESC("`target_ad` DESC") + ,SendType_ASC("`send_type` ASC"),SendType_DESC("`send_type` DESC") + ,SendStartDate_ASC("`send_start_date` ASC"),SendStartDate_DESC("`send_start_date` DESC") + ,SendEndDate_ASC("`send_end_date` ASC"),SendEndDate_DESC("`send_end_ate` DESC") + ,ValidType_ASC("`valid_type` ASC"),ValidType_DESC("`valid_type` DESC") + ,ValidStartDate_ASC("`valid_start_date` ASC"),ValidStartDate_DESC("`valid_start_date` DESC") + ,ValidEndDate_ASC("`valid_end_date` ASC"),ValidEndDate_DESC("`valid_end_date` DESC") + ,ValidDays_ASC("`valid_days` ASC"),ValidDays_DESC("`valid_days` DESC") ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") ,Price_ASC("`price` ASC"),Price_DESC("`price` DESC") - ,RemainInventory_ASC("`remainInventory` ASC"),RemainInventory_DESC("`remainInventory` DESC") + ,RemainInventory_ASC("`remain_inventory` ASC"),RemainInventory_DESC("`remain_inventory` DESC") ,Inventory_ASC("`inventory` ASC"),Inventory_DESC("`inventory` DESC") ,Remark_ASC("`remark` ASC"),Remark_DESC("`remark` DESC") ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") - ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") - ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") + ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") + ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") ,Business_ASC("`business` ASC"),Business_DESC("`business` DESC") ; private String value; @@ -376,7 +385,7 @@ public class WxCoupon implements Serializable { sb.append(","); sb.append(fields[k].toString()); } - + this.sortColumns = sb.toString(); } public void setSortColumns(String sortColumns) diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java b/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java index 691e410c7..a523d1de2 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java @@ -43,7 +43,7 @@ public class WxCouponCar implements Serializable { /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") - private Long tenantId; + private String tenantId; /*停车场ID**/ @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") private Long parkId; @@ -62,10 +62,10 @@ public class WxCouponCar implements Serializable { /*更新时间**/ @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") private Date updateDate; - public Long getTenantId() { + public String getTenantId() { return tenantId; } - public void setTenantId(Long _tenantId) { + public void setTenantId(String _tenantId) { tenantId = _tenantId; } public Long getParkId() { diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCouponChannel.java b/mallinkService/src/main/java/com/simple/domain/po/WxCouponChannel.java index e18bb0fe5..ef5cacf9c 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCouponChannel.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCouponChannel.java @@ -17,8 +17,6 @@ public class WxCouponChannel implements Serializable { @Transient protected List ids; - @Transient - protected List couponIds; @Transient protected String sortColumns; @@ -44,6 +42,15 @@ public class WxCouponChannel implements Serializable { } + @Transient + protected List couponIds; + public List getCouponIds() { + return couponIds; + } + public void setCouponIds(List couponIds) { + this.couponIds = couponIds; + } + /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") @@ -82,6 +89,11 @@ public class WxCouponChannel implements Serializable { /*更新时间**/ @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") private Date updateDate; + /*更新时间**/ + @io.swagger.annotations.ApiModelProperty(value="子频道ID",name="subTargetId") + private Long subTargetId; + + public String getTenantId() { return tenantId; } @@ -154,12 +166,13 @@ public class WxCouponChannel implements Serializable { public void setUpdateDate(Date _updateDate) { updateDate = _updateDate; } - public List getCouponIds() { - return couponIds; - } - public void setCouponIds(List couponIds) { - this.couponIds = couponIds; + + public Long getSubTargetId() { + return subTargetId; + } + public void setSubTargetId(Long subTargetId) { + this.subTargetId = subTargetId; } @@ -167,19 +180,19 @@ public class WxCouponChannel implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") - ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") - ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") - ,CouponStatus_ASC("`couponStatus` ASC"),CouponStatus_DESC("`couponStatus` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC") + ,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC") + ,CouponStatus_ASC("`coupon_status` ASC"),CouponStatus_DESC("`coupon_status` DESC") ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") - ,TargetAd_ASC("`targetAd` ASC"),TargetAd_DESC("`targetAd` DESC") + ,TargetAd_ASC("`target_ad` ASC"),TargetAd_DESC("`target_ad` DESC") ,Business_ASC("`business` ASC"),Business_DESC("`business` DESC") - ,BeginTime_ASC("`beginTime` ASC"),BeginTime_DESC("`beginTime` DESC") - ,EndTime_ASC("`endTime` ASC"),EndTime_DESC("`endTime` DESC") + ,BeginTime_ASC("`begin_time` ASC"),BeginTime_DESC("`begin_time` DESC") + ,EndTime_ASC("`end_time` ASC"),EndTime_DESC("`end_time` DESC") ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") - ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") - ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") + ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") + ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") ; private String value; Field(String value){ @@ -213,6 +226,8 @@ public class WxCouponChannel implements Serializable { sb.append(fields[k].toString()); } + this.sortColumns = sb.toString(); + } public void setSortColumns(String sortColumns) diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/simple/domain/po/WxCouponOrder.java index c94d2397e..c13b64cd5 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCouponOrder.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCouponOrder.java @@ -1,14 +1,13 @@ package com.simple.domain.po; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; import java.io.Serializable; import java.text.DecimalFormat; import java.util.Date; import java.util.List; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - @Table(name = "wx_coupon_order") public class WxCouponOrder implements Serializable { private static final long serialVersionUID = 1L; @@ -205,26 +204,26 @@ public class WxCouponOrder implements Serializable { public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), - TenantId_ASC("`tenantId` ASC"), - TenantId_DESC("`tenantId` DESC"), - CouponId_ASC("`couponId` ASC"), - CouponId_DESC("`couponId` DESC"), - CUserId_ASC("`cUserId` ASC"), - CUserId_DESC("`cUserId` DESC"), - BUserId_ASC("`bUserId` ASC"), - BUserId_DESC("`bUserId` DESC"), - OrderId_ASC("`orderId` ASC"), - OrderId_DESC("`orderId` DESC"), - ExpiredTime_ASC("`expiredTime` ASC"), - ExpiredTime_DESC("`expiredTime` DESC"), - CouponOrderStatus_ASC("`couponOrderStatus` ASC"), - CouponOrderStatus_DESC("`couponOrderStatus` DESC"), - CreateDate_ASC("`createDate` ASC"), - CreateDate_DESC("`createDate` DESC"), - UpdateDate_ASC("`updateDate` ASC"), - UpdateDate_DESC("`updateDate` DESC"), - CouponPrice_ASC("`couponPrice` ASC"), - CouponPrice_DESC("`couponPrice` DESC"); + TenantId_ASC("`tenant_id` ASC"), + TenantId_DESC("`tenant_id` DESC"), + CouponId_ASC("`coupon_id` ASC"), + CouponId_DESC("`coupon_id` DESC"), + CUserId_ASC("`c_user_id` ASC"), + CUserId_DESC("`c_user_id` DESC"), + BUserId_ASC("`b_user_id` ASC"), + BUserId_DESC("`b_user_id` DESC"), + OrderId_ASC("`order_id` ASC"), + OrderId_DESC("`order_id` DESC"), + ExpiredTime_ASC("`expired_time` ASC"), + ExpiredTime_DESC("`expired_time` DESC"), + CouponOrderStatus_ASC("`coupon_order_status` ASC"), + CouponOrderStatus_DESC("`coupon_order_status` DESC"), + CreateDate_ASC("`create_date` ASC"), + CreateDate_DESC("`create_date` DESC"), + UpdateDate_ASC("`update_date` ASC"), + UpdateDate_DESC("`update_date` DESC"), + CouponPrice_ASC("`coupon_price` ASC"), + CouponPrice_DESC("`coupon_price` DESC"); private String value; Field(String value) { @@ -259,6 +258,7 @@ public class WxCouponOrder implements Serializable { sb.append(","); sb.append(fields[k].toString()); } + this.sortColumns=sb.toString(); } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxMall.java b/mallinkService/src/main/java/com/simple/domain/po/WxMall.java index b46efc716..f0280b88a 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxMall.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxMall.java @@ -85,6 +85,13 @@ public class WxMall implements Serializable { @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrl") private String imgUrl; + @io.swagger.annotations.ApiModelProperty(value="迈外迪key",name="wiwideKey") + private String wiwideKey; + + @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") + private String wiwideUrl; + + public String getTenantId() { return tenantId; } @@ -180,6 +187,22 @@ public class WxMall implements Serializable { this.imgUrl = _imgUrl; } + public String getWiwideKey() { + return wiwideKey; + } + + public void setWiwideKey(String wiwideKey) { + this.wiwideKey = wiwideKey; + } + + public String getWiwideUrl() { + return wiwideUrl; + } + + public void setWiwideUrl(String wiwideUrl) { + this.wiwideUrl = wiwideUrl; + } + public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxOrder.java b/mallinkService/src/main/java/com/simple/domain/po/WxOrder.java index c16bda544..77d4ad36d 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxOrder.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxOrder.java @@ -167,18 +167,18 @@ public class WxOrder implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,OrderNumber_ASC("`orderNumber` ASC"),OrderNumber_DESC("`orderNumber` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") - ,CUserId_ASC("`cUserId` ASC"),CUserId_DESC("`cUserId` DESC") - ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") - ,BUserId_ASC("`bUserId` ASC"),BUserId_DESC("`bUserId` DESC") - ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") - ,PaymentType_ASC("`paymentType` ASC"),PaymentType_DESC("`paymentType` DESC") + ,OrderNumber_ASC("`order_number` ASC"),OrderNumber_DESC("`order_number` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,CUserId_ASC("`c_user_id` ASC"),CUserId_DESC("`c_user_id` DESC") + ,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC") + ,BUserId_ASC("`b_user_id` ASC"),BUserId_DESC("`b_user_id` DESC") + ,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC") + ,PaymentType_ASC("`payment_type` ASC"),PaymentType_DESC("`payment_type` DESC") ,Payment_ASC("`payment` ASC"),Payment_DESC("`payment` DESC") - ,PaymentTime_ASC("`paymentTime` ASC"),PaymentTime_DESC("`paymentTime` DESC") - ,OrderStatus_ASC("`orderStatus` ASC"),OrderStatus_DESC("`orderStatus` DESC") - ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") - ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") + ,PaymentTime_ASC("`payment_time` ASC"),PaymentTime_DESC("`payment_time` DESC") + ,OrderStatus_ASC("`order_status` ASC"),OrderStatus_DESC("`order_status` DESC") + ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") + ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") ,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC") ; private String value; @@ -212,6 +212,7 @@ public class WxOrder implements Serializable { sb.append(","); sb.append(fields[k].toString()); } + this.sortColumns = sb.toString(); } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxTags.java b/mallinkService/src/main/java/com/simple/domain/po/WxTags.java index efd52dfc6..eb4bd50c8 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxTags.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxTags.java @@ -101,12 +101,12 @@ public class WxTags implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") ,Type1_ASC("`type1` ASC"),Type1_DESC("`type1` DESC") ,Type2_ASC("`type2` ASC"),Type2_DESC("`type2` DESC") - ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") - ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") + ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") + ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") ; private String value; Field(String value){ @@ -139,6 +139,8 @@ public class WxTags implements Serializable { sb.append(","); sb.append(fields[k].toString()); } + + this.sortColumns = sb.toString(); } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java b/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java new file mode 100644 index 000000000..ed551f6ac --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/po/WxUserChannel.java @@ -0,0 +1,132 @@ +package com.simple.domain.po; + +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "wx_user_channel") +public class WxUserChannel implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + + + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="channelName") + private String channelName; + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="sceneAddress") + private String sceneAddress; + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="description") + private String description; + public String getChannelName() { + return channelName; + } + public void setChannelName(String _channelName) { + channelName = _channelName; + } + public String getSceneAddress() { + return sceneAddress; + } + public void setSceneAddress(String _sceneAddress) { + sceneAddress = _sceneAddress; + } + public String getDescription() { + return description; + } + public void setDescription(String _description) { + description = _description; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,ChannelName_ASC("`channelName` ASC"),ChannelName_DESC("`channelName` DESC") + ,SceneAddress_ASC("`sceneAddress` ASC"),SceneAddress_DESC("`sceneAddress` DESC") + ,Description_ASC("`description` ASC"),Description_DESC("`description` DESC") + ; + private String value; + Field(String value){ + this.value = value; + } + public String getValue() { + return value; + } + public void setCol(String value) { + this.value = value; + } + @Override + public String toString() { + return this.getValue(); + } + } + + public void setSortColumns(WxUserChannel.Field... fields) + { + if (fields == null || fields.length == 0) { + return; + } + for (int k = 0; k < fields.length; k++) { + if (fields[k] == null) { + return; + } + } + StringBuilder sb = new StringBuilder(fields[0].toString()); + for (int k = 1; k < fields.length; k++) { + sb.append(","); + sb.append(fields[k].toString()); + } + + } + + public void setSortColumns(String sortColumns) + { + if (sortColumns == null || "".equals(sortColumns.trim())) { + return; + } + if (sortColumns.contains(",")) { + String[] cols = sortColumns.split(","); + java.util.List fList = new java.util.ArrayList(); + for (int k = 0; k < cols.length; k++) { + fList.add(Field.valueOf(cols[k])); + } + this.setSortColumns(fList.toArray(new Field[fList.size()])); + } else { + this.setSortColumns(Field.valueOf(sortColumns)); + } + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxUserVisit.java b/mallinkService/src/main/java/com/simple/domain/po/WxUserVisit.java new file mode 100644 index 000000000..c2719a57a --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/po/WxUserVisit.java @@ -0,0 +1,222 @@ +package com.simple.domain.po; + +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "wx_user_visit") +public class WxUserVisit implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + + + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") + private String tenantId; + /*日期字符串**/ + @io.swagger.annotations.ApiModelProperty(value="日期字符串",name="refDate") + private String refDate; + /*日期**/ + @io.swagger.annotations.ApiModelProperty(value="日期",name="dayDate") + private Date dayDate; + /*打开次数**/ + @io.swagger.annotations.ApiModelProperty(value="打开次数",name="sessionCnt") + private Integer sessionCnt; + /*访问次数**/ + @io.swagger.annotations.ApiModelProperty(value="访问次数",name="visitPv") + private Integer visitPv; + /*访问人数**/ + @io.swagger.annotations.ApiModelProperty(value="访问人数",name="visitUv") + private Integer visitUv; + /*新用户数**/ + @io.swagger.annotations.ApiModelProperty(value="新用户数",name="visitUvNew") + private Integer visitUvNew; + /*人均停留时长 (浮点型,单位:秒)**/ + @io.swagger.annotations.ApiModelProperty(value="人均停留时长 (浮点型,单位:秒)",name="stayTimeUv") + private String stayTimeUv; + /*次均停留时长 (浮点型,单位:秒)**/ + @io.swagger.annotations.ApiModelProperty(value="次均停留时长 (浮点型,单位:秒)",name="stayTimeSession") + private String stayTimeSession; + /*平均访问深度 (浮点型)**/ + @io.swagger.annotations.ApiModelProperty(value="平均访问深度 (浮点型)",name="visitDepth") + private String visitDepth; + /*appId**/ + @io.swagger.annotations.ApiModelProperty(value="appId",name="appId") + private String appId; + /*创建时间**/ + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + public String getTenantId() { + return tenantId; + } + public void setTenantId(String _tenantId) { + tenantId = _tenantId; + } + public String getRefDate() { + return refDate; + } + public void setRefDate(String _refDate) { + refDate = _refDate; + } + public Date getDayDate() { + return dayDate; + } + public void setDayDate(Date _dayDate) { + dayDate = _dayDate; + } + public Integer getSessionCnt() { + return sessionCnt; + } + public void setSessionCnt(Integer _sessionCnt) { + sessionCnt = _sessionCnt; + } + public Integer getVisitPv() { + return visitPv; + } + public void setVisitPv(Integer _visitPv) { + visitPv = _visitPv; + } + public Integer getVisitUv() { + return visitUv; + } + public void setVisitUv(Integer _visitUv) { + visitUv = _visitUv; + } + public Integer getVisitUvNew() { + return visitUvNew; + } + public void setVisitUvNew(Integer _visitUvNew) { + visitUvNew = _visitUvNew; + } + public String getStayTimeUv() { + return stayTimeUv; + } + public void setStayTimeUv(String _stayTimeUv) { + stayTimeUv = _stayTimeUv; + } + public String getStayTimeSession() { + return stayTimeSession; + } + public void setStayTimeSession(String _stayTimeSession) { + stayTimeSession = _stayTimeSession; + } + public String getVisitDepth() { + return visitDepth; + } + public void setVisitDepth(String _visitDepth) { + visitDepth = _visitDepth; + } + public String getAppId() { + return appId; + } + public void setAppId(String _appId) { + appId = _appId; + } + public Date getCreateDate() { + return createDate; + } + public void setCreateDate(Date _createDate) { + createDate = _createDate; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,RefDate_ASC("`refDate` ASC"),RefDate_DESC("`refDate` DESC") + ,DayDate_ASC("`dayDate` ASC"),DayDate_DESC("`dayDate` DESC") + ,SessionCnt_ASC("`sessionCnt` ASC"),SessionCnt_DESC("`sessionCnt` DESC") + ,VisitPv_ASC("`visitPv` ASC"),VisitPv_DESC("`visitPv` DESC") + ,VisitUv_ASC("`visitUv` ASC"),VisitUv_DESC("`visitUv` DESC") + ,VisitUvNew_ASC("`visitUvNew` ASC"),VisitUvNew_DESC("`visitUvNew` DESC") + ,StayTimeUv_ASC("`stayTimeUv` ASC"),StayTimeUv_DESC("`stayTimeUv` DESC") + ,StayTimeSession_ASC("`stayTimeSession` ASC"),StayTimeSession_DESC("`stayTimeSession` DESC") + ,VisitDepth_ASC("`visitDepth` ASC"),VisitDepth_DESC("`visitDepth` DESC") + ,AppId_ASC("`appId` ASC"),AppId_DESC("`appId` DESC") + ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") + ; + private String value; + Field(String value){ + this.value = value; + } + public String getValue() { + return value; + } + public void setCol(String value) { + this.value = value; + } + @Override + public String toString() { + return this.getValue(); + } + } + + public void setSortColumns(WxUserVisit.Field... fields) + { + if (fields == null || fields.length == 0) { + return; + } + for (int k = 0; k < fields.length; k++) { + if (fields[k] == null) { + return; + } + } + StringBuilder sb = new StringBuilder(fields[0].toString()); + for (int k = 1; k < fields.length; k++) { + sb.append(","); + sb.append(fields[k].toString()); + } + + } + + public void setSortColumns(String sortColumns) + { + if (sortColumns == null || "".equals(sortColumns.trim())) { + return; + } + if (sortColumns.contains(",")) { + String[] cols = sortColumns.split(","); + java.util.List fList = new java.util.ArrayList(); + for (int k = 0; k < cols.length; k++) { + fList.add(Field.valueOf(cols[k])); + } + this.setSortColumns(fList.toArray(new Field[fList.size()])); + } else { + this.setSortColumns(Field.valueOf(sortColumns)); + } + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/CUserDateAmountVo.java b/mallinkService/src/main/java/com/simple/domain/vo/CUserDateAmountVo.java new file mode 100644 index 000000000..50a4a86ff --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/CUserDateAmountVo.java @@ -0,0 +1,27 @@ +package com.simple.domain.vo; + + +/** + * Created by syf on 2018/8/30. + */ +public class CUserDateAmountVo { + + private String xTime; + private int price; + + public String getxTime() { + return xTime; + } + + public void setxTime(String xTime) { + this.xTime = xTime; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/MarkingCouponDataReportVo.java b/mallinkService/src/main/java/com/simple/domain/vo/MarkingCouponDataReportVo.java new file mode 100644 index 000000000..ba7b2c570 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/MarkingCouponDataReportVo.java @@ -0,0 +1,92 @@ +package com.simple.domain.vo; + +/** + * Created by syf on 2018/8/28. + */ +public class MarkingCouponDataReportVo { + + //券领取张数 couponCount + //券领取人数 couponUserCount + //券核销张数 verifyCount + //券核销人数 verifyUserCount + private String createTime; + + public Long getCouponId() { + return couponId; + } + + public void setCouponId(Long couponId) { + this.couponId = couponId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + private Long couponId; //券id + + private String title; //券名称 + + private String type; //券类型 + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public int getCouponCount() { + return couponCount; + } + + public void setCouponCount(int couponCount) { + this.couponCount = couponCount; + } + + public int getCouponUserCount() { + return couponUserCount; + } + + public void setCouponUserCount(int couponUserCount) { + this.couponUserCount = couponUserCount; + } + + public int getVerifyCount() { + return verifyCount; + } + + public void setVerifyCount(int verifyCount) { + this.verifyCount = verifyCount; + } + + public int getVerifyUserCount() { + return verifyUserCount; + } + + public void setVerifyUserCount(int verifyUserCount) { + this.verifyUserCount = verifyUserCount; + } + + private int couponCount; + + private int couponUserCount; + + private int verifyCount; + + private int verifyUserCount; + +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataReportVo.java b/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataReportVo.java new file mode 100644 index 000000000..4d12d7adc --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataReportVo.java @@ -0,0 +1,89 @@ +package com.simple.domain.vo; + +/** + * Created by syf on 2018/8/29. + */ +public class MarkingSceneDataReportVo { + + private String xTime; + private int parkSendCount; //停车发放 + private int verifySendCount; //核销发放 + private int parkCount; //停车核销数 + private int verifyCount; //核销 核销数 + private int tempCount; + private Integer carCount; //车辆进场数 + private String verifyPercent; + private int total; + + public int getTotal() { + return verifySendCount+parkSendCount; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getTempCount() { + return tempCount; + } + + public void setTempCount(int tempCount) { + this.tempCount = tempCount; + } + + public String getxTime() { + return xTime; + } + + public void setxTime(String xTime) { + this.xTime = xTime; + } + + public int getParkSendCount() { + return parkSendCount; + } + + public void setParkSendCount(int parkSendCount) { + this.parkSendCount = parkSendCount; + } + + public int getVerifySendCount() { + return verifySendCount; + } + + public void setVerifySendCount(int verifySendCount) { + this.verifySendCount = verifySendCount; + } + + public int getParkCount() { + return parkCount; + } + + public void setParkCount(int parkCount) { + this.parkCount = parkCount; + } + + public int getVerifyCount() { + return verifyCount; + } + + public void setVerifyCount(int verifyCount) { + this.verifyCount = verifyCount; + } + + public Integer getCarCount() { + return carCount; + } + + public void setCarCount(Integer carCount) { + this.carCount = carCount; + } + + public String getVerifyPercent() { + return verifyPercent; + } + + public void setVerifyPercent(String verifyPercent) { + this.verifyPercent = verifyPercent; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataVo.java b/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataVo.java new file mode 100644 index 000000000..95272e024 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/MarkingSceneDataVo.java @@ -0,0 +1,54 @@ +package com.simple.domain.vo; + +/** + * Created by syf on 2018/8/30. + * + * 场景营销数据VO + */ +public class MarkingSceneDataVo { + private int carCount; //进车数量 + private int sendCount; //发券数 + private int verifyCount; //核销数 + private String verifyPercent; //核销比 + private String xTime; //时间 + + public int getCarCount() { + return carCount; + } + + public void setCarCount(int carCount) { + this.carCount = carCount; + } + + public int getSendCount() { + return sendCount; + } + + public void setSendCount(int sendCount) { + this.sendCount = sendCount; + } + + public int getVerifyCount() { + return verifyCount; + } + + public void setVerifyCount(int verifyCount) { + this.verifyCount = verifyCount; + } + + public String getVerifyPercent() { + return verifyPercent; + } + + public void setVerifyPercent(String verifyPercent) { + this.verifyPercent = verifyPercent; + } + + public String getxTime() { + return xTime; + } + + public void setxTime(String xTime) { + this.xTime = xTime; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/TouchUsersReportVo.java b/mallinkService/src/main/java/com/simple/domain/vo/TouchUsersReportVo.java new file mode 100644 index 000000000..bac601053 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/TouchUsersReportVo.java @@ -0,0 +1,74 @@ +package com.simple.domain.vo; + +/** + * Created by syf on 2018/8/30. + */ +public class TouchUsersReportVo { + private String xTime; + private int uv; + private int pv; + + private int userCount; //领取人数 + private int couponCount; //领取券数 + private int verifyUserCount; //核销人数 + + public int getVerifyCount() { + return verifyCount; + } + + public void setVerifyCount(int verifyCount) { + this.verifyCount = verifyCount; + } + + private int verifyCount; //核销量 + + public String getxTime() { + return xTime; + } + + public void setxTime(String xTime) { + this.xTime = xTime; + } + + public int getUv() { + return uv; + } + + public void setUv(int uv) { + this.uv = uv; + } + + public int getPv() { + return pv; + } + + public void setPv(int pv) { + this.pv = pv; + } + + public int getUserCount() { + return userCount; + } + + public void setUserCount(int userCount) { + this.userCount = userCount; + } + + public int getCouponCount() { + return couponCount; + } + + public void setCouponCount(int couponCount) { + this.couponCount = couponCount; + } + + public int getVerifyUserCount() { + return verifyUserCount; + } + + public void setVerifyUserCount(int verifyUserCount) { + this.verifyUserCount = verifyUserCount; + } + + +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java b/mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java index 84db123d6..21a641ff0 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java @@ -15,7 +15,7 @@ public class UserStructureVo implements Serializable{ //名称 private String name; //数量 - private String count; + private long count; //百分比 private String percentage; //序号 @@ -32,10 +32,10 @@ public class UserStructureVo implements Serializable{ public void setName(String name) { this.name = name; } - public String getCount() { + public long getCount() { return count; } - public void setCount(String count) { + public void setCount(long count) { this.count = count; } public String getPercentage() { diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCVo.java index 6a6f9abb2..9a3fee45a 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCVo.java @@ -122,6 +122,9 @@ public class WxCouponCVo implements Serializable { /*面额**/ @io.swagger.annotations.ApiModelProperty(value="面额",name="price") private Integer price; + /*单位**/ + @io.swagger.annotations.ApiModelProperty(value="单位0:钱分,1:小时",name="unit") + private Integer unit; /*剩余库存**/ @io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory") private Integer remainInventory; @@ -310,6 +313,15 @@ public class WxCouponCVo implements Serializable { public void setPrice(Integer _price) { price = _price; } + + public Integer getUnit() { + return unit; + } + + public void setUnit(Integer unit) { + this.unit = unit; + } + public Integer getRemainInventory() { return remainInventory; } diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCarVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCarVo.java new file mode 100644 index 000000000..78aaf0113 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponCarVo.java @@ -0,0 +1,347 @@ +package com.simple.domain.vo; + +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; +import java.io.Serializable; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class WxCouponCarVo implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + @Transient + protected String channels; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + + @Transient + private String salePriceStr; + + @Transient + private String usePriceStr; + + @Transient + private String priceStr; + + /*租户ID**/ + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + /*商户id**/ + @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") + private Long merchantId; + /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ + @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") + private Integer type; + /*封面图**/ + @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") + private String coverImg; + /*券名称**/ + @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") + private String title; + /*副标题**/ + @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle") + private String subTitle; + /*售价(适用于类型2,3,4,5)**/ + @io.swagger.annotations.ApiModelProperty(value="售价(适用于类型2,3,4,5)",name="salePrice") + private Integer salePrice; + /*使用条件金额(适用于类型1,2,3,4)**/ + @io.swagger.annotations.ApiModelProperty(value="使用条件金额(适用于类型1,2,3,4)",name="usePrice") + private Integer usePrice; + /*限领张数**/ + @io.swagger.annotations.ApiModelProperty(value="限领张数",name="useLimitQuantity") + private Integer useLimitQuantity; + /*投放频道位置(1.banner图,2.限时抢购)**/ + @io.swagger.annotations.ApiModelProperty(value="投放频道位置(1.banner图,2.限时抢购)",name="targetAd") + private Integer targetAd; + /*1.主动领取2.定向投放**/ + @io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType") + private Integer sendType; + /*有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)**/ + @io.swagger.annotations.ApiModelProperty(value="有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)",name="validType") + private Integer validType; + /*有效日期-开始**/ + @io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate") + private Date validStartDate; + /*有效日期-结束**/ + @io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate") + private Date validEndDate; + /*自领取之日几日有效,(停车券当天有效)**/ + @io.swagger.annotations.ApiModelProperty(value="自领取之日几日有效,(停车券当天有效)",name="validDays") + private Integer validDays; + /*须知**/ + @io.swagger.annotations.ApiModelProperty(value="须知",name="detail") + private String detail; + /*面额**/ + @io.swagger.annotations.ApiModelProperty(value="面额",name="price") + private Integer price; + /*单位**/ + @io.swagger.annotations.ApiModelProperty(value="单位(0:rmb分 1:小时)",name="unit") + private Integer unit; + /*剩余库存**/ + @io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory") + private Integer remainInventory; + /*总库存**/ + @io.swagger.annotations.ApiModelProperty(value="总库存",name="inventory") + private Integer inventory; + /*购买须知**/ + @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") + private String remark; + /*状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)**/ + @io.swagger.annotations.ApiModelProperty(value="状态(-1:全部,0:可投放,1:已生效,2:已失效,3:已作废)",name="status") + private Integer status; + /*创建时间**/ + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + /*更新时间**/ + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + /*业态**/ + @io.swagger.annotations.ApiModelProperty(value="业态",name="business") + private String business; + /*车场厂商类型**/ + @io.swagger.annotations.ApiModelProperty(value="车场厂商类型1:ETCP,2:TJD",name="vendorType") + private String vendorType; + /*车场厂商相关信息**/ + @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") + private String vendorParams; + public String getTenantId() { + return tenantId; + } + public void setTenantId(String _tenantId) { + tenantId = _tenantId; + } + public Long getMerchantId() { + return merchantId; + } + public void setMerchantId(Long _merchantId) { + merchantId = _merchantId; + } + public Integer getType() { + return type; + } + public void setType(Integer _type) { + type = _type; + } + public String getCoverImg() { + return coverImg; + } + public void setCoverImg(String _coverImg) { + coverImg = _coverImg; + } + public String getTitle() { + return title; + } + public void setTitle(String _title) { + title = _title; + } + public String getSubTitle() { + return subTitle; + } + public void setSubTitle(String _subTitle) { + subTitle = _subTitle; + } + public Integer getSalePrice() { + return salePrice; + } + public void setSalePrice(Integer _salePrice) { + salePrice = _salePrice; + } + public Integer getUsePrice() { + return usePrice; + } + public void setUsePrice(Integer _usePrice) { + usePrice = _usePrice; + } + public Integer getUseLimitQuantity() { + return useLimitQuantity; + } + public void setUseLimitQuantity(Integer _useLimitQuantity) { + useLimitQuantity = _useLimitQuantity; + } + public Integer getTargetAd() { + return targetAd; + } + public void setTargetAd(Integer _targetAd) { + targetAd = _targetAd; + } + public Integer getSendType() { + return sendType; + } + public void setSendType(Integer _sendType) { + sendType = _sendType; + } + public Integer getValidType() { + return validType; + } + public void setValidType(Integer _validType) { + validType = _validType; + } + public Date getValidStartDate() { + return validStartDate; + } + public void setValidStartDate(Date _validStartDate) { + validStartDate = _validStartDate; + } + public Date getValidEndDate() { + return validEndDate; + } + public void setValidEndDate(Date _validEndDate) { + validEndDate = _validEndDate; + } + public Integer getValidDays() { + return validDays; + } + public void setValidDays(Integer _validDays) { + validDays = _validDays; + } + public String getDetail() { + return detail; + } + public void setDetail(String _detail) { + detail = _detail; + } + public Integer getPrice() { + return price; + } + public void setPrice(Integer _price) { + price = _price; + } + public Integer getUnit() { + return unit; + } + public void setUnit(Integer _unit) { + unit = _unit; + } + public Integer getRemainInventory() { + return remainInventory; + } + public void setRemainInventory(Integer _remainInventory) { + remainInventory = _remainInventory; + } + public Integer getInventory() { + return inventory; + } + public void setInventory(Integer _inventory) { + inventory = _inventory; + } + public String getRemark() { + return remark; + } + public void setRemark(String _remark) { + remark = _remark; + } + public Integer getStatus() { + return status; + } + public void setStatus(Integer _status) { + status = _status; + } + public Date getCreateDate() { + return createDate; + } + public void setCreateDate(Date _createDate) { + createDate = _createDate; + } + public Date getUpdateDate() { + return updateDate; + } + public void setUpdateDate(Date _updateDate) { + updateDate = _updateDate; + } + public String getBusiness() { + return business; + } + public void setBusiness(String _business) { + business = _business; + } + + public String getVendorType() { + return vendorType; + } + + public void setVendorType(String vendorType) { + this.vendorType = vendorType; + } + + public String getVendorParams() { + return vendorParams; + } + + public void setVendorParams(String vendorParams) { + this.vendorParams = vendorParams; + } + + public String getSalePriceStr() { + if(salePrice!=null) { + DecimalFormat df=new DecimalFormat("0.00"); + salePriceStr = df.format((float)salePrice/100); + } + return salePriceStr; + } + + public void setSalePriceStr(String salePriceStr) { + this.salePriceStr = salePriceStr; + } + + public String getUsePriceStr() { + if(usePrice!=null) { + DecimalFormat df=new DecimalFormat("0.00"); + usePriceStr = df.format((float)usePrice/100); + } + return usePriceStr; + } + + public void setUsePriceStr(String usePriceStr) { + this.usePriceStr = usePriceStr; + } + + public String getPriceStr() { + if(price!=null) { + DecimalFormat df=new DecimalFormat("0.00"); + priceStr = df.format((float)price/100); + } + return priceStr; + } + + public void setPriceStr(String priceStr) { + this.priceStr = priceStr; + } + + public String getChannels() { + return channels; + } + + public void setChannels(String channels) { + this.channels = channels; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelVo.java index f5ab53a7c..99fe69083 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelVo.java @@ -39,6 +39,9 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { /*面额**/ @io.swagger.annotations.ApiModelProperty(value="面额",name="price") private Integer price; + /*单位**/ + @io.swagger.annotations.ApiModelProperty(value="单位0:钱分,1:小时",name="unit") + private Integer unit; /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") @@ -109,6 +112,14 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { return price; } + public Integer getUnit() { + return unit; + } + + public void setUnit(Integer unit) { + this.unit = unit; + } + public Integer getUseLimitQuantity() { return useLimitQuantity; } diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxOrderCVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxOrderCVo.java index 4c8d4a504..eab3cbddb 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/WxOrderCVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxOrderCVo.java @@ -85,6 +85,13 @@ public class WxOrderCVo extends WxCouponOrder{ private Date updateDate; + /*券ID-产品ID将来的产品都会放在coupon表里**/ + @io.swagger.annotations.ApiModelProperty(value="券包中券ID",name="couponOrderId") + private Long couponOrderId; + /*0: 未使用 1: 已核销 2:已过期 3:已退款**/ + @io.swagger.annotations.ApiModelProperty(value="0: 未使用 1: 已核销 2:已过期 3:已退款",name="couponOrderStatus") + private Integer couponOrderStatus; + /* 券类型信息 */ /*商户id**/ /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ @@ -179,7 +186,6 @@ public class WxOrderCVo extends WxCouponOrder{ public Long getCouponId() { return couponId; } - public void setCouponId(Long _couponId) { this.couponId = _couponId; } @@ -221,6 +227,18 @@ public class WxOrderCVo extends WxCouponOrder{ updateDate = _updateDate; } + public Long getCouponOrderId() { + return couponOrderId; + } + public void setCouponOrderId(Long _couponOrderId) { + this.couponOrderId = _couponOrderId; + } + public Integer getCouponOrderStatus() { + return couponOrderStatus; + } + public void setCouponOrderStatus(Integer _couponOrderStatus) { + couponOrderStatus = _couponOrderStatus; + } public Integer getType() { return type; diff --git a/mallinkService/src/main/java/com/simple/enums/EnumCouponChannelType.java b/mallinkService/src/main/java/com/simple/enums/EnumCouponChannelType.java new file mode 100644 index 000000000..b47f9ef80 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/enums/EnumCouponChannelType.java @@ -0,0 +1,39 @@ +package com.simple.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponChannelType { + + COUPON_CHANNEL_ID_LIST(1, "列表"), + COUPON_CHANNEL_ID_TIMED(2, "限时抢购"), + COUPON_CHANNEL_ID_CAMPAIN(3, "幻灯片"), + ; + + ; + + public static EnumCouponChannelType getEnum(Integer code) { + for (EnumCouponChannelType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponChannelType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/simple/enums/EnumCouponStatus.java b/mallinkService/src/main/java/com/simple/enums/EnumCouponStatus.java index 3e730d29f..3cce3c458 100644 --- a/mallinkService/src/main/java/com/simple/enums/EnumCouponStatus.java +++ b/mallinkService/src/main/java/com/simple/enums/EnumCouponStatus.java @@ -5,11 +5,9 @@ package com.simple.enums; */ public enum EnumCouponStatus { - // 0-草稿/待生效;1-已生效/已发布/已投放;2-已下架; - - COUPON_STATUS_DRAFT(0, "草稿"), - COUPON_STATUS_THROW_IN(1, "已投放"), - COUPON_STATUS_TAKE_OFFF(2, "已下架"), + // 0-可投放;1-已作废; + COUPON_STATUS_THROW_IN(0, "可投放"), + COUPON_STATUS_TAKE_OFFF(1, "已作废"), ; public static EnumCouponStatus getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/simple/enums/EnumCouponType.java b/mallinkService/src/main/java/com/simple/enums/EnumCouponType.java new file mode 100644 index 000000000..9f76e0e56 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/enums/EnumCouponType.java @@ -0,0 +1,40 @@ +package com.simple.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponType { + + // 1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券 + COUPON_MANJIAN(1, "满减券"), + COUPON_DAIJIN(2, "代金券"), + COUPON_TUANGOU(3, "团购券"), + COUPON_LIPIN(4, "礼品券"), + COUPON_TINGCHE(5, "停车券"), + ; + + public static EnumCouponType getEnum(Integer code) { + for (EnumCouponType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/simple/enums/EnumDateAmtType.java b/mallinkService/src/main/java/com/simple/enums/EnumDateAmtType.java new file mode 100644 index 000000000..54e337a62 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/enums/EnumDateAmtType.java @@ -0,0 +1,37 @@ +package com.simple.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumDateAmtType { + + // 0 交易记录 1.核销记录; + PAY_RECORD(0, "交易记录"), + VERIFY_RECORD(1, "核销记录"), + ; + + public static EnumDateAmtType getEnum(Integer code) { + for (EnumDateAmtType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumDateAmtType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/simple/enums/EnumOrderStatus.java b/mallinkService/src/main/java/com/simple/enums/EnumOrderStatus.java index 8dceebb4c..fb2a74051 100644 --- a/mallinkService/src/main/java/com/simple/enums/EnumOrderStatus.java +++ b/mallinkService/src/main/java/com/simple/enums/EnumOrderStatus.java @@ -5,7 +5,7 @@ package com.simple.enums; */ public enum EnumOrderStatus { - // 0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款);3-未退款/待退款;4-已退款;5-退款失败 + // 0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败 ORDER_STATUS_PENDING_PAYMENT(0, "待付款"), ORDER_STATUS_PAYMENT_SUCCESS(1, "已支付"), diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCUserCarMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCUserCarMapper.java index aa6a2780b..9d3265673 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCUserCarMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCUserCarMapper.java @@ -8,6 +8,7 @@ import com.simple.domain.po.WxCUserCar; public interface WxCUserCarMapper extends CommonMapper { List findList(WxCUserCar wxCUserCar); + Integer countList(WxCUserCar wxCUserCar); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCUserMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCUserMapper.java index 222053d6e..d2ed63697 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCUserMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCUserMapper.java @@ -2,6 +2,8 @@ package com.simple.mapper; import java.util.List; +import org.apache.ibatis.annotations.Param; + import com.simple.common.CommonMapper; import com.simple.domain.dto.WxCuerBasicInfoDto; import com.simple.domain.po.WxCUser; @@ -15,5 +17,9 @@ public interface WxCUserMapper extends CommonMapper { WxCUser findByToken(String token); - long findCountBySex(WxCuerBasicInfoDto dto); + long findCount(WxCuerBasicInfoDto dto); + + + List listByChannel(@Param("sceneList")List sceneList); + } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCarCmdLogMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCarCmdLogMapper.java index ccb627ed6..3449822ce 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCarCmdLogMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCarCmdLogMapper.java @@ -2,6 +2,7 @@ package com.simple.mapper; import com.simple.common.CommonMapper; import com.simple.domain.po.WxCarCmdLog; +import com.simple.domain.vo.MarkingSceneDataVo; import java.util.HashMap; import java.util.List; @@ -14,4 +15,6 @@ public interface WxCarCmdLogMapper extends CommonMapper { List> queryHistory(HashMap params); List> queryTodayCar(HashMap params); + + List queryForSceneRepotyHistoryCar(HashMap params); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponActionLogMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponActionLogMapper.java index 053fa82d8..e113a2116 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponActionLogMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponActionLogMapper.java @@ -2,12 +2,29 @@ package com.simple.mapper; import java.util.*; import com.simple.common.CommonMapper; +import com.simple.domain.vo.MarkingSceneDataReportVo; import org.apache.ibatis.annotations.Param; import com.simple.domain.po.WxCouponActionLog; public interface WxCouponActionLogMapper extends CommonMapper { List findList(WxCouponActionLog wxCouponActionLog); + /** + * 查询场景投放发券数 + * @param tenantId + * @param startTime + * @param endTime + * @return + */ + int findCountByDateLimit(@Param("tenantId")String tenantId,@Param("startTime") Date startTime,@Param("endTime")Date endTime); + + List sceneDataMap(HashMap params); + + List sceneDataMapJoinCouponOrder(HashMap params); + + List sceneDataList(HashMap params); + + List sceneDataJoinCouponOrderList(HashMap params); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java index 5421db797..6abf581e8 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java @@ -2,6 +2,8 @@ package com.simple.mapper; import java.util.*; import com.simple.common.CommonMapper; +import com.simple.domain.po.WxCoupon; +import com.simple.domain.vo.WxCouponCarVo; import org.apache.ibatis.annotations.Param; import com.simple.domain.po.WxCouponCar; @@ -10,8 +12,10 @@ public interface WxCouponCarMapper extends CommonMapper { List findList(WxCouponCar wxCouponCar); + Integer findTemplateAmtCount(Long templateId); - - + Integer findTemplateAvailCount(Long templateId); + + WxCouponCarVo selectCouponCarDetail(WxCoupon coupon); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java index 613e9dd7f..8e3cd641a 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java @@ -13,10 +13,10 @@ public interface WxCouponChannelMapper extends CommonMapper findVoList(WxCouponChannel wxCouponChannel); void updateStatusByCouponId(WxCouponChannel wxCouponChannel); - - - + void offExpiriedCouponChannelByEndTime(); + + void offExpiriedCouponChannelByValidDate(); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java index 3ef099724..45c8d18c8 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponMapper.java @@ -11,11 +11,9 @@ public interface WxCouponMapper extends CommonMapper { List findList(WxCoupon wxCoupon); - List findEnableList(WxCoupon wxCoupon); - - List findCanSendList(WxCoupon wxCoupon); - - WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel); + WxCouponCVo selectDetailForCUserC(WxCoupon wxCoupon); + + void reduceInventory(@Param("id")Long id,@Param("number")Integer number); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java index b4cde9e0e..d6a5b7cde 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java @@ -2,23 +2,60 @@ package com.simple.mapper; import java.util.*; import com.simple.common.CommonMapper; -import com.simple.domain.vo.WxCouponOrderBVo; -import com.simple.domain.vo.WxCouponOrderCVo; +import com.simple.domain.vo.*; import org.apache.ibatis.annotations.Param; import com.simple.domain.po.WxCouponOrder; public interface WxCouponOrderMapper extends CommonMapper { List findList(WxCouponOrder wxCouponOrder); + Integer countList(WxCouponOrder wxCouponOrder); - List findListOfUnverifiedByDate(Map dateMap); + List findListOfOrderedByDate(Map dateMap); List findListOfVerifiedByDate(Map dateMap); - List findListOfUnverifiedByDateForBUser(Map dateMap); + List findListOfOrderedByDateForBUser(Map dateMap); List findListOfVerifiedByDateForBUser(Map dateMap); - List findListOfCUser(Map paramMap); - WxCouponOrderCVo selectDetailOfCUser(Map paramMap); + WxCouponOrderCVo selectDetailOfUser(Map paramMap); + + List findListOfCUser(WxCouponOrder wxCouponOrder); + List findListOfAdmin(WxCouponOrder wxCouponOrder); + + //营销报表 券数据图表 + List couponDataMap(HashMap params); + + //营销报表 券数据报表 + List couponDataList(HashMap params); //返回日期格式yy-MM-dd + + //营销报表 触达用户数 + List touchUsersReportList(HashMap params); //返回日期格式yy-MM-dd + + + /** + * 查询商场领券数 + * @param tenantId + * @param startTime + * @param endTime + * @return + */ + int findCountByDateLimit(@Param("tenantId")String tenantId,@Param("startTime") Date startTime,@Param("endTime")Date endTime); + /** + * 日期分组 消费总数 + * @param tenantId + * @param startTime + * @param endTime + * @return + */ + List queryPriceTotalGroup(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); + /** + * 查询时间段内消费总数 + * @param tenantId + * @param startTime + * @param endTime + * @return + */ + int queryPriceTotal(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); + - List findListOfAdmin(WxCouponOrder wxCouponOrder); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxOrderMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxOrderMapper.java index ad5230ed7..955b9303d 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxOrderMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxOrderMapper.java @@ -11,6 +11,8 @@ public interface WxOrderMapper extends CommonMapper { List findList(WxOrder wxOrder); + Integer countList(WxOrder wxOrder); + List findListOfUnpaidOrderByDate(Map dateMap); List findListOfCUser(WxOrder wxOrder); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.java new file mode 100644 index 000000000..7e0cd34ac --- /dev/null +++ b/mallinkService/src/main/java/com/simple/mapper/WxUserChannelMapper.java @@ -0,0 +1,17 @@ +package com.simple.mapper; + +import java.util.*; +import com.simple.common.CommonMapper; +import org.apache.ibatis.annotations.Param; +import com.simple.domain.po.WxUserChannel; + +public interface WxUserChannelMapper extends CommonMapper { + + List findList(WxUserChannel wxUserChannel); + + + List findDistinctChannel(); + + + +} diff --git a/mallinkService/src/main/java/com/simple/mapper/WxUserVisitMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxUserVisitMapper.java new file mode 100644 index 000000000..d73973b81 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/mapper/WxUserVisitMapper.java @@ -0,0 +1,20 @@ +package com.simple.mapper; + +import java.util.*; +import com.simple.common.CommonMapper; +import com.simple.domain.vo.TouchUsersReportVo; +import org.apache.ibatis.annotations.Param; +import com.simple.domain.po.WxUserVisit; + +public interface WxUserVisitMapper extends CommonMapper { + + List findList(WxUserVisit wxUserVisit); + + List touchUsersReportList(HashMap params); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/schedule/SchedulingConfig.java b/mallinkService/src/main/java/com/simple/schedule/SchedulingConfig.java deleted file mode 100644 index 1bbab78a5..000000000 --- a/mallinkService/src/main/java/com/simple/schedule/SchedulingConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.simple.schedule; - -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableScheduling; - -@Configuration -@EnableScheduling -public class SchedulingConfig { //implements SchedulingConfigurer { - - // @Override - // public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - // ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); - // scheduler.setPoolSize(10); - // scheduler.initialize(); - // taskRegistrar.setTaskScheduler(scheduler); - // } - -} \ No newline at end of file diff --git a/mallinkService/src/main/java/com/simple/service/DataTowerService.java b/mallinkService/src/main/java/com/simple/service/DataTowerService.java index 0f2d231b5..949ce5788 100644 --- a/mallinkService/src/main/java/com/simple/service/DataTowerService.java +++ b/mallinkService/src/main/java/com/simple/service/DataTowerService.java @@ -9,4 +9,6 @@ public interface DataTowerService { Map queryCar(String tenantId); + Map queryCustomer(String tenantId); + } diff --git a/mallinkService/src/main/java/com/simple/service/MarkingDataReportService.java b/mallinkService/src/main/java/com/simple/service/MarkingDataReportService.java new file mode 100644 index 000000000..2c61449ea --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/MarkingDataReportService.java @@ -0,0 +1,28 @@ +package com.simple.service; + +import com.github.pagehelper.PageInfo; +import com.simple.domain.dto.MarkingCouponDataReportDto; +import com.simple.domain.vo.MarkingCouponDataReportVo; +import com.simple.domain.vo.MarkingSceneDataReportVo; +import com.simple.domain.vo.MarkingSceneDataVo; +import com.simple.domain.vo.TouchUsersReportVo; + +import java.util.List; +import java.util.Map; + +/** + * Created by syf on 2018/8/28. + */ +public interface MarkingDataReportService { + Map getCouponDate(String tenantId); + + Map getSceneData(String tenantId); + + PageInfo getCouponDateList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize); + + PageInfo getSceneDataList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize); + + PageInfo getTouchUsersReportList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize); + + List getTouchUsersReportData(String tenantId); +} diff --git a/mallinkService/src/main/java/com/simple/service/WxCUserService.java b/mallinkService/src/main/java/com/simple/service/WxCUserService.java index 1dcb1e883..61ef2f35d 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCUserService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCUserService.java @@ -1,5 +1,7 @@ package com.simple.service; +import java.util.List; + import com.github.pagehelper.PageInfo; import com.simple.domain.dto.WxCuerBasicInfoDto; import com.simple.domain.po.WxCUser; @@ -55,9 +57,20 @@ public interface WxCUserService { void deleteById(Long id); /** - * 根据性别统计数量 + * 统计数量 * @param dto * @return */ - long findCountBySex(WxCuerBasicInfoDto dto); + long findCount(WxCuerBasicInfoDto dto); + + + /** + * 通过渠道获取会员信息 + * @param channel + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listByChannel(List sceneList, Integer pageIndex, Integer pageSize); + } diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java b/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java index 6aca30ceb..406de3c2a 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java @@ -1,8 +1,9 @@ package com.simple.service; -import java.util.*; import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponCar; +import com.simple.domain.vo.WxCouponCarVo; public interface WxCouponCarService { @@ -24,12 +25,19 @@ public interface WxCouponCarService { */ WxCouponCar getById(Long id); - /** + /** * 保存或更新实体 * * @param record */ - void saveOrUpdate(WxCouponCar record); + void save(WxCouponCar record); + + /** + * 更新实体 + * + * @param record + */ + void update(WxCouponCar record); /** * 根据Id删除实体 @@ -37,11 +45,28 @@ public interface WxCouponCarService { * @param id */ void deleteById(Long id); - - - - + /** + * 根据templateId获取分配总数 + * + * @param templateId + */ + Integer getAmtCountByTemplateId(Long templateId); + + /** + * 根据templateId获取库存总数 + * + * @param templateId + */ + Integer getAvaibleCountByTemplateId(Long templateId); + + /** + * 根据coupon获得实体 + * + * @param coupon + * @return + */ + WxCouponCarVo getByCoupon(WxCoupon coupon); diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java index c1093fd49..21f5fee58 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java @@ -1,10 +1,12 @@ package com.simple.service; import com.github.pagehelper.PageInfo; +import com.simple.common.ResultData; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponChannelVo; import java.util.Date; +import java.util.List; public interface WxCouponChannelService { @@ -12,14 +14,30 @@ public interface WxCouponChannelService { * 根据实体查询分页列表 * * @param record - * @param offset - * @param limit + * @param pageIndex + * @param pageSize * @return */ PageInfo listAsPage(WxCouponChannel record, Integer pageIndex, Integer pageSize); + /** + * 根据实体查询Vo分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ PageInfo listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize); - + + /** + * 根据实体查询Vo分页列表 + * + * @param record + * @return + */ + List listAPI(WxCouponChannel record); + /** * 根据Id获得实体 * @@ -42,7 +60,7 @@ public interface WxCouponChannelService { */ void deleteById(Long id); - void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); + ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime); void updateStatusByCouponId(Long couponId,String tenantId,int status); diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/simple/service/WxCouponOrderService.java index 6e49becda..6169ca752 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponOrderService.java @@ -1,13 +1,11 @@ package com.simple.service; -import java.util.*; - -import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.simple.common.ResultData; -import com.simple.domain.po.MallUserInfo; import com.simple.domain.po.WxCouponOrder; -import com.simple.domain.po.WxMerchantBUser; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; public interface WxCouponOrderService { @@ -80,7 +78,7 @@ public interface WxCouponOrderService { * @param bUserId C端用户 */ - ResultData listCUserVoAsPage(Long cUserId, Integer pageIndex, Integer pageSize, Integer status); + ResultData listCUserVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize); /** * C用户查券详情 @@ -107,4 +105,6 @@ public interface WxCouponOrderService { */ ResultData listAdminAsPage(WxCouponOrder wxCouponOrder, Integer pageIndex, Integer pageSize); + void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId); + } diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponService.java b/mallinkService/src/main/java/com/simple/service/WxCouponService.java index 6dc34f35e..044712aa2 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponService.java @@ -19,15 +19,6 @@ public interface WxCouponService { */ PageInfo listAsPage(WxCoupon record, Integer pageIndex, Integer pageSize); - /** - * 根据实体查询分页列表 - * - * @param record - * @param pageIndex - * @param pageSize - * @return - */ - PageInfo findEnableList(WxCoupon record, Integer pageIndex, Integer pageSize); /** * 不分页 @@ -57,14 +48,11 @@ public interface WxCouponService { * @param id */ void deleteById(Long id); - /** - * - */ - PageInfo findCanSendList(WxCoupon record, Integer pageIndex, Integer pageSize); - WxCouponCVo selectDetailForCUser(WxCouponChannel record); - + WxCouponCVo selectDetailForCUser(WxCoupon record); ResultData updateCoupon(WxCoupon wxCoupon); + void reduceInventory(Long id,Integer number); + } diff --git a/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java b/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java new file mode 100644 index 000000000..a7b25fb79 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/WxUserChannelService.java @@ -0,0 +1,48 @@ +package com.simple.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserChannel; + +public interface WxUserChannelService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param offset + * @param limit + * @return + */ + PageInfo listAsPage(WxUserChannel record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxUserChannel getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(WxUserChannel record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + List findDistinctChannel(); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/WxUserVisitService.java b/mallinkService/src/main/java/com/simple/service/WxUserVisitService.java new file mode 100644 index 000000000..293f1533b --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/WxUserVisitService.java @@ -0,0 +1,49 @@ +package com.simple.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserVisit; +import com.simple.domain.vo.TouchUsersReportVo; + +public interface WxUserVisitService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param offset + * @param limit + * @return + */ + PageInfo listAsPage(WxUserVisit record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxUserVisit getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(WxUserVisit record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + List touchUsersReportList(HashMap params); + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java index 55db6dd7a..63b316e7f 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java @@ -1,6 +1,8 @@ package com.simple.service.impl; -import com.simple.common.ErrorCode; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonObject; +import com.simple.domain.po.WxMall; import com.simple.domain.po.WxMerchant; import com.simple.domain.po.WxMerchantTradeDaily; import com.simple.domain.po.WxShop; @@ -8,12 +10,14 @@ import com.simple.enums.EnumCarCmd; import com.simple.mapper.*; import com.simple.service.DataTowerService; import com.simple.utils.DateUtils; -import org.apache.commons.collections.map.TransformedMap; +import com.simple.utils.HashUtil; +import com.simple.utils.HttpUtil; import org.apache.log4j.Logger; -import org.apache.shiro.crypto.hash.Hash; +import org.apache.shiro.codec.Base64; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -39,6 +43,9 @@ public class DataTowerServiceImpl implements DataTowerService { @Autowired WxCarCmdLogMapper wxCarCmdLogMapper; + @Autowired + WxMallMapper wxMallMapper; + @Override @@ -223,6 +230,67 @@ public class DataTowerServiceImpl implements DataTowerService { return datamap; } + @Override + public Map queryCustomer(String tenantId) { + + + WxMall wxMall = new WxMall(); + wxMall.setTenantId(tenantId); + List list = wxMallMapper.findList(wxMall); + wxMall = list.get(0); + String username=wxMall.getWiwideId(); + String authVal=encrypt(wxMall.getWiwideKey()); + Map params=new HashMap<>(); + params.put("username",username); + params.put("authVal",authVal); + String token = HttpUtil.doPost(wxMall.getWiwideUrl(), params); + + + Map datamap = new HashMap<>(); + datamap.put("token",JSONObject.parseObject(token).get("data")); + + return datamap; + } + + + public String encrypt(String key) + { + String data = new Date().getTime()/1000+30+""; + String md5 = HashUtil.md5(key); + int x = 0; + int len = data.length(); + int l = md5.length(); + char[] datachar =new char[len]; + for (int i = 0; i < len; i++) + { + if (x == l) + { + x = 0; + } + datachar[i]=md5.charAt(x); + x++; + } + + StringBuilder chars=new StringBuilder(); + for (int i = 0; i < len; i++) + { + int a = data.charAt(i); + int b = (datachar[i]%256); + char v = (char) (a+b); + chars.append(v); + } + + byte[] bytes=null; + try { + bytes = chars.toString().getBytes("ISO-8859-1"); + } catch (Exception e) { + e.printStackTrace(); + } + return Base64.encodeToString(bytes); + + } + + public TreeMap getTimeTreeMap(){ TreeMap timemap=new TreeMap(); timemap.put("06:00",0); @@ -248,4 +316,5 @@ public class DataTowerServiceImpl implements DataTowerService { + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java new file mode 100644 index 000000000..ef10a7758 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java @@ -0,0 +1,338 @@ +package com.simple.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.simple.domain.dto.MarkingCouponDataReportDto; +import com.simple.domain.po.WxCoupon; +import com.simple.domain.po.WxUserVisit; +import com.simple.domain.vo.MarkingCouponDataReportVo; +import com.simple.domain.vo.MarkingSceneDataReportVo; +import com.simple.domain.vo.MarkingSceneDataVo; +import com.simple.domain.vo.TouchUsersReportVo; +import com.simple.enums.EnumCouponType; +import com.simple.mapper.*; +import com.simple.service.MarkingDataReportService; +import com.simple.service.WxCouponService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.NumberFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Created by syf on 2018/8/28. + */ +@Service +public class MarkingDataReportServiceImpl implements MarkingDataReportService { + + + @Autowired + private WxCouponOrderMapper wxCouponOrderMapper; + @Autowired + private WxCouponActionLogMapper wxCouponActionLogMapper; + @Autowired + private WxCarCmdLogMapper wxCarCmdLogMapper; + @Autowired + private WxUserVisitMapper wxUserVisitMapper; + @Autowired + private WxCouponMapper wxCouponMapper; + + //取本月第一天 + private Date getFirstDayOfMonth() { + Calendar c = Calendar.getInstance(); + c.set(Calendar.DAY_OF_MONTH, 0);//设置为1号,当前日期既为本月第一天 + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + Date thisMonth = c.getTime(); + return thisMonth; + } + + private Date addDay(int addDayAmount) { + Calendar c = Calendar.getInstance(); + c.add(Calendar.DATE, addDayAmount); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + Date date = c.getTime(); + return date; + } + + /** + * @param date 转换当前时间去掉时分秒 + * @return + */ + private Date convertDate(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + Date result = c.getTime(); + return result; + } + + private Date convertDateAndAdd(Date date, int addDayAmount) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DATE, addDayAmount); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + Date result = c.getTime(); + return result; + } + + //取的当月券数据 + @Override + public Map getCouponDate(String tenantId) { + //今日领取券数 + //查询coupon order表 + int todayCouponCount = wxCouponOrderMapper.findCountByDateLimit(tenantId, addDay(0), addDay(1)); + int yesterdayCount = wxCouponOrderMapper.findCountByDateLimit(tenantId, addDay(-1), addDay(0)); + int lastWeekCount = wxCouponOrderMapper.findCountByDateLimit(tenantId, addDay(-7), addDay(-6)); + + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 + String couponUpDay = ""; + if (yesterdayCount != 0) { + couponUpDay = nf.format((todayCouponCount - yesterdayCount) / (float) yesterdayCount); + } else { + couponUpDay = nf.format(todayCouponCount); + } + String couponUpWeek = ""; + if (lastWeekCount != 0) { + couponUpWeek = nf.format((todayCouponCount - lastWeekCount) / (float) lastWeekCount); + } else { + couponUpWeek = nf.format(todayCouponCount); + } + + //couponData + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", getFirstDayOfMonth()); + params.put("endTime", addDay(1)); + List couponDatalist = wxCouponOrderMapper.couponDataMap(params); + //查询券领取人数 + + HashMap returnMap = new HashMap<>(); + returnMap.put("couponUpDay", couponUpDay);//比昨日提升 + returnMap.put("couponUpWeek", couponUpWeek);//比上周提升 + returnMap.put("todayCouponCount", todayCouponCount);//今日领取数 + returnMap.put("couponDataMap", couponDatalist); + return returnMap; + } + + + @Override + public Map getSceneData(String tenantId) { + //今日营销投放券数 + int todaySceneCount = wxCouponActionLogMapper.findCountByDateLimit(tenantId, addDay(0), addDay(1)); + int yesterdayCount = wxCouponActionLogMapper.findCountByDateLimit(tenantId, addDay(-1), addDay(0)); + int lastWeekCount = wxCouponActionLogMapper.findCountByDateLimit(tenantId, addDay(-7), addDay(-6)); + + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 + String sceneDownDay = ""; + if (yesterdayCount != 0) { + sceneDownDay = nf.format((yesterdayCount - todaySceneCount) / (float) yesterdayCount); + } else { + sceneDownDay = nf.format(0 - todaySceneCount); + } + String sceneUpWeek = ""; + if (lastWeekCount != 0) { + sceneUpWeek = nf.format((todaySceneCount - lastWeekCount) / (float) lastWeekCount); + } else { + sceneUpWeek = nf.format(todaySceneCount); + } + + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", getFirstDayOfMonth()); + params.put("endTime", addDay(1)); + //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 + List list = wxCouponActionLogMapper.sceneDataMap(params); + + //停车发券被核销数 + HashMap params1 = new HashMap<>(); + params1.put("tenantId", tenantId); + params1.put("startTime", getFirstDayOfMonth()); + params1.put("endTime", addDay(1)); + params1.put("channelType", 3);//停车 + List list1 = wxCouponActionLogMapper.sceneDataMapJoinCouponOrder(params1); + Map parkCountMap = list1.stream().collect(Collectors.toMap(MarkingSceneDataReportVo::getxTime, p -> p.getTempCount())); + //核销发券被核销数 + HashMap params2 = new HashMap<>(); + params2.put("tenantId", tenantId); + params2.put("startTime", getFirstDayOfMonth()); + params2.put("endTime", addDay(1)); + params2.put("channelType", 4);//核销 + List list2 = wxCouponActionLogMapper.sceneDataMapJoinCouponOrder(params2); + Map verifyCountMap = list2.stream().collect(Collectors.toMap(MarkingSceneDataReportVo::getxTime, p -> p.getTempCount())); + + for (MarkingSceneDataReportVo vo : list) { + vo.setParkCount(parkCountMap.get(vo.getxTime()) == null ? 0 : parkCountMap.get(vo.getxTime())); + vo.setVerifyCount(verifyCountMap.get(vo.getxTime()) == null ? 0 : verifyCountMap.get(vo.getxTime())); + } + + + HashMap returnMap = new HashMap<>(); + returnMap.put("sceneDownDay", sceneDownDay);//比昨日下降 + returnMap.put("sceneUpWeek", sceneUpWeek);//比上周提升 + returnMap.put("todaySceneCount", todaySceneCount);//今日领取数 + returnMap.put("sceneDataMap", list); + return returnMap; + } + + @Override + public PageInfo getCouponDateList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + PageHelper.startPage(pageIndex, pageSize); + List couponDatalist = wxCouponOrderMapper.couponDataList(params); + if(couponDatalist.isEmpty()){ + return new PageInfo<>(couponDatalist); + } + List couponIds = couponDatalist.stream().map(p->p.getCouponId()).distinct().collect(Collectors.toList()); + WxCoupon wxCoupon = new WxCoupon(); + wxCoupon.setTenantId(tenantId); + wxCoupon.setIds(couponIds); + List wxCoupons = wxCouponMapper.findList(wxCoupon); + Map map = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId, p -> p)); + for (MarkingCouponDataReportVo temp:couponDatalist) { + if(map.get(temp.getCouponId())!=null){ + temp.setTitle(map.get(temp.getCouponId()).getTitle()); + String typeName = EnumCouponType.getEnum(map.get(temp.getCouponId()).getType()).getMessage(); + temp.setType(typeName); + } + } + + return new PageInfo<>(couponDatalist); + } + + @Override + public PageInfo getSceneDataList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 + PageHelper.startPage(pageIndex, pageSize); + List templist = wxCouponActionLogMapper.sceneDataList(params); + + List list = new ArrayList<>(); + for (MarkingSceneDataReportVo temp: templist) { + MarkingSceneDataVo vo = new MarkingSceneDataVo(); + vo.setxTime(temp.getxTime()); + if(markingCouponDataReportDto.getType()==1) { + vo.setSendCount(temp.getParkSendCount()); + }else{ + vo.setSendCount(temp.getVerifySendCount()); + } + list.add(vo); + } + + + Map countMap = new HashMap<>(); + + if(markingCouponDataReportDto.getType()==1){ //停车 + //停车发券被核销数 + HashMap params1 = new HashMap<>(); + params1.put("tenantId", tenantId); + params1.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params1.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + params1.put("channelType", 3);//停车 + List list1 = wxCouponActionLogMapper.sceneDataJoinCouponOrderList(params1); + countMap = list1.stream().collect(Collectors.toMap(MarkingSceneDataReportVo::getxTime, p -> p.getTempCount())); + }else{ + //核销发券被核销数 + HashMap params2 = new HashMap<>(); + params2.put("tenantId", tenantId); + params2.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params2.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + params2.put("channelType", 4);//核销 + List list2 = wxCouponActionLogMapper.sceneDataJoinCouponOrderList(params2); + countMap = list2.stream().collect(Collectors.toMap(MarkingSceneDataReportVo::getxTime, p -> p.getTempCount())); + } + + //获取车辆进场数 + HashMap params3 = new HashMap<>(); + params3.put("tenantId", tenantId); + params3.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params3.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + params3.put("cmdType", 601);//核销 + List markingSceneDataVos = wxCarCmdLogMapper.queryForSceneRepotyHistoryCar(params3); + Map carCountMap = markingSceneDataVos.stream().collect(Collectors.toMap(MarkingSceneDataVo::getxTime, p -> p.getCarCount())); + + for (MarkingSceneDataVo vo : list) { + vo.setVerifyCount(countMap.get(vo.getxTime()) == null ? 0 : countMap.get(vo.getxTime())); + vo.setCarCount(carCountMap.get(vo.getxTime()) == null ? 0 : carCountMap.get(vo.getxTime())); + if(vo.getSendCount()==0||vo.getVerifyCount()==0){ + vo.setVerifyPercent(vo.getVerifyCount()+":"+vo.getSendCount()); + }else { + int gcd = gcd(vo.getSendCount(), vo.getVerifyCount()); + vo.setVerifyPercent(vo.getVerifyCount() / gcd + "/" + vo.getSendCount() / gcd); + } + } + return new PageInfo<>(list); + } + + @Override + public PageInfo getTouchUsersReportList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { + //获取领取人数 + //获取领取量 + //获取核销人数 + //核销量 + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + PageHelper.startPage(pageIndex, pageSize); + List couponDatalist = wxCouponOrderMapper.touchUsersReportList(params); + + //查询UV PV + HashMap params1 = new HashMap<>(); + params1.put("tenantId", tenantId); + params1.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); + params1.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + List wxUserVisitList = wxUserVisitMapper.touchUsersReportList(params1); + Map visitMap = wxUserVisitList.stream().collect(Collectors.toMap(TouchUsersReportVo::getxTime, p -> p)); + for (TouchUsersReportVo temp:couponDatalist) { + if(visitMap.get(temp.getxTime())!=null){ + temp.setUv(visitMap.get(temp.getxTime()).getUv()); + temp.setPv(visitMap.get(temp.getxTime()).getPv()); + } + } + return new PageInfo<>(couponDatalist); + } + + @Override + public List getTouchUsersReportData(String tenantId){ + //查询UV PV + HashMap params = new HashMap<>(); + params.put("tenantId", tenantId); + params.put("startTime", getFirstDayOfMonth()); + params.put("endTime", addDay(1)); + List wxUserVisitList = wxUserVisitMapper.touchUsersReportList(params); + return wxUserVisitList; + + } + + + //计算最大公约数 + public int gcd(int x, int y){ // 这个是运用辗转相除法求 两个数的 最大公约数 看不懂可以百度 // 下 + if(y == 0) + return x; + else + return gcd(y,x%y); + } + +} + diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserCarServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserCarServiceImpl.java index b38485901..4173cc93a 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCUserCarServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCUserCarServiceImpl.java @@ -29,7 +29,7 @@ public class WxCUserCarServiceImpl implements WxCUserCarService { @Override public Integer countUserCar(WxCUserCar record) { - return wxCUserCarMapper.selectCount(record); + return wxCUserCarMapper.countList(record); } @Override diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java index e1dbc5676..e083d8242 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java @@ -63,10 +63,18 @@ public class WxCUserServiceImpl implements WxCUserService { } @Override - public long findCountBySex(WxCuerBasicInfoDto dto) { - - return wxCUserMapper.findCountBySex(dto); + public long findCount(WxCuerBasicInfoDto dto) { + return wxCUserMapper.findCount(dto); } + + @Override + public PageInfo listByChannel(List sceneList, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(sceneList)); + } + + + + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCampaignServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCampaignServiceImpl.java index 21709f28f..8f615ac8c 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCampaignServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCampaignServiceImpl.java @@ -1,13 +1,29 @@ package com.simple.service.impl; +import com.alibaba.fastjson.JSONArray; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.ErrorCode; import com.simple.common.IdWorker; import com.simple.domain.po.WxCampaign; +import com.simple.domain.po.WxCoupon; +import com.simple.domain.po.WxCouponChannel; +import com.simple.enums.EnumCouponChannelStatus; +import com.simple.enums.EnumCouponChannelType; +import com.simple.enums.EnumCouponStatus; +import com.simple.exception.MallinkException; import com.simple.mapper.WxCampaignMapper; +import com.simple.mapper.WxCouponChannelMapper; import com.simple.service.WxCampaignService; +import com.simple.service.WxCouponChannelService; +import com.simple.service.WxCouponService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; @Service public class WxCampaignServiceImpl implements WxCampaignService { @@ -15,6 +31,14 @@ public class WxCampaignServiceImpl implements WxCampaignService { @Autowired WxCampaignMapper wxCampaignMapper; + @Autowired + WxCouponChannelMapper wxCouponChannelMapper; + + @Autowired + WxCouponService wxCouponService; + + @Autowired + WxCouponChannelService wxCouponChannelService; @Override public PageInfo listAsPage(WxCampaign record, Integer pageIndex, Integer pageSize) { @@ -26,16 +50,106 @@ public class WxCampaignServiceImpl implements WxCampaignService { return wxCampaignMapper.selectByPrimaryKey(id); } + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Override public void saveOrUpdate(WxCampaign record) { if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); IdWorker idWorker = new IdWorker(0, 0); record.setId(idWorker.nextId()); wxCampaignMapper.insertSelective(record); } else { wxCampaignMapper.updateByPrimaryKeySelective(record); } + record = wxCampaignMapper.selectByPrimaryKey(record); + if (record.getStatus() == 0) + addOrUpdateBatch(JSONArray.parseArray(record.getCouponIds(),String.class),record); + else + delBatch(record); + } + + public void delBatch(WxCampaign record) { + + WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); + wxCouponChannelQuery.setTenantId(record.getTenantId()); + wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); + wxCouponChannelQuery.setSubTargetId(record.getId()); + List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); + if (wxCouponChannels.size() > 0) { + for (WxCouponChannel ch : wxCouponChannels) { + ch.setStatus(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + ch.setUpdateDate(new Date()); + wxCouponChannelMapper.updateByPrimaryKeySelective(ch); + } + } + } + + public void addOrUpdateBatch(List ids, WxCampaign record) { + + WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); + wxCouponChannelQuery.setTenantId(record.getTenantId()); + wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); + wxCouponChannelQuery.setSubTargetId(record.getId()); + List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); + + for (String couponIdStr:ids) { + Long couponId = Long.parseLong(couponIdStr); + saveOrUpdateCouponChannel(couponId, wxCouponChannels, record); + } + + if (wxCouponChannels.size() > 0) + { + for (int i = 0; i < wxCouponChannels.size(); i++) { + wxCouponChannels.get(i).setStatus(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + wxCouponChannels.get(i).setUpdateDate(new Date()); + wxCouponChannelMapper.updateByPrimaryKeySelective(wxCouponChannels.get(i)); + } + + } + } + + public void saveOrUpdateCouponChannel(Long couponId, List wxCouponChannels, WxCampaign record){ + + WxCoupon wxCoupon = wxCouponService.getById(couponId); + if (wxCoupon == null) { + throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); + } + if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { + throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); + } + if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) { + throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); + } + + + for (int i = 0; i < wxCouponChannels.size(); i++) { + if (wxCouponChannels.get(i).getCouponId().longValue() == couponId.longValue()) { + wxCouponChannels.get(i).setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + wxCouponChannels.get(i).setBeginTime(record.getValidStartDate()); + wxCouponChannels.get(i).setEndTime(record.getValidEndDate()); + wxCouponChannels.get(i).setUpdateDate(new Date()); + wxCouponChannelMapper.updateByPrimaryKeySelective(wxCouponChannels.get(i)); + wxCouponChannels.remove(i); + return; + } + } + + + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setBeginTime(record.getValidStartDate()); + wxCouponChannel.setEndTime(record.getValidEndDate()); + wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + wxCouponChannel.setCouponId(couponId); + wxCouponChannel.setMerchantId(wxCoupon.getMerchantId()); + wxCouponChannel.setType(wxCoupon.getType()); + wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); + wxCouponChannel.setTenantId(wxCoupon.getTenantId()); + wxCouponChannel.setBusiness(wxCoupon.getBusiness()); + wxCouponChannel.setTitle(wxCoupon.getTitle()); + wxCouponChannel.setSubTargetId(record.getId()); + final IdWorker idWorker = IdWorker.get(); + wxCouponChannel.setId(idWorker.nextId()); + wxCouponChannelMapper.insertSelective(wxCouponChannel); + } @Override diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java index 584a3fdd3..8f649b517 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java @@ -1,14 +1,14 @@ package com.simple.service.impl; -import java.util.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponCar; +import com.simple.domain.vo.WxCouponCarVo; import com.simple.mapper.WxCouponCarMapper; import com.simple.service.WxCouponCarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.simple.common.IdWorker; @Service public class WxCouponCarServiceImpl implements WxCouponCarService { @@ -28,25 +28,35 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { } @Override - public void saveOrUpdate(WxCouponCar record) { - if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); - final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + public void save(WxCouponCar record) { wxCouponCarMapper.insertSelective(record); - } else { - wxCouponCarMapper.updateByPrimaryKeySelective(record); - } + } + + @Override + public void update(WxCouponCar record) { + wxCouponCarMapper.updateByPrimaryKey(record); } @Override public void deleteById(Long id) { wxCouponCarMapper.deleteByPrimaryKey(id); } - - - - + + + @Override + public Integer getAmtCountByTemplateId(Long templateId) { + return wxCouponCarMapper.findTemplateAmtCount(templateId); + } + + @Override + public Integer getAvaibleCountByTemplateId(Long templateId) { + return wxCouponCarMapper.findTemplateAvailCount(templateId); + } + + @Override + public WxCouponCarVo getByCoupon(WxCoupon coupon) { + return wxCouponCarMapper.selectCouponCarDetail(coupon); + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java index 1de28ed00..3ea46f8ff 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java @@ -5,6 +5,8 @@ import java.util.stream.Collectors; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.Result; +import com.simple.common.ResultData; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponChannelVo; @@ -62,14 +64,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public void addBatch(String[] ids,String[] channelId,String tanantId,Date beginTime,Date endTime) { + public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { + boolean result = false; for (String targetIdstr:channelId) { Integer targetId = Integer.parseInt(targetIdstr); for (String couponidstr:ids) { Long couponid = Long.parseLong(couponidstr); - addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); + boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); + if(addResult){ + result = true; + } } } + if(result) { + return new ResultData(); + }else { + return new ResultData(Result.ERROR,"请确认券状态,及有效期"); + } } @@ -82,8 +93,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setCouponId(couponId); } - @Transactional - public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ + + public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); wxCouponChannelQuery.setTenantId(tanantId); @@ -93,18 +104,22 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); if(wxCouponChannels.size()>0){ logger.debug(couponid+"已经投放过了"); - return; + return false; } WxCoupon wxCoupon = wxCouponService.getById(couponid); + if(wxCoupon==null){ + logger.debug(couponid+"没有查到对应的券信息"); + return false; + } if(wxCoupon.getStatus()!=0) { logger.debug(wxCoupon.getId()+"状态不对"); - return; + return false; } - if(wxCoupon.getValidEndDate().before(endTime)){ + if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){ logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间"); - return; + return false; } WxCouponChannel wxCouponChannel = new WxCouponChannel(); wxCouponChannel.setEndTime(endTime); @@ -119,6 +134,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setBusiness(wxCoupon.getBusiness()); wxCouponChannel.setTitle(wxCoupon.getTitle()); saveOrUpdate(wxCouponChannel); + return true; } /** @@ -149,5 +165,24 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new PageInfo<>(wxCouponChannelVoList); } + @Override + public List listAPI(WxCouponChannel record) { + List wxCouponChannelVoList = new ArrayList<>(); + wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); + if(wxCouponChannelVoList.isEmpty()){ + return wxCouponChannelVoList; + } + List couponIds = wxCouponChannelVoList.stream().map(p->p.getCouponId()).distinct().collect(Collectors.toList()); + WxCoupon wxCoupon = new WxCoupon(); + wxCoupon.setIds(couponIds); + List wxCoupons = wxCouponService.findList(wxCoupon); + Map couponNamesMap = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId,p->p)); + for (WxCouponChannelVo wxcouponVo:wxCouponChannelVoList) { + if(couponNamesMap.get(wxcouponVo.getCouponId())!=null){ + wxcouponVo.setWxCoupon(couponNamesMap.get(wxcouponVo.getCouponId())); + } + } + return wxCouponChannelVoList; + } } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java index 258231995..f17de51c1 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java @@ -1,25 +1,30 @@ package com.simple.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.simple.common.ErrorCode; import com.simple.common.IdWorker; -import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.*; -import com.simple.domain.vo.WxCouponOrderBVo; import com.simple.domain.vo.WxCouponOrderCVo; import com.simple.enums.EnumCouponOrderStatus; -import com.simple.enums.EnumCouponStatus; import com.simple.exception.MallinkException; import com.simple.mapper.*; import com.simple.service.WxCouponOrderService; import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.Workbook; +import org.aspectj.apache.bcel.classfile.ConstantString; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -134,7 +139,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { if(isVerified) list = wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); else - list = wxCouponOrderMapper.findListOfUnverifiedByDate(dateMap); + list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); int total_price = 0; for (WxCouponOrder couponOrder : list) { @@ -146,27 +151,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { if (isVerified) resultMap.put("list", PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfVerifiedByDateForBUser(dateMap))); else - resultMap.put("list", PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfUnverifiedByDateForBUser(dateMap))); + resultMap.put("list", PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfOrderedByDateForBUser(dateMap))); } return new ResultData(resultMap); } @Override - public ResultData listCUserVoAsPage(Long cUserId, Integer status, Integer pageIndex, Integer pageSize) { + public ResultData listCUserVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { - WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); - if(wxCuser == null){ - logger.error("用户不存在:"+ cUserId); - throw new MallinkException(ErrorCode.USER_IS_EMPTY); - } - - Map paramMap = new HashMap(); - paramMap.put("cUserId", cUserId); - paramMap.put("tenantId", wxCuser.getTenantId()); - if (status != null) - paramMap.put("status", status); - - return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUser(paramMap))); + return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUser(record))); } @Override @@ -182,7 +175,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { paramMap.put("tenantId", wxCuser.getTenantId()); paramMap.put("couponOrderId", couponOrderId); - WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfCUser(paramMap); + WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfUser(paramMap); if (wxCouponOrderCVo == null) return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); return new ResultData(wxCouponOrderCVo); @@ -206,7 +199,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { paramMap.put("merchantId", wxMerchant.getId()); paramMap.put("tenantId", wxMerchant.getTenantId()); paramMap.put("couponOrderId", couponOrderId); - WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfCUser(paramMap); + WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfUser(paramMap); if (wxCouponOrderCVo == null) return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); return new ResultData(wxCouponOrderCVo); @@ -218,6 +211,66 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfAdmin(wxCouponOrder))); } + @Override + public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { + WxCouponOrder wxCouponOrder = new WxCouponOrder(); + wxCouponOrder.setTenantId(tenantId); + List list = wxCouponOrderMapper.findList(wxCouponOrder); + + String filepath="./uploads/"; + File savefile = new File(filepath); + if (!savefile.exists()) { + savefile.mkdirs(); + } + + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), WxCouponOrder.class, list); + FileOutputStream fos = null; + try { + String filename=UUID.randomUUID()+".xlsx"; + filepath=filepath+filename; + fos = new FileOutputStream(filepath); + workbook.write(fos); + fos.close(); + downFile(filepath,filename,response,request); + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + + public void downFile(String filePath,String filename, HttpServletResponse response, + HttpServletRequest req) throws IOException { + try { + response.reset(); + response.setContentType("bin"); + String agent = req.getHeader("user-agent"); + if (agent.contains("Firefox")) { + response.setHeader("Content-disposition", + "attachment; filename=" + + new String(filename.getBytes("GB2312"), + "ISO-8859-1")); + } else { + response + .setHeader("Content-disposition", + "attachment; filename=" + + java.net.URLEncoder.encode(filename, + "UTF-8")); + } + // 循环取出流中的数据 + byte[] b = new byte[1024]; + int len; + InputStream inStream = new FileInputStream(filePath); + while ((len = inStream.read(b)) > 0) + response.getOutputStream().write(b, 0, len); + inStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public ResultData verify(Long couponOrderId, Long bUserId) { diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java index 5f131c8d1..0e5eab49d 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java @@ -6,15 +6,14 @@ import com.github.pagehelper.PageInfo; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponOrder; import com.simple.domain.po.WxCouponSend; +import com.simple.domain.po.WxMallConfig; import com.simple.mapper.WxCouponSendMapper; -import com.simple.service.WxCouponActionLogService; -import com.simple.service.WxCouponOrderService; -import com.simple.service.WxCouponSendService; -import com.simple.service.WxCouponService; +import com.simple.service.*; import org.apache.commons.lang.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.simple.common.IdWorker; +import org.springframework.transaction.annotation.Transactional; @Service public class WxCouponSendServiceImpl implements WxCouponSendService { @@ -27,6 +26,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { WxCouponService wxCouponService; @Autowired WxCouponActionLogService wxCouponActionLogService; + @Autowired + WxMallConfigService wxMallConfigService; @Override @@ -57,24 +58,40 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { } @Override + @Transactional public void sendCouponToUser(String tenantId, Long cUserId, int type) { //查询开关是否打开 - //查询停车或者核销的券 + //查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch WxCouponSend wxCouponSendQuery = new WxCouponSend(); wxCouponSendQuery.setTenantId(tenantId); int actionLogType=0; + String configKey=""; if(type==2){ //停车 wxCouponSendQuery.setSendType(2); actionLogType=3; + configKey="stopCarCouponSwitch"; } if(type==3){ //核销 wxCouponSendQuery.setSendType(3); actionLogType=4; + configKey="verifyConponSwitch"; }else{ return; } + WxMallConfig wxMallConfigQuery = new WxMallConfig(); + wxMallConfigQuery.setKey(configKey); + wxMallConfigQuery.setTenantId(tenantId); + PageInfo page = wxMallConfigService.listAsPage(wxMallConfigQuery, 1, 1); + if(page.getSize()>0) { + WxMallConfig config = page.getList().get(0); + if(config.getValue()==1){ + return; + } + } + + List wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery); for (WxCouponSend send:wxCouponSends) { WxCoupon wxCoupon= wxCouponService.getById(send.getCouponId()); @@ -85,6 +102,9 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { wxCouponOrder.setCouponPrice(0); wxCouponOrder.setCreateDate(new Date()); if (wxCoupon.getValidType() == 1) { //时间范围区间 + if(new Date().after(wxCoupon.getValidEndDate())){ + continue; + } wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); } else { Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); @@ -93,10 +113,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { wxCouponOrder.setTenantId(wxCoupon.getTenantId()); Long couponOrderId = wxCouponOrderService.insertOne(wxCouponOrder); wxCouponActionLogService.addOne(tenantId, wxCoupon.getId(), couponOrderId, actionLogType, send.getId()); + wxCouponService.reduceInventory(wxCoupon.getId(),1); } - - - } @Override diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java index 727572056..154ccd4bf 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java @@ -22,13 +22,13 @@ import org.springframework.transaction.annotation.Transactional; @Service public class WxCouponServiceImpl implements WxCouponService { - - @Autowired + + @Autowired WxCouponMapper wxCouponMapper; - @Autowired + @Autowired WxCouponChannelService wxCouponChannelService; - @Autowired + @Autowired WxCouponSendService wxCouponSendService; @@ -37,11 +37,6 @@ public class WxCouponServiceImpl implements WxCouponService { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMapper.findList(record)); } - @Override - public PageInfo findEnableList(WxCoupon record, Integer pageIndex, Integer pageSize) { - return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMapper.findEnableList(record)); - } - @Override public List findList(WxCoupon record) { return wxCouponMapper.findList(record); @@ -57,7 +52,7 @@ public class WxCouponServiceImpl implements WxCouponService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + record.setId(idWorker.nextId()); wxCouponMapper.insertSelective(record); } else { wxCouponMapper.updateByPrimaryKeySelective(record); @@ -70,30 +65,35 @@ public class WxCouponServiceImpl implements WxCouponService { wxCouponMapper.deleteByPrimaryKey(id); } - @Override - public PageInfo findCanSendList(WxCoupon record, Integer pageIndex, Integer pageSize) { - return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMapper.findCanSendList(record)); - } @Override public WxCouponCVo selectDetailForCUser(WxCouponChannel record) { return wxCouponMapper.selectDetailForCUser(record); } + @Override + public WxCouponCVo selectDetailForCUser(WxCoupon record) { + return wxCouponMapper.selectDetailForCUserC(record); + } @Override @Transactional public ResultData updateCoupon(WxCoupon wxCoupon) { WxCoupon query = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); - if(wxCoupon.getStatus()!=null){ - if(wxCoupon.getStatus()==1){ //已作废 + if (wxCoupon.getStatus() != null) { + if (query.getStatus() == 0 && wxCoupon.getStatus() == 1) { //作废所有投放频道 - wxCouponChannelService.updateStatusByCouponId(wxCoupon.getId(),query.getTenantId(),1); - wxCouponSendService.updateStatusByCouponId(query.getId(),query.getTenantId(),1); + wxCouponChannelService.updateStatusByCouponId(wxCoupon.getId(), query.getTenantId(), 1); + wxCouponSendService.updateStatusByCouponId(query.getId(), query.getTenantId(), 1); } } return new ResultData(saveOrUpdate(wxCoupon)); } + @Override + public void reduceInventory(Long id, Integer number) { + wxCouponMapper.reduceInventory(id,number); + } + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java index 0ec1a8ef5..f5833eeb7 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java @@ -4,12 +4,10 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.simple.common.ErrorCode; import com.simple.common.IdWorker; -import com.simple.common.ResultData; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponOrder; import com.simple.domain.po.WxOrder; -import com.simple.domain.vo.WxCouponOrderCVo; import com.simple.domain.vo.WxOrderCVo; import com.simple.enums.*; import com.simple.exception.MallinkException; @@ -22,10 +20,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.util.Calendar; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; @Service public class WxOrderServiceImpl implements WxOrderService { @@ -75,7 +72,7 @@ public class WxOrderServiceImpl implements WxOrderService { orderQ.setCUserId(user.getId()); orderQ.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); try { - countOrder = wxOrderMapper.selectCount(orderQ); + countOrder = wxOrderMapper.countList(orderQ); } catch (Exception e) { logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage()); throw new MallinkException(ErrorCode.ORDER_IS_FAIL); @@ -86,7 +83,7 @@ public class WxOrderServiceImpl implements WxOrderService { couponOrderQ.setCUserId(user.getId()); couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); try { - countCouponOrder = wxCouponOrderMapper.selectCount(couponOrderQ); + countCouponOrder = wxCouponOrderMapper.countList(couponOrderQ); } catch (Exception e) { logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage()); throw new MallinkException(ErrorCode.ORDER_IS_FAIL); @@ -122,7 +119,7 @@ public class WxOrderServiceImpl implements WxOrderService { throw new MallinkException(ErrorCode.DB_FAIL); } - if (count > coupon.getUseLimitQuantity()) { + if (count >= coupon.getUseLimitQuantity()) { //解锁 redisLock.unlock(couponIdStr, timeStr); logger.error("此券购买数量已超限, couponId: " + couponIdStr + ", count: " + count); @@ -161,11 +158,11 @@ public class WxOrderServiceImpl implements WxOrderService { coupon = wxCouponMapper.selectByPrimaryKey(couponId); } catch (Exception e) { logger.error("券未找到, e:" + e.getMessage()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券未找到:" + couponIdStr); + throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); } if (coupon == null) { logger.error("券未找到, " + couponIdStr); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券未找到:" + couponIdStr); + throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); } coupon.setRemainInventory(coupon.getRemainInventory() + 1); @@ -173,8 +170,8 @@ public class WxOrderServiceImpl implements WxOrderService { try { wxCouponMapper.updateByPrimaryKeySelective(coupon); } catch (Exception e) { - logger.error("库存+1失败, e:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "库存+1失败, e:" + e.getMessage()); + logger.error("数据库更新失败,库存+1失败, e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "库存恢复失败"); } finally { //解锁 redisLock.unlock(couponIdStr, timeStr); @@ -214,12 +211,7 @@ public class WxOrderServiceImpl implements WxOrderService { */ // 减库存操作 - try { - stockReduce(user, coupon, couponIdStr); - } catch (Exception e) { - logger.error("减库存失败, couponId: " + couponIdStr); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), "减库存失败, couponId: " + couponIdStr); - } + stockReduce(user, coupon, couponIdStr); Date curr = new Date(); @@ -250,10 +242,10 @@ public class WxOrderServiceImpl implements WxOrderService { // 保存订单 wxOrderMapper.insertSelective(record); } catch (RuntimeException e) { - // 加库存 + // 库存恢复 stockBack(record); logger.error("保存订单:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), "保存订单失败:" + record.toString()); + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } return record; @@ -268,28 +260,44 @@ public class WxOrderServiceImpl implements WxOrderService { */ private void createCouponOrder(WxCUser user, WxOrder order, WxCoupon coupon) { Date curr = new Date(); - Date valid_date = (coupon.getValidType() == EnumValidStatus.VALID_RANGE.getCode()) ? - coupon.getValidEndDate() : - new Date((curr.getTime() / 1000 + coupon.getValidDays() * 24 * 60 * 60) * 1000); - final IdWorker idWorker = IdWorker.get(); - try { - WxCouponOrder couponOrder = new WxCouponOrder(); - couponOrder.setId(idWorker.nextId()); - couponOrder.setTenantId(user.getTenantId()); - couponOrder.setCouponId(order.getCouponId()); - couponOrder.setCUserId(user.getId()); - couponOrder.setOrderId(order.getOrderNumber()); - couponOrder.setExpiredTime(valid_date); - couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); - couponOrder.setCreateDate(curr); - couponOrder.setUpdateDate(curr); - couponOrder.setCouponPrice(order.getPayment()); - - wxCouponOrderMapper.insertSelective(couponOrder); - } catch (RuntimeException e) { - logger.error("WxCouponOrder:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), "couponOrder保存失败!"); + Date valid_date = null; + if (coupon.getValidType() == EnumValidStatus.VALID_RANGE.getCode()) + valid_date = coupon.getValidEndDate(); + else { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(curr); + if (coupon.getType() != EnumCouponType.COUPON_TINGCHE.getCode()) { + // 普通券精确到天 + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.add(Calendar.DAY_OF_MONTH, 1+coupon.getValidDays()); + valid_date = calendar.getTime(); + } else { + // 停车券过期日期到月 + calendar.set(Calendar.DAY_OF_MONTH, 0); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.add(Calendar.MONTH, 1); + valid_date = calendar.getTime(); + } } + final IdWorker idWorker = IdWorker.get(); + + WxCouponOrder couponOrder = new WxCouponOrder(); + couponOrder.setId(idWorker.nextId()); + couponOrder.setTenantId(user.getTenantId()); + couponOrder.setCouponId(order.getCouponId()); + couponOrder.setCUserId(user.getId()); + couponOrder.setOrderId(order.getOrderNumber()); + couponOrder.setExpiredTime(valid_date); + couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); + couponOrder.setCreateDate(curr); + couponOrder.setUpdateDate(curr); + couponOrder.setCouponPrice(order.getPayment()); + + wxCouponOrderMapper.insertSelective(couponOrder); } @Override @@ -315,7 +323,7 @@ public class WxOrderServiceImpl implements WxOrderService { } if (coupon.getStatus() == EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()) { logger.error("券已下架, couponId: " + couponIdStr); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); + throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); } if (coupon.getSalePrice() != 0) { logger.error("券不免费, couponId: " + couponIdStr); @@ -350,21 +358,22 @@ public class WxOrderServiceImpl implements WxOrderService { try { wxOrderMapper.insertSelective(record); } catch (Exception e) { - //加库存 + // 库存恢复 stockBack(record); logger.error("保存订单:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL); + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } // 创建couponOrder try { createCouponOrder(user, record, coupon); } catch (Exception e) { + // 库存恢复 + stockBack(record); logger.error("保存订单:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL); + throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); } - return record; } @@ -379,7 +388,7 @@ public class WxOrderServiceImpl implements WxOrderService { } if (coupon.getStatus() == EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()) { logger.error("券已下架, couponId: " + updateOrder.getCouponId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); + throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); } WxCUser user = wxCUserMapper.selectByPrimaryKey(updateOrder.getCUserId()); if (user == null) { @@ -395,14 +404,14 @@ public class WxOrderServiceImpl implements WxOrderService { ret = wxOrderMapper.updateByPrimaryKey(updateOrder); } catch (Exception e) { logger.error("订单更新失败:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), "订单更新失败:" + e.getMessage()); + throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); } // 创建couponOrder try { createCouponOrder(user, updateOrder, coupon); } catch (Exception e) { logger.error("保存订单:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_IS_FAIL); + throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); } return ret; } @@ -418,19 +427,19 @@ public class WxOrderServiceImpl implements WxOrderService { stockBack(updateOrder); } catch (Exception e) { logger.error("库存+1失败, e:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "库存+1失败, e:" + e.getMessage()); + throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); } break; } } + updateOrder.setOrderStatus(enumOrderStatus.getCode()); + updateOrder.setUpdateDate(currentDate); int ret = 0; try { - updateOrder.setOrderStatus(enumOrderStatus.getCode()); - updateOrder.setUpdateDate(currentDate); ret = wxOrderMapper.updateByPrimaryKey(updateOrder); } catch (Exception e) { logger.error("订单状态更新失败, e:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单状态更新失败, e:" + e.getMessage()); + throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); } return ret; } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java new file mode 100644 index 000000000..51fc512eb --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/WxUserChannelServiceImpl.java @@ -0,0 +1,56 @@ +package com.simple.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserChannel; +import com.simple.mapper.WxUserChannelMapper; +import com.simple.service.WxUserChannelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.simple.common.IdWorker; + +@Service +public class WxUserChannelServiceImpl implements WxUserChannelService { + + @Autowired + WxUserChannelMapper wxUserChannelMapper; + + + @Override + public PageInfo listAsPage(WxUserChannel record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxUserChannelMapper.findList(record)); + } + + @Override + public WxUserChannel getById(Long id) { + return wxUserChannelMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(WxUserChannel record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + IdWorker idWorker = new IdWorker(0, 0); + record.setId(idWorker.nextId()); + wxUserChannelMapper.insertSelective(record); + } else { + wxUserChannelMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + wxUserChannelMapper.deleteByPrimaryKey(id); + } + + @Override + public List findDistinctChannel() { + + return wxUserChannelMapper.findDistinctChannel(); + } + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxUserVisitServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxUserVisitServiceImpl.java new file mode 100644 index 000000000..501afb646 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/WxUserVisitServiceImpl.java @@ -0,0 +1,60 @@ +package com.simple.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxUserVisit; +import com.simple.domain.vo.TouchUsersReportVo; +import com.simple.mapper.WxUserVisitMapper; +import com.simple.service.WxUserVisitService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.simple.common.IdWorker; + +@Service +public class WxUserVisitServiceImpl implements WxUserVisitService { + + @Autowired + WxUserVisitMapper wxUserVisitMapper; + + + @Override + public PageInfo listAsPage(WxUserVisit record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxUserVisitMapper.findList(record)); + } + + @Override + public WxUserVisit getById(Long id) { + return wxUserVisitMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(WxUserVisit record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + IdWorker idWorker = new IdWorker(0, 0); + record.setId(idWorker.nextId()); + wxUserVisitMapper.insertSelective(record); + } else { + wxUserVisitMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + wxUserVisitMapper.deleteByPrimaryKey(id); + } + + @Override + public List touchUsersReportList(HashMap params) { + return wxUserVisitMapper.touchUsersReportList(params); + } + + + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml index 65e963ceb..44004949b 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml @@ -71,5 +71,10 @@ select from wx_c_user_car + + diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml index c247c6fe4..08aacf5f6 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -184,13 +184,31 @@ where `token` = #{token} - + select count(id) from wx_c_user where 1=1 + + and gender =#{sex} + and create_date >= #{startTime} and create_date <= #{endTime} + + and tenant_id =#{tenantId} + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml index 43572c99e..89068300b 100644 --- a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml @@ -84,6 +84,13 @@ and create_date BETWEEN #{startdate} and #{enddate} ) c group by c.create_time + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index 2ce37552e..bb81f2d06 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -71,10 +71,37 @@ select from wx_coupon_action_log - - - - - - + + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml index 593463c99..f5e196b62 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml @@ -71,9 +71,71 @@ select from wx_coupon_car - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, + car.vendor_type, car.vendor_params + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index b6193895e..e5c7c516d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -15,10 +15,11 @@ + - `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`begin_time`,`end_time`,`status`,`create_date`,`update_date` + `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`begin_time`,`end_time`,`status`,`create_date`,`update_date`,`sub_target_id` @@ -88,6 +89,10 @@ and `update_date` = #{updateDate} + + + and `sub_target_id` = #{subTargetId} + and id in @@ -137,11 +142,21 @@ + + + update wx_coupon_channel SET status = 1, update_date = now() + where status = 0 and end_time < now() + + + + update wx_coupon_channel, wx_coupon c SET cc.status = 1, cc.update_date = now() + where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now(); + diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 27806625e..8dd689d7c 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -20,6 +20,7 @@ + @@ -30,7 +31,7 @@ - `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business` + `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business` @@ -126,8 +127,13 @@ and `price` = #{price} - - + + + + and `unit` = #{unit} + + + and `remain_inventory` = #{remainInventory} @@ -171,296 +177,13 @@ order by ${sortColumns} - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `merchant_id` = #{merchantId} - - - - - and `type` = #{type} - - - - - and `cover_img` like concat('%', #{coverImg},'%') - - - - - and `title` like concat('%', #{title},'%') - - - - - and `sub_title` like concat('%', #{subTitle},'%') - - - - - and `sale_price` = #{salePrice} - - - - - and `use_price` = #{usePrice} - - - - - and `use_limit_quantity` = #{useLimitQuantity} - - - - - and `target_ad` = #{targetAd} - - - - - and `send_type` = #{sendType} - - - - - - - and `valid_type` = #{validType} - - - - - and `valid_start_date` = #{validStartDate} - - - - - and `valid_end_date` = #{validEndDate} - - - - - and `valid_days` = #{validDays} - - - - - and `detail` like concat('%', #{detail},'%') - - - - - and `price` = #{price} - - - - - and `remain_inventory` = #{remainInventory} - - - - - and `inventory` = #{inventory} - - - - - and `remark` like concat('%', #{remark},'%') - - - - - and `status` =0 - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - - and `business` like concat('%', #{business},'%') - - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - where 1 = 1 - - - and `id` = #{id} - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `merchant_id` = #{merchantId} - - - - - and `type` = #{type} - - - - - and `cover_img` like concat('%', #{coverImg},'%') - - - - - and `title` like concat('%', #{title},'%') - - - - - and `sub_title` like concat('%', #{subTitle},'%') - - - - - and `sale_price` = #{salePrice} - - - - - and `use_price` = #{usePrice} - - - - - and `use_limit_quantity` = #{useLimitQuantity} - - - - - and `target_ad` = #{targetAd} - - - - - and `send_type` = #{sendType} - - - - - - and `valid_type` = #{validType} - - - - - and `valid_start_date` = #{validStartDate} - - - - - and `valid_end_date` = #{validEndDate} - - - - - and `valid_days` = #{validDays} - - - - - and `detail` like concat('%', #{detail},'%') - - - - - and `price` = #{price} - - - - - and `remain_inventory` = #{remainInventory} - - - - - and `inventory` = #{inventory} - - - - - and `remark` like concat('%', #{remark},'%') - - - - - and `status` =0 - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - - and `business` like concat('%', #{business},'%') - - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - @@ -487,6 +210,7 @@ + @@ -509,7 +233,7 @@ - c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, + c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, m.img_url,m.name,m.link_phone,m.status, s.addr,s.shop_number,s.baidu_poi, mb.building_name,mf.floor_name, @@ -540,6 +264,36 @@ and cc.target_ad = #{targetAd} - - + + + + + c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, + m.img_url,m.name,m.link_phone,m.status, + s.addr,s.shop_number,s.baidu_poi, + mb.building_name,mf.floor_name + + + + + update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index e86ec8828..633ab599b 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -90,6 +90,11 @@ + + @@ -123,7 +128,7 @@ bu.name,cu.phone - + co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.type,c.title,c.sale_price,c.use_price,c.price, cu.phone @@ -133,8 +138,8 @@ co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price - + select from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu where o.id = co.order_id and o.merchant_id = #{merchantID} @@ -143,10 +148,10 @@ AND co.create_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.create_date < #{endDate,jdbcType=TIMESTAMP} - AND co.coupon_order_status = '0' + AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') order by co.create_date desc @@ -162,7 +167,7 @@ AND co.update_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.update_date < #{endDate,jdbcType=TIMESTAMP} AND co.coupon_order_status = '1' @@ -170,12 +175,11 @@ - select from wx_coupon_order co,wx_order o where o.id = co.order_id @@ -246,10 +250,10 @@ AND co.create_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.create_date < #{endDate,jdbcType=TIMESTAMP} - AND co.coupon_order_status = '0' + AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') @@ -261,7 +265,7 @@ AND co.update_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.update_date < #{endDate,jdbcType=TIMESTAMP} AND co.coupon_order_status = '1' @@ -324,28 +328,25 @@ - select from wx_coupon_order c,wx_coupon co,wx_merchant m where 1=1 + and c.coupon_id = co.id + and co.merchant_id = m.id and c.c_user_id = #{cUserId} - - and co.merchant_id = #{merchantId} - and c.tenant_id = #{tenantId} - and c.coupon_id = co.id - and co.merchant_id = m.id - - AND c.coupon_order_status = #{status} + + AND c.coupon_order_status = #{couponOrderStatus} - order by c.create_date desc + order by ${sortColumns} - select from wx_coupon_order c,wx_coupon co,wx_merchant m left join wx_merchant_shop ms on ms.merchant_id = m.id @@ -369,6 +370,61 @@ + + + + + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxMallMapper.xml b/mallinkService/src/main/resources/mapper/WxMallMapper.xml index 43a2928e6..251779e4e 100644 --- a/mallinkService/src/main/resources/mapper/WxMallMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMallMapper.xml @@ -18,11 +18,13 @@ - + + + - `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`,`img_url` + `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`,`img_url`,`wiwide_key`,`wiwide_url` diff --git a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml index 81877325f..50ac00a0f 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml @@ -108,6 +108,11 @@ + + @@ -131,7 +138,8 @@ co.type,co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.detail,co.remark, m.img_url,m.name,m.link_phone,m.status, s.addr,s.shop_number,s.baidu_poi, - mb.building_name,mf.floor_name + mb.building_name,mf.floor_name, + c.id as coupon_order_id,c.coupon_order_status @@ -160,6 +168,9 @@ + + + @@ -192,7 +203,8 @@ + select from wx_user_channel + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml b/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml new file mode 100644 index 000000000..8354338b7 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`ref_date`,`day_date`,`session_cnt`,`visit_pv`,`visit_uv`,`visit_uv_new`,`stay_time_uv`,`stay_time_session`,`visit_depth`,`app_id`,`create_date` + + + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` =#{tenantId} + + + + + and `ref_date` = #{refDate} + + + + + and `day_date` = #{dayDate} + + + + + and `session_cnt` = #{sessionCnt} + + + + + and `visit_pv` = #{visitPv} + + + + + and `visit_uv` = #{visitUv} + + + + + and `visit_uv_new` = #{visitUvNew} + + + + + and `stay_time_uv` like concat('%', #{stayTimeUv},'%') + + + + + and `stay_time_session` like concat('%', #{stayTimeSession},'%') + + + + + and `visit_depth` like concat('%', #{visitDepth},'%') + + + + + and `app_id` = #{appId} + + + + + and `create_date` = #{createDate} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + diff --git a/pom.xml b/pom.xml index 53c9af695..15864e45c 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.9.RELEASE + 1.5.15.RELEASE @@ -32,6 +32,16 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.springframework.boot + spring-boot-starter-undertow org.springframework.boot