feat:平台账号

This commit is contained in:
苏竹红
2025-04-08 15:22:47 +08:00
parent c431754f28
commit c08905399c
29 changed files with 1294 additions and 19 deletions

View File

@@ -0,0 +1,120 @@
package com.cool.store.dao;
import com.cool.store.constants.CommonConstants;
import com.cool.store.entity.HyPartnerUserInfoDO;
import com.cool.store.entity.ShopAccountDO;
import com.cool.store.enums.OpenStatusEnum;
import com.cool.store.enums.PlatformBuildEnum;
import com.cool.store.enums.ShopAccountEnum;
import com.cool.store.mapper.ShopAccountMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @Author suzhuhong
* @Date 2025/4/7 14:26
* @Version 1.0
*/
@Component
public class ShopAccountDAO {
@Resource
ShopAccountMapper shopAccountMapper;
public Integer initShopAccount(HyPartnerUserInfoDO partnerUserInfoDO, List<Long> shopIds){
List<ShopAccountDO> shopAccountDOS = new ArrayList<>();
for (Long shopId : shopIds) {
for (ShopAccountEnum shopAccountEnum: ShopAccountEnum.values()) {
ShopAccountDO shopAccountDO = new ShopAccountDO();
shopAccountDO.setShopId(shopId);
shopAccountDO.setSystemName(shopAccountEnum.getSystemName());
shopAccountDO.setBoundPhone(partnerUserInfoDO.getMobile());
shopAccountDO.setPasswordSalt(partnerUserInfoDO.getDownstreamSystemSalting());
shopAccountDO.setPassword(partnerUserInfoDO.getDownstreamSystemPassword());
shopAccountDO.setStatus(shopAccountEnum.getInitStatus().getCode());
if (ShopAccountEnum.HuoMa.equals(shopAccountEnum)){
shopAccountDO.setEntryStatus(CommonConstants.ONE);
}
shopAccountDOS.add(shopAccountDO);
}
}
return shopAccountMapper.batchInsert(shopAccountDOS);
}
int batchInsert(List<ShopAccountDO> list){
if (CollectionUtils.isEmpty(list)){
return CommonConstants.ZERO;
}
return shopAccountMapper.batchInsert(list);
}
/**
* 根据shopId查询多条数据
* @param shopId 店铺ID
* @return 店铺账号列表
*/
public List<ShopAccountDO> selectByShopId(Long shopId){
return shopAccountMapper.selectByShopId(shopId);
}
/**
* 根据shopId与system_name修改status
* @param shopId 店铺ID
* @param systemName 系统名称
* @param status 状态
* @return 影响的行数
*/
public int updateStatusByShopIdAndSystemName(Long shopId, List<String> systemNameList, Integer status){
return shopAccountMapper.updateStatusByShopIdAndSystemName(shopId,systemNameList,status);
}
public int updateEntryStatusByShopIdAndSystemName(Long shopId, List<String> systemNameList, Integer status){
return shopAccountMapper.updateEntryStatusByShopIdAndSystemName(shopId,systemNameList,status);
}
/**
* changeStatus
* @param shopId
* @param type
* @param account
* @param password
* @param resultType
* @return
*/
public Boolean changeStatus(Long shopId,Integer type,String account ,String password,Integer resultType){
if (Objects.isNull(shopId)||Objects.isNull(resultType)){
return Boolean.FALSE;
}
Integer openStatus = resultType == 1 ? OpenStatusEnum.OPENSTATUSENUM_6.getCode() : OpenStatusEnum.OPENSTATUSENUM_5.getCode();
String systemName = PlatformBuildEnum.getMessageByCode(type);
shopAccountMapper.updateAccountByShopIdAndSystemName(shopId,systemName,account,password,openStatus);
return Boolean.TRUE;
}
/**
* 只修改 POS 云流水 新掌柜
* @param shopIds
* @param password
* @param passwordSalt
* @param lastSyncTime
* @return
*/
public int batchUpdatePasswordByShopIds( List<Long> shopIds, String password, String passwordSalt, Date lastSyncTime){
return shopAccountMapper.batchUpdatePasswordByShopIds(
shopIds, password, passwordSalt, lastSyncTime
);
}
}

View File

@@ -186,6 +186,13 @@ public class ShopInfoDAO {
return shopInfoMapper.selectByStoreNum(storeNum);
}
public ShopInfoDO selectByStoreCode(String storeCode){
if (StringUtils.isBlank(storeCode)) {
return null;
}
return shopInfoMapper.selectByStoreCode(storeCode);
}
public List<ShopInfoDO> selectByIdOrSelectAll(Long shopId){
return shopInfoMapper.selectByIdOrSelectAll(shopId);

View File

@@ -0,0 +1,74 @@
package com.cool.store.mapper;
import com.cool.store.entity.ShopAccountDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface ShopAccountMapper extends Mapper<ShopAccountDO> {
/**
* 批量新增店铺账号
* @param list 店铺账号列表
* @return 影响的行数
*/
int batchInsert(List<ShopAccountDO> list);
/**
* 根据shopId查询多条数据
* @param shopId 店铺ID
* @return 店铺账号列表
*/
List<ShopAccountDO> selectByShopId(Long shopId);
/**
* 根据shopId与system_name修改status
* @param shopId 店铺ID
* @param systemName 系统名称
* @param status 状态
* @param lastSyncTime 最后同步时间
* @return 影响的行数
*/
int updateStatusByShopIdAndSystemName(
@Param("shopId") Long shopId,
@Param("systemNameList") List<String> systemNameList,
@Param("status") Integer status
);
int updateEntryStatusByShopIdAndSystemName(
@Param("shopId") Long shopId,
@Param("systemNameList") List<String> systemNameList,
@Param("entryStatus") Integer entryStatus
);
int updateAccountByShopIdAndSystemName(
@Param("shopId") Long shopId,
@Param("systemName") String systemName,
@Param("account") String account,
@Param("password") String password,
@Param("status") Integer status
);
/**
* 批量修改密码和密码盐
* @param shopIds 店铺ID列表
* @param password 新密码
* @param passwordSalt 新密码盐
* @param lastSyncTime 最后同步时间
* @return 影响的行数
*/
int batchUpdatePasswordByShopIds(
@Param("shopIds") List<Long> shopIds,
@Param("password") String password,
@Param("passwordSalt") String passwordSalt,
@Param("lastSyncTime") Date lastSyncTime
);
}

View File

@@ -0,0 +1,7 @@
package com.cool.store.mapper;
import com.cool.store.entity.ShopAccountDO;
import tk.mybatis.mapper.common.Mapper;
public interface ShopAccountMapper extends Mapper<ShopAccountDO> {
}

View File

@@ -92,6 +92,8 @@ public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
Long getRegionIdByid(@Param("shopId") Long shopId);
ShopInfoDO selectByStoreNum(@Param("storeNum") String storeNum);
ShopInfoDO selectByStoreCode(@Param("storeNum") String storeCode);
/**
* @Auther: wangshuo
* @Date: 2024/5/3

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.ShopAccountMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.ShopAccountDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
<result column="system_name" jdbcType="VARCHAR" property="systemName" />
<result column="account" jdbcType="VARCHAR" property="account" />
<result column="bound_phone" jdbcType="VARCHAR" property="boundPhone" />
<result column="password_salt" jdbcType="VARCHAR" property="passwordSalt" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="status" jdbcType="BIT" property="status" />
<result column="entry_status" jdbcType="TINYINT" property="entryStatus" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="last_sync_time" jdbcType="TIMESTAMP" property="lastSyncTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<!-- 批量新增 -->
<insert id="batchInsert">
INSERT INTO xfsg_shop_account (
shop_id,
system_name,
account,
bound_phone,
password_salt,
password,
status,
entry_status,
last_sync_time,
remark
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.shopId},
#{item.systemName},
#{item.account},
#{item.boundPhone},
#{item.passwordSalt},
#{item.password},
#{item.status},
#{item.entryStatus},
#{item.lastSyncTime},
#{item.remark}
)
</foreach>
</insert>
<!-- 根据shopId查询多条数据 -->
<select id="selectByShopId" resultMap="BaseResultMap">
SELECT
id,
shop_id,
system_name,
account,
bound_phone,
password_salt,
password,
status,
entry_status,
create_time,
last_sync_time,
remark
FROM
xfsg_shop_account
WHERE
shop_id = #{shopId}
</select>
<!-- 根据shopId与system_name修改status -->
<update id="updateStatusByShopIdAndSystemName">
UPDATE
xfsg_shop_account
SET
status = #{status,jdbcType=BIT}
WHERE
shop_id = #{shopId}
and system_name in
<foreach close=")" collection="systemNameList" item="systemName" open="(" separator=",">
#{systemName}
</foreach>
</update>
<update id="updateEntryStatusByShopIdAndSystemName">
UPDATE
xfsg_shop_account
SET
entry_status = #{entryStatus,jdbcType=BIT}
WHERE
shop_id = #{shopId}
and system_name in
<foreach close=")" collection="systemNameList" item="systemName" open="(" separator=",">
#{systemName}
</foreach>
</update>
<update id="updateAccountByShopIdAndSystemName">
UPDATE
xfsg_shop_account
SET
account = #{account},
password = #{password},
status = #{status},
WHERE
shop_id = #{shopId}
AND system_name = #{systemName}
</update>
<!-- 批量修改密码和密码盐 -->
<update id="batchUpdatePasswordByShopIds">
UPDATE
xfsg_shop_account
SET
password = #{password},
password_salt = #{passwordSalt},
last_sync_time = #{lastSyncTime,jdbcType=TIMESTAMP}
WHERE
system_name in ('火码POS','云流水','新掌柜')
and shop_id IN
<foreach close=")" collection="shopIds" item="shopId" open="(" separator=",">
#{shopId}
</foreach>
</update>
</mapper>

View File

@@ -173,6 +173,12 @@
from xfsg_shop_info
where store_num = #{storeNum}
</select>
<select id="selectByStoreCode" resultType="com.cool.store.entity.ShopInfoDO">
select
<include refid="allColumn"/>
from xfsg_shop_info
where store_code = #{storeCode}
</select>
<select id="selectShopListByRegionId" resultType="com.cool.store.entity.ShopInfoDO">
select
xsi.id,xsi.line_id as lineId,xsi.region_id as regionId,xsi.shop_name as shopName,xsi.store_num as