| @@ -0,0 +1,55 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserCar; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| import com.iformall.service.WxCUserCarService; | |||
| import com.iformall.service.WxCUserFromService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCUserFrom") | |||
| public class WxCUserFromController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserFromService wxCUserFromService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "停车-列表") | |||
| public ResultData list(@ModelAttribute WxCUserFrom wxCUserFrom, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsPage(wxCUserFrom, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/visits") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "停车-查询") | |||
| public ResultData visits(@ModelAttribute WxCUserFrom wxCUserFrom,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsVisitsPage(wxCUserFrom, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| --加预购菜单 | |||
| INSERT INTO `mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (514, '推广数据', 5, 'Y', NULL, 1, NULL, NULL, 'memberImport', 'icon-tuiguang', 0, 503); | |||
| --销售类型加权限 | |||
| update mall_sale_type set menus = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 201, 202, 203, 204, 205, 206, 209, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004]' where id=1; | |||
| update mall_sale_type set menus = '[1, 2, 4, 5, 6, 7, 8, 9, 10, 50, 101, 102, 103, 104, 105, 106, 107, 201, 202, 203, 204, 205, 209, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932, 951, 961]' where id=2; | |||
| update mall_sale_type set menus = '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932]' where id=3; | |||
| update mall_sale_type set menus = '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 514, 521, 522, 523, 531, 532, 591, 601, 602, 604, 605, 606, 607, 608, 610, 611, 612, 622, 623, 624, 625, 626, 641, 642, 643, 644, 661, 662, 663, 664, 671, 672, 674, 675, 681, 682, 684, 685, 686, 691, 692, 693, 694, 695, 711, 901, 902, 904, 905, 931, 932]' where id=4; | |||
| --所有广场管理员角色加权限 | |||
| INSERT INTO `mall_role_permission`(`id`, `tenant_id`, `parent_tenant_id`, `permission_id`, `role_id`) | |||
| select CEILING(RAND()*90000000000+10000000000) ,mui.tenant_id,mui.parent_tenant_id, 514,mur.role_id | |||
| from mall_user_info mui | |||
| left join mall_user_role mur on mui.id = mur.uid | |||
| where mui.is_admin = 1 and mur.role_id is not null GROUP BY mur.role_id; | |||
| @@ -27,6 +27,9 @@ public class WxCUserFrom extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserNickName",name="cUserNickName") | |||
| protected String cUserNickName; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserPhone",name="cUserPhone") | |||
| protected String cUserPhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") | |||
| private String scene; | |||
| @@ -57,6 +60,9 @@ public class WxCUserFrom extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源Name",name="fromName") | |||
| protected String fromName; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源phone",name="fromPhone") | |||
| protected String fromPhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户(0:否1:是)EnumYesOrNo",name="isNewUser") | |||
| private Integer isNewUser; | |||
| @@ -97,6 +103,27 @@ public class WxCUserFrom extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="推广人次",name="visits") | |||
| private Integer visits; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达用户",name="reachUser") | |||
| private Integer reachUser; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达新用户",name="newUser") | |||
| private Integer newUser; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达老用户",name="oldUser") | |||
| private Integer oldUser; | |||
| public Integer getOldUser(){ | |||
| if(this.getReachUser() != null && this.getNewUser() != null){ | |||
| oldUser = this.getReachUser() - this.getNewUser(); | |||
| } | |||
| return oldUser; | |||
| } | |||
| @TableField(exist = false) | |||
| protected Date startDate; | |||
| @@ -9,4 +9,5 @@ public interface WxCUserFromMapper extends CommonMapper<WxCUserFrom, Long>{ | |||
| List<WxCUserFrom> findList(WxCUserFrom record); | |||
| List<WxCUserFrom> visits(WxCUserFrom record); | |||
| } | |||
| @@ -15,6 +15,9 @@ public interface WxCUserFromService { | |||
| */ | |||
| PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxCUserFrom> listAsVisitsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | |||
| void save(WxCUserFrom wxCUserFrom); | |||
| } | |||
| @@ -29,6 +29,11 @@ public class WxCUserFromServiceImpl implements WxCUserFromService { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PageInfo<WxCUserFrom> listAsVisitsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.visits(record)); | |||
| } | |||
| @Override | |||
| public void save(WxCUserFrom wxCUserFrom) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -8,6 +8,7 @@ | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||
| <result column="c_user_phone" jdbcType="VARCHAR" property="cUserPhone" /> | |||
| <result column="scene" jdbcType="VARCHAR" property="scene"/> | |||
| <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/> | |||
| @@ -87,23 +88,98 @@ | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserFrom" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> | |||
| ,(select nick_name from wx_c_user where id = wcuf.c_user_id ) c_user_nick_name | |||
| ,(select description from wx_user_channel where scene_address = wcuf.scene_address ) scene_address_desc | |||
| ,case when wcuf.from_type = 1 then (select nick_name from wx_c_user where id = wcuf.from_id) | |||
| when wcuf.from_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.from_id) | |||
| when wcuf.from_type = 3 then (select name from wx_merchant_b_user where id = wcuf.from_id) | |||
| when wcuf.from_type = 4 then (select name from mall_user_info where id = wcuf.from_id) | |||
| when wcuf.from_type = 5 then (select name from wx_merchant where id = wcuf.from_id) | |||
| when wcuf.from_type = 6 then (select title from wx_coupon_channel where id = wcuf.from_id) | |||
| when wcuf.from_type = 7 then (select title from wx_activity where id = wcuf.from_id) | |||
| else '' end from_name | |||
| ,case when wcuf.share_user_type = 1 then (select nick_name from wx_c_user where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 3 then (select name from wx_merchant_b_user where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 4 then (select name from mall_user_info where id = wcuf.share_user) | |||
| else '' end share_user_name | |||
| ,wcu.nick_name c_user_nick_name | |||
| ,wcu.phone c_user_phone | |||
| ,wuc.description scene_address_desc | |||
| from wx_c_user_from wcuf | |||
| left join wx_c_user wcu on wcu.id = wcuf.c_user_id | |||
| left join wx_user_channel wuc on wuc.scene_address = wcuf.scene_address | |||
| <include refid="dynamicWhereConditions" /> | |||
| <!-- select <include refid="allColumns" />--> | |||
| <!-- ,(select nick_name from wx_c_user where id = wcuf.c_user_id ) c_user_nick_name--> | |||
| <!-- ,(select description from wx_user_channel where scene_address = wcuf.scene_address ) scene_address_desc--> | |||
| <!-- ,case when wcuf.from_type = 1 then (select nick_name from wx_c_user where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 3 then (select name from wx_merchant_b_user where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 4 then (select name from mall_user_info where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 5 then (select name from wx_merchant where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 6 then (select title from wx_coupon_channel where id = wcuf.from_id)--> | |||
| <!-- when wcuf.from_type = 7 then (select title from wx_activity where id = wcuf.from_id)--> | |||
| <!-- else '' end from_name--> | |||
| <!-- ,case when wcuf.share_user_type = 1 then (select nick_name from wx_c_user where id = wcuf.share_user)--> | |||
| <!-- when wcuf.share_user_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.share_user)--> | |||
| <!-- when wcuf.share_user_type = 3 then (select name from wx_merchant_b_user where id = wcuf.share_user)--> | |||
| <!-- when wcuf.share_user_type = 4 then (select name from mall_user_info where id = wcuf.share_user)--> | |||
| <!-- else '' end share_user_name--> | |||
| <!-- from wx_c_user_from wcuf--> | |||
| <!-- <include refid="dynamicWhereConditions" />--> | |||
| </select> | |||
| <select id="visits" parameterType="com.iformall.domain.po.WxCUserFrom" resultType="com.iformall.domain.po.WxCUserFrom"> | |||
| select a.from_id fromId,a.from_name fromName,a.from_phone fromPhone,a.visits visits,b.reach_user reachUser,c.new_user newUser from ( | |||
| select wcuf.from_id, | |||
| <if test=" fromType == 2 ">wcubi.nick_name from_name,wcubi.phone from_phone,</if> | |||
| <if test=" fromType == 5 ">wm.name from_name,wm.link_phone from_phone,</if> | |||
| count(*) visits | |||
| from wx_c_user_from wcuf | |||
| <if test=" fromType == 2 ">left join wx_c_user_basic_info wcubi on wcuf.from_type = 2 and wcubi.id = wcuf.from_id</if> | |||
| <if test=" fromType == 5 ">left join wx_merchant wm on wcuf.from_type = 5 and wm.id = wcuf.from_id</if> | |||
| where wcuf.from_type = #{fromType} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcuf.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wcuf.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and wcuf.`create_date` >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and wcuf.`create_date` <= #{endTime} | |||
| </if> | |||
| group by wcuf.from_id | |||
| ) a | |||
| left join ( | |||
| select wcuf.from_id, | |||
| count(wcuf.c_user_id) reach_user, | |||
| from wx_c_user_from wcuf | |||
| where wcuf.from_type = #{fromType} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcuf.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wcuf.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and wcuf.`create_date` >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and wcuf.`create_date` <= #{endTime} | |||
| </if> | |||
| group by wcuf.from_id,wcuf.c_user_id | |||
| ) b on b.from_id = a.from_id | |||
| left join ( | |||
| select wcuf.from_id, | |||
| count(wcuf.c_user_id) new_user, | |||
| from wx_c_user_from wcuf | |||
| where wcuf.from_type = #{fromType} | |||
| and wcuf.is_new_user = 1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcuf.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wcuf.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and wcuf.`create_date` >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and wcuf.`create_date` <= #{endTime} | |||
| </if> | |||
| group by wcuf.from_id,wcuf.c_user_id | |||
| ) c on c.from_id = a.from_id | |||
| order by a.visits desc | |||
| </select> | |||
| </mapper> | |||