| @@ -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,7 +31,11 @@ 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; | ||||
| @TableField(exist = false) | |||||
| private Long notMerchantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | ||||
| @@ -47,9 +54,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 +75,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>(); | |||||
| } | |||||
| } | } | ||||
| @@ -156,8 +156,27 @@ public class WxCouponOrderBVo extends WxCouponOrder { | |||||
| @Excel(name = "b端核销手机号", width = 50, orderNum = "5") | @Excel(name = "b端核销手机号", width = 50, orderNum = "5") | ||||
| @io.swagger.annotations.ApiModelProperty(value="b端核销手机号",name="bUserPhone") | @io.swagger.annotations.ApiModelProperty(value="b端核销手机号",name="bUserPhone") | ||||
| private String bUserPhone; | private String bUserPhone; | ||||
| public String getbMerchantName() { | |||||
| return bMerchantName; | |||||
| } | |||||
| public void setbMerchantName(String bMerchantName) { | |||||
| this.bMerchantName = bMerchantName; | |||||
| } | |||||
| public String getbmerchantName() { | |||||
| return bMerchantName; | |||||
| } | |||||
| public void setbmerchantName(String bMerchantName) { | |||||
| this.bMerchantName = bMerchantName; | |||||
| } | |||||
| private String bMerchantName; | |||||
| @Excel(name = "所属商户", width = 50, orderNum = "3") | @Excel(name = "所属商户", width = 50, orderNum = "3") | ||||
| @io.swagger.annotations.ApiModelProperty(value="使用券商户名",name="merchantName") | |||||
| @io.swagger.annotations.ApiModelProperty(value="所属商户",name="merchantName") | |||||
| private String merchantName; | private String merchantName; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> bUserIdList; | private List<Long> bUserIdList; | ||||
| @@ -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); | |||||
| } | } | ||||
| @@ -67,8 +67,9 @@ public interface WxMerchantService { | |||||
| PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize); | PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize); | ||||
| List<WxMerchant> queryIdAndNames(WxMerchant record); | List<WxMerchant> queryIdAndNames(WxMerchant record); | ||||
| Map<Long,String> getIdAndNamesMap(WxMerchant record); | |||||
| PageInfo<WxMerchantVo> listAsPageCVo(WxMerchantDto wxMerchantDto, Integer pageIndex, Integer pageSize,boolean hasShop); | PageInfo<WxMerchantVo> listAsPageCVo(WxMerchantDto wxMerchantDto, Integer pageIndex, Integer pageSize,boolean hasShop); | ||||
| /** | /** | ||||
| * 根据code查询 | * 根据code查询 | ||||
| @@ -493,11 +493,18 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| if (null != b) { | if (null != b) { | ||||
| bvo.setbUserName(b.getName()); | bvo.setbUserName(b.getName()); | ||||
| bvo.setbUserPhone(b.getPhone()); | bvo.setbUserPhone(b.getPhone()); | ||||
| WxMerchant merchant = merchantSimpleMap.get(b.getMerchantId()); | |||||
| if (null != merchant) { | |||||
| bvo.setMerchantName(merchant.getName()); | |||||
| bvo.setMerchantId(merchant.getId()); | |||||
| } | |||||
| // WxMerchant merchant = merchantSimpleMap.get(b.getMerchantId()); | |||||
| // if (null != merchant) { | |||||
| // bvo.setMerchantName(merchant.getName()); | |||||
| // bvo.setMerchantId(merchant.getId()); | |||||
| // } | |||||
| } | |||||
| } | |||||
| if (null != bvo.getBMerchantId()) { | |||||
| WxMerchant merchant = merchantSimpleMap.get(bvo.getBMerchantId()); | |||||
| if (null != merchant) { | |||||
| bvo.setbMerchantName(merchant.getName()); | |||||
| // bvo.setVerifyMerchantName(merchant.getName()); | |||||
| } | } | ||||
| } | } | ||||
| if (null != bvo.getCUserId()) { | if (null != bvo.getCUserId()) { | ||||
| @@ -841,8 +848,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| private List<WxCouponOrderBVo> handleQueryResult(boolean cUserEntry,List<WxCouponOrder> list,TenantEntity tenantEntity) { | private List<WxCouponOrderBVo> handleQueryResult(boolean cUserEntry,List<WxCouponOrder> list,TenantEntity tenantEntity) { | ||||
| if (null != list && list.size() > 0) { | if (null != list && list.size() > 0) { | ||||
| //循环list,获取 cUserId | //循环list,获取 cUserId | ||||
| List<Long> cUserIdList = new ArrayList<Long>(); | List<Long> cUserIdList = new ArrayList<Long>(); | ||||
| List<Long> bUserIdList = new ArrayList<Long>(); | List<Long> bUserIdList = new ArrayList<Long>(); | ||||
| @@ -965,22 +971,22 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| co.setSourceType(coupon.getSourceType()); | co.setSourceType(coupon.getSourceType()); | ||||
| } | } | ||||
| co.setSubsidyNum(co.getSubsidy()); | |||||
| if(co.getBMerchantId() == null){ | |||||
| Long merchanId = merchantProductIdMap.get(co.getCouponId()); | |||||
| if (null != merchanId) { | |||||
| if (merchanId == -999L) { | |||||
| co.setMerchantName("多商户通用"); | |||||
| co.setMerchantId(0L); | |||||
| }else { | |||||
| co.setMerchantName(merchantNameMap.get(merchanId)); | |||||
| co.setMerchantId(merchanId); | |||||
| } | |||||
| co.setSubsidyNum(co.getSubsidy()); | |||||
| Long merchanId = merchantProductIdMap.get(co.getCouponId()); | |||||
| if (null != merchanId) { | |||||
| if (merchanId == -999L) { | |||||
| co.setMerchantName("多商户通用"); | |||||
| co.setMerchantId(0L); | |||||
| }else { | |||||
| co.setMerchantName(merchantNameMap.get(merchanId)); | |||||
| co.setMerchantId(merchanId); | |||||
| } | } | ||||
| }else{ | |||||
| co.setMerchantName(merchantNameMap.get(co.getBMerchantId())); | |||||
| co.setMerchantId(co.getBMerchantId()); | |||||
| } | |||||
| if(co.getBMerchantId() != null){ | |||||
| co.setbMerchantName(merchantNameMap.get(co.getBMerchantId())); | |||||
| co.setVerifyMerchantName(merchantNameMap.get(co.getBMerchantId())); | |||||
| } | } | ||||
| @@ -994,11 +1000,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| co.setUserNickName("保密"); | co.setUserNickName("保密"); | ||||
| } | } | ||||
| } | } | ||||
| Long bMechantId = co.getBMerchantId(); | |||||
| if (null != bMechantId) { | |||||
| co.setVerifyMerchantName(merchantNameMap.get(bMechantId)); | |||||
| } | |||||
| //co.setChannelType();) | //co.setChannelType();) | ||||
| if(null != co.getBUserId()){ | if(null != co.getBUserId()){ | ||||
| WxMerchantBUser buser = buserPhoneMap.get(co.getBUserId()); | WxMerchantBUser buser = buserPhoneMap.get(co.getBUserId()); | ||||
| @@ -7,24 +7,26 @@ 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.List; | |||||
| import java.util.Map; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| /** | /** | ||||
| @@ -37,6 +39,9 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @Autowired | |||||
| WxMerchantMapper wxMerchantMapper; | |||||
| @Autowired | @Autowired | ||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | WxMerchantBUserMapper wxMerchantBUserMapper; | ||||
| @@ -45,7 +50,43 @@ 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()); | |||||
| if(record.getNotMerchantId() != null){ | |||||
| List<Long> notIds = new ArrayList<>(); | |||||
| notIds.add(record.getNotMerchantId()); | |||||
| merchantQ1.setNotInids(notIds); | |||||
| } | |||||
| 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 | ||||
| @@ -161,6 +161,19 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| return wxMerchantMapper.findIdNameList(record); | return wxMerchantMapper.findIdNameList(record); | ||||
| } | } | ||||
| @Override | |||||
| public Map<Long, String> getIdAndNamesMap(WxMerchant record) { | |||||
| Map<Long,String> merchantSimpleMap = new HashMap<Long,String>(); | |||||
| List<WxMerchant> merchantList = wxMerchantMapper.findIdNameList(record); | |||||
| if (null != merchantList && !merchantList.isEmpty()) { | |||||
| for (int k = 0 ; k < merchantList.size() ; k++) { | |||||
| WxMerchant m = merchantList.get(k); | |||||
| merchantSimpleMap.put(m.getId(), m.getName()); | |||||
| } | |||||
| } | |||||
| return merchantSimpleMap; | |||||
| } | |||||
| @Override | @Override | ||||
| public WxMerchantVo getMerchantInfo(HashMap<String, String> params) { | public WxMerchantVo getMerchantInfo(HashMap<String, String> params) { | ||||
| WxMerchant merchant = wxMerchantMapper.getMerchantByCode(params); | WxMerchant merchant = wxMerchantMapper.getMerchantByCode(params); | ||||
| @@ -323,6 +336,24 @@ 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); | |||||
| if(otherUserList != null && !otherUserList.isEmpty()){ | |||||
| List<Long> ids = otherUserList.stream().map(u -> u.getMerchantId()).collect(Collectors.toList()); | |||||
| WxMerchant merchantQ = new WxMerchant(); | |||||
| merchantQ.updateTenantInfo(wxMerchant); | |||||
| merchantQ.setIds(ids); | |||||
| Map<Long, String> idAndNamesMap = getIdAndNamesMap(merchantQ); | |||||
| for (WxMerchantBUser buser: otherUserList) { | |||||
| buser.setMerchantName(idAndNamesMap.get(buser.getMerchantId())); | |||||
| } | |||||
| } | |||||
| 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 +846,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 +873,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()); | ||||
| @@ -852,6 +893,10 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| if (wxMerchant.getId() == null) { | if (wxMerchant.getId() == null) { | ||||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | ||||
| } | } | ||||
| if(EnumYesOrNo.NO.getCode().equals(wxMerchant.getIsAdmin())){ | |||||
| //删除关联的其他门店用户 | |||||
| wxMerchantBUserMapper.deleteOtherMerchant(wxMerchant.getTenantId(),wxMerchant.getId().toString()); | |||||
| } | |||||
| wxMerchantMapper.updateById(wxMerchant); | wxMerchantMapper.updateById(wxMerchant); | ||||
| wxLevelConfigService.batchSaveByMerchantId(wxMerchant, wxMerchant.getId(), wxMerchant.getLevelConfigList()); | wxLevelConfigService.batchSaveByMerchantId(wxMerchant, wxMerchant.getId(), wxMerchant.getLevelConfigList()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -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="addOtherMerchant" 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> | ||||