| @@ -1,10 +1,16 @@ | |||||
| package com.iformall.controller.basic; | package com.iformall.controller.basic; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.service.WxMerchantBUserService; | import com.iformall.service.WxMerchantBUserService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -19,6 +25,21 @@ public class WxMerchantBUserController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxMerchantBUserService wxMerchantBUserService; | private WxMerchantBUserService wxMerchantBUserService; | ||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("listVo") | |||||
| @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 listVo(@ModelAttribute WxMerchantBUser wxMerchantBUser, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::list"); | |||||
| if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.updateTenantInfo(getTenantInfo()); | |||||
| wxMerchantBUser.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("手机号是否存在") | @ApiOperation("手机号是否存在") | ||||
| @GetMapping("/hasphone") | @GetMapping("/hasphone") | ||||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | ||||
| @@ -47,6 +47,9 @@ public class WxMerchant extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<WxMerchantBUser> users; | private List<WxMerchantBUser> users; | ||||
| @TableField(exist = false) | |||||
| private List<WxMerchantBUser> otherMerchantUsers; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Long rentContractId; | private Long rentContractId; | ||||
| @@ -1,13 +1,16 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.UUID; | import java.util.UUID; | ||||
| @@ -28,6 +31,8 @@ public class WxMerchantBUser extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | ||||
| private Long merchantId; | private Long merchantId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String merchantName; | |||||
| @TableField(exist = false) | |||||
| private List<Long> merchantIds; | private List<Long> merchantIds; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @@ -47,9 +52,12 @@ public class WxMerchantBUser extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "是否是管理员", name = "isAdmin") | @io.swagger.annotations.ApiModelProperty(value = "是否是管理员", name = "isAdmin") | ||||
| private Integer isAdmin; | private Integer isAdmin; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "可核销其他商户", name = "otherMerchant") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "json 可核销其他商户", name = "otherMerchant") | |||||
| private String otherMerchant; | private String otherMerchant; | ||||
| @TableField(exist = false) | |||||
| private String otherMerchantId; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @io.swagger.annotations.ApiModelProperty(value = "b用户ID", name = "buserId") | @io.swagger.annotations.ApiModelProperty(value = "b用户ID", name = "buserId") | ||||
| private transient Long buserId; | private transient Long buserId; | ||||
| @@ -65,4 +73,13 @@ public class WxMerchantBUser extends TenantEntity { | |||||
| } | } | ||||
| return this.token; | return this.token; | ||||
| } | } | ||||
| public List<String> getOtherMerchantIds(){ | |||||
| if(StringUtils.isNotBlank(otherMerchant)){ | |||||
| try{ | |||||
| return JSONObject.parseArray(otherMerchant, String.class); | |||||
| }catch(Exception e){} | |||||
| } | |||||
| return new ArrayList<String>(); | |||||
| } | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.vo.WxMerchantBuInfoVo; | import com.iformall.domain.vo.WxMerchantBuInfoVo; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxMerchantBUserMapper extends CommonMapper<WxMerchantBUser, Long> { | public interface WxMerchantBUserMapper extends CommonMapper<WxMerchantBUser, Long> { | ||||
| @@ -18,7 +19,8 @@ public interface WxMerchantBUserMapper extends CommonMapper<WxMerchantBUser, Lon | |||||
| List<WxMerchantBuInfoVo> findSelMerchantList(WxMerchantBUser wxMerchantBUser); | List<WxMerchantBuInfoVo> findSelMerchantList(WxMerchantBUser wxMerchantBUser); | ||||
| WxMerchantBUser findByToken(String token); | WxMerchantBUser findByToken(String token); | ||||
| int deleteOtherMerchant(@Param("tenantId")String tenantId, @Param("otherId")String otherId); | |||||
| int addOtherMerchant(@Param("tenantId")String tenantId, @Param("ids")List<Long> ids, @Param("otherId")String otherId); | |||||
| } | } | ||||
| @@ -7,22 +7,27 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.po.WxMsgValidationcode; | import com.iformall.domain.po.WxMsgValidationcode; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxMerchantBuInfoVo; | import com.iformall.domain.vo.WxMerchantBuInfoVo; | ||||
| import com.iformall.enums.EnumMerchantBUserStatus; | import com.iformall.enums.EnumMerchantBUserStatus; | ||||
| import com.iformall.enums.EnumMerchantStatus; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxAppinfoMapper; | import com.iformall.mapper.WxAppinfoMapper; | ||||
| import com.iformall.mapper.WxMerchantBUserMapper; | import com.iformall.mapper.WxMerchantBUserMapper; | ||||
| import com.iformall.mapper.WxMerchantMapper; | |||||
| import com.iformall.mapper.WxMsgValidationcodeMapper; | import com.iformall.mapper.WxMsgValidationcodeMapper; | ||||
| import com.iformall.service.WxMerchantBUserService; | import com.iformall.service.WxMerchantBUserService; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -37,6 +42,9 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @Autowired | |||||
| WxMerchantMapper wxMerchantMapper; | |||||
| @Autowired | @Autowired | ||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | WxMerchantBUserMapper wxMerchantBUserMapper; | ||||
| @@ -45,7 +53,38 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchantBUser> listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchantBUser> listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantBUserMapper.findList(record)); | |||||
| //查询有效门店的员工 | |||||
| WxMerchant merchantQ1 = new WxMerchant(); | |||||
| merchantQ1.updateTenantInfo(record); | |||||
| merchantQ1.setName(record.getMerchantName()); | |||||
| merchantQ1.setStatus(EnumMerchantStatus.VALID.getCode()); | |||||
| List<Long> merchantIdList = wxMerchantMapper.findIdList(merchantQ1); | |||||
| if(merchantIdList == null || merchantIdList.isEmpty()){ | |||||
| return new PageInfo<WxMerchantBUser>(); | |||||
| } | |||||
| record.setMerchantIds(merchantIdList); | |||||
| PageInfo<WxMerchantBUser> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantBUserMapper.findList(record)); | |||||
| List<WxMerchantBUser> list = pageInfo.getList(); | |||||
| if(list != null && !list.isEmpty()){ | |||||
| Map<Long,String> merchantSimpleMap = new HashMap<Long,String>(); | |||||
| if (null != merchantIdList && merchantIdList.size() > 0) { | |||||
| WxMerchant merchantQ = new WxMerchant(); | |||||
| merchantQ.updateTenantInfo(record); | |||||
| merchantQ.setIds(merchantIdList); | |||||
| List<WxMerchant> merchantList = wxMerchantMapper.findIdNameList(merchantQ); | |||||
| if (null != merchantList) { | |||||
| for (int k = 0 ; k < merchantList.size() ; k++) { | |||||
| WxMerchant m = merchantList.get(k); | |||||
| merchantSimpleMap.put(m.getId(), m.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| for (WxMerchantBUser bUser:list) { | |||||
| bUser.setMerchantName(merchantSimpleMap.get(bUser.getMerchantId())); | |||||
| } | |||||
| } | |||||
| return pageInfo; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -323,6 +323,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| List<WxMerchantBUser> userList = wxMerchantBUserMapper.findList(wxMerchantBUser); | List<WxMerchantBUser> userList = wxMerchantBUserMapper.findList(wxMerchantBUser); | ||||
| wxMerchant.setUsers(userList); | wxMerchant.setUsers(userList); | ||||
| if(EnumYesOrNo.YES.getCode().equals(wxMerchant.getIsAdmin())){ | |||||
| WxMerchantBUser otherQ = new WxMerchantBUser(); | |||||
| otherQ.setOtherMerchantId(wxMerchant.getId().toString()); | |||||
| otherQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | |||||
| List<WxMerchantBUser> otherUserList = wxMerchantBUserMapper.findList(otherQ); | |||||
| wxMerchant.setOtherMerchantUsers(otherUserList); | |||||
| } | |||||
| //分账信息 | //分账信息 | ||||
| WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(wxMerchant,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT); | WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(wxMerchant,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT); | ||||
| if (receiver != null) { | if (receiver != null) { | ||||
| @@ -815,6 +823,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantBUser.setStatus(EnumMerchantBUserStatus.INVALID.getCode()); | wxMerchantBUser.setStatus(EnumMerchantBUserStatus.INVALID.getCode()); | ||||
| wxMerchantBUserMapper.updateById(wxMerchantBUser); | wxMerchantBUserMapper.updateById(wxMerchantBUser); | ||||
| } | } | ||||
| //删除关联的其他门店用户 | |||||
| wxMerchantBUserMapper.deleteOtherMerchant(wxMerchant.getTenantId(),wxMerchant.getId().toString()); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| //保存商户关联用户 | //保存商户关联用户 | ||||
| for (WxMerchantBUser user : users) { | for (WxMerchantBUser user : users) { | ||||
| @@ -839,6 +850,13 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantBUserMapper.updateById(user); | wxMerchantBUserMapper.updateById(user); | ||||
| } | } | ||||
| } | } | ||||
| if(EnumYesOrNo.YES.getCode().equals(wxMerchant.getIsAdmin())){ | |||||
| List<WxMerchantBUser> otherMerchantUsers = wxMerchant.getOtherMerchantUsers(); | |||||
| if(otherMerchantUsers != null && !otherMerchantUsers.isEmpty()){ | |||||
| List<Long> ids = otherMerchantUsers.stream().map(u -> u.getId()).collect(Collectors.toList()); | |||||
| wxMerchantBUserMapper.addOtherMerchant(wxMerchant.getTenantId(),ids,wxMerchant.getId().toString()); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "账号操作成功"); | return new ResultData(Result.SUCCESS, "账号操作成功"); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("db failed: 账号操作失败, e:" + e.getMessage()); | logger.error("db failed: 账号操作失败, e:" + e.getMessage()); | ||||
| @@ -83,6 +83,9 @@ | |||||
| <if test=" null != isAdmin "> | <if test=" null != isAdmin "> | ||||
| and `is_admin` = #{isAdmin} | and `is_admin` = #{isAdmin} | ||||
| </if> | </if> | ||||
| <if test=" null != otherMerchantId and '' != otherMerchantId"> | |||||
| and json_search(other_merchant, 'one', #{otherMerchantId}) IS NOT NULL; | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -171,5 +174,20 @@ | |||||
| where `token` = #{token} | where `token` = #{token} | ||||
| </select> | </select> | ||||
| <update id="deleteOtherMerchant" parameterType="hashmap"> | |||||
| update wx_merchant_b_user set other_merchant = JSON_REMOVE(other_merchant, replace(json_search(other_merchant, 'one', #{otherId}), '"', '')) | |||||
| where `tenant_id` = #{tenantId} | |||||
| and json_search(other_merchant, 'one', #{otherId}) IS NOT NULL; | |||||
| </update> | |||||
| <update id="deleteOtherMerchant" parameterType="hashmap"> | |||||
| update wx_merchant_b_user set other_merchant = json_array_append(coalesce(other_merchant,'[]'), '$', #{otherId}) | |||||
| where `tenant_id` = #{tenantId} | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| and json_search(other_merchant, 'one', #{otherId}) IS NULL; | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||