| @@ -18,6 +18,9 @@ public class WxCreditHistory extends BaseTenantEntity { | |||
| protected Long id; | |||
| @TableField(exist = false) | |||
| private List<Long> userIdList; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="startTime") | |||
| private Date startTime; | |||
| @@ -43,4 +43,8 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon | |||
| List<MerchantCreditRankingVo> merchantCreditRanking(WxCreditHistory record); | |||
| int monthCount(WxCreditHistory record); | |||
| List<WxCreditHistory> findAddList(WxCreditHistory chaddq); | |||
| List<WxCreditHistory> findLesList(WxCreditHistory chlesq); | |||
| } | |||
| @@ -1349,25 +1349,55 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| } | |||
| List<Long> userIds = wxCUserBasicInfoMapper.findVoIdsList1(tenantInfo,basicInfo); | |||
| if (null != userIds && userIds.size() > 0 ) { | |||
| WxCreditHistory chaddq = new WxCreditHistory(); | |||
| chaddq.setUserIdList(userIds); | |||
| chaddq.setTenantId(tenantInfo.getFinalTenantId()); | |||
| chaddq.setStartTime(basicInfo.getCreditStartTime()); | |||
| chaddq.setEndTime(basicInfo.getCreditEndTime()); | |||
| List<WxCreditHistory> chadds = creditHistoryMapper.findAddList(chaddq); | |||
| Map<Long, Integer> chaddMap = new HashMap<>(); | |||
| if(null != chadds){ | |||
| chaddMap = chadds.stream().collect(Collectors.toMap(WxCreditHistory::getCUserId, WxCreditHistory::getCreditNum)); | |||
| } | |||
| WxCreditHistory chlesq = new WxCreditHistory(); | |||
| chlesq.setUserIdList(userIds); | |||
| chlesq.setTenantId(tenantInfo.getFinalTenantId()); | |||
| chlesq.setStartTime(basicInfo.getCreditStartTime()); | |||
| chlesq.setEndTime(basicInfo.getCreditEndTime()); | |||
| List<WxCreditHistory> chless = creditHistoryMapper.findLesList(chlesq); | |||
| Map<Long, Integer> chlesMap = new HashMap<>(); | |||
| if(null != chless){ | |||
| chlesMap = chless.stream().collect(Collectors.toMap(WxCreditHistory::getCUserId, WxCreditHistory::getCreditNum)); | |||
| } | |||
| WxCUserTags tq = new WxCUserTags(); | |||
| tq.setUserIdList(userIds); | |||
| tq.setTenantId(tenantInfo.getFinalTenantId()); | |||
| List<WxCUserTags> userTagList = wxCUserTagsMapper.findList(tq); | |||
| Map<Long, String> tagMap = new HashMap<>(); | |||
| Map<Long, String> userTagsMap = new HashMap<>(); | |||
| if (null != userTagList) { | |||
| List<WxTags> tagList = wxTagsMapper.findListAll(); | |||
| Map<Long, String> tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| Map<Long,String> userTagsMap = userTagList.stream().collect(Collectors.toMap(WxCUserTags::getUserId, WxCUserTags::getTags)); | |||
| list.stream().forEach(u->{ | |||
| List<Long> ids = JSONObject.parseArray(userTagsMap.get(u.getId()), Long.class); | |||
| if (null != ids) { | |||
| String tagNames = StringUtils.join(ids.stream().map(id->tagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| u.setTagNames(tagNames); | |||
| } | |||
| }); | |||
| tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| userTagsMap = userTagList.stream().collect(Collectors.toMap(WxCUserTags::getUserId, WxCUserTags::getTags)); | |||
| } | |||
| Map<Long, Integer> finalChaddMap = chaddMap; | |||
| Map<Long, Integer> finalChlesMap = chlesMap; | |||
| Map<Long, String> finalUserTagsMap = userTagsMap; | |||
| Map<Long, String> finalTagMap = tagMap; | |||
| list.stream().forEach(u->{ | |||
| u.setAddCredit(finalChaddMap.get(u.getId())); | |||
| u.setLesCredit(finalChlesMap.get(u.getId())); | |||
| List<Long> ids = JSONObject.parseArray(finalUserTagsMap.get(u.getId()), Long.class); | |||
| if (null != ids) { | |||
| String tagNames = StringUtils.join(ids.stream().map(id-> finalTagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| u.setTagNames(tagNames); | |||
| } | |||
| }); | |||
| } | |||
| if (null != list && list.size() > 0 ) { | |||
| List<Object> retList = new ArrayList<Object>(); | |||
| @@ -650,7 +650,8 @@ | |||
| <sql id="allVoColumns"> | |||
| distinct cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`, | |||
| cu.`create_date`,cu.`update_date`,cu.`name`,cu.`level`,cu.`nick_name`, | |||
| cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`final_tenant_id` | |||
| <!-- cut.`tags`,--> | |||
| cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`final_tenant_id` | |||
| </sql> | |||
| <sql id="dynamicVoWhereConditions"> | |||
| @@ -714,11 +715,11 @@ | |||
| <if test=" null != startTime and null!=endTime"> | |||
| and cu.`create_date` between #{startTime} and #{endTime} | |||
| </if> | |||
| <if test=" null != activeStartTime and null!=activeEndTime"> | |||
| and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} | |||
| </if> | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and cu.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -829,26 +830,26 @@ | |||
| <select id="findVoList1" resultMap="VoBaseResultMap"> | |||
| select | |||
| <include refid="allVoColumns"/> | |||
| ,(select ifnull(sum(credit.credit_num),0) amount from wx_credit_history${basicInfo.shardFinalTableSuffix} credit | |||
| where credit.`tenant_id` = #{basicInfo.finalTenantId} | |||
| and credit.credit_num > 0 and credit.c_user_id = cu.id | |||
| <if test=" null != basicInfo.creditStartTime "> | |||
| and credit.create_date >= #{basicInfo.creditStartTime} | |||
| </if> | |||
| <if test=" null != basicInfo.creditEndTime"> | |||
| and credit.create_date < #{basicInfo.creditEndTime} | |||
| </if>) as addCredit, | |||
| (select ifnull(sum(credit.credit_num),0) amount from wx_credit_history${basicInfo.shardFinalTableSuffix} credit | |||
| where credit.`tenant_id` = #{basicInfo.finalTenantId} | |||
| and credit.credit_num < 0 and credit.c_user_id = cu.id | |||
| <if test=" null != basicInfo.creditStartTime "> | |||
| and credit.create_date >= #{basicInfo.creditStartTime} | |||
| </if> | |||
| <if test=" null != basicInfo.creditEndTime"> | |||
| and credit.create_date < #{basicInfo.creditEndTime} | |||
| </if>) as lesCredit | |||
| <!-- ,(select ifnull(sum(credit.credit_num),0) amount from wx_credit_history${basicInfo.shardFinalTableSuffix} credit--> | |||
| <!-- where credit.`tenant_id` = #{basicInfo.finalTenantId}--> | |||
| <!-- and credit.credit_num > 0 and credit.c_user_id = cu.id--> | |||
| <!-- <if test=" null != basicInfo.creditStartTime ">--> | |||
| <!-- and credit.create_date >= #{basicInfo.creditStartTime}--> | |||
| <!-- </if>--> | |||
| <!-- <if test=" null != basicInfo.creditEndTime">--> | |||
| <!-- and credit.create_date < #{basicInfo.creditEndTime}--> | |||
| <!-- </if>) as addCredit,--> | |||
| <!-- (select ifnull(sum(credit.credit_num),0) amount from wx_credit_history${basicInfo.shardFinalTableSuffix} credit--> | |||
| <!-- where credit.`tenant_id` = #{basicInfo.finalTenantId}--> | |||
| <!-- and credit.credit_num < 0 and credit.c_user_id = cu.id--> | |||
| <!-- <if test=" null != basicInfo.creditStartTime ">--> | |||
| <!-- and credit.create_date >= #{basicInfo.creditStartTime}--> | |||
| <!-- </if>--> | |||
| <!-- <if test=" null != basicInfo.creditEndTime">--> | |||
| <!-- and credit.create_date < #{basicInfo.creditEndTime}--> | |||
| <!-- </if>) as lesCredit--> | |||
| from wx_c_user_basic_info cu | |||
| left join wx_c_user_tags${basicInfo.shardFinalTableSuffix} cut on cut.`id` = cu.`tag_id` | |||
| <!-- left join wx_c_user_tags${basicInfo.shardFinalTableSuffix} cut on cut.`id` = cu.`tag_id`--> | |||
| <include refid="dynamicVoWhereConditions1"/> | |||
| <if test=" null != basicInfo.begin "> | |||
| limit #{basicInfo.begin}, #{basicInfo.limit} | |||
| @@ -378,4 +378,51 @@ | |||
| </select> | |||
| </mapper> | |||
| <select id="findAddList" parameterType="com.iformall.domain.po.WxCreditHistory" | |||
| resultType="com.iformall.domain.po.WxCreditHistory"> | |||
| select credit.c_user_id cUserId,ifnull(sum(credit.credit_num),0) creditNum | |||
| from wx_credit_history credit | |||
| where credit.`tenant_id` = #{tenantId} | |||
| and credit.credit_num > 0 | |||
| <if test=" null != userIdList "> | |||
| and credit.`c_user_id` in | |||
| <foreach collection="userIdList" index="index" item="uItem" open="(" separator="," close=")"> | |||
| #{uItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and credit.create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and credit.create_date < #{endTime} | |||
| </if> | |||
| GROUP BY credit.`c_user_id` | |||
| </select> | |||
| <select id="findLesList" parameterType="com.iformall.domain.po.WxCreditHistory" | |||
| resultType="com.iformall.domain.po.WxCreditHistory"> | |||
| select credit.c_user_id cUserId,ifnull(sum(credit.credit_num),0) creditNum | |||
| from wx_credit_history credit | |||
| where credit.`tenant_id` = #{tenantId} | |||
| and credit.credit_num < 0 | |||
| <if test=" null != userIdList "> | |||
| and `user_id` in | |||
| <foreach collection="userIdList" index="index" item="uItem" open="(" separator="," close=")"> | |||
| #{uItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and credit.create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and credit.create_date < #{endTime} | |||
| </if> | |||
| GROUP BY credit.`c_user_id` | |||
| </select> | |||
| </mapper> | |||