后台部分修改

This commit is contained in:
Jerry Yan 2024-12-05 14:33:27 +08:00
parent 569c038072
commit bf73241bf4
11 changed files with 179 additions and 5 deletions

View File

@ -0,0 +1,15 @@
package com.ycwl.basic.mapper.pc;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ScenicAccountMapper {
ScenicAccountEntity getByAccount(String account);
int add(ScenicAccountEntity scenicAccount);
ScenicAccountEntity getSuperAccountOfScenic(Long scenicId);
int update(ScenicAccountEntity scenicAccount);
int deleteById(Long id);
int updateStatus(Long id);
int deleteByScenicId(Long scenicId);
}

View File

@ -20,6 +20,7 @@ public class BrokerEntity {
* 推客名称
*/
private String name;
private String phone;
/**
* 专属优惠码新建时生成
*/
@ -30,4 +31,8 @@ public class BrokerEntity {
private Integer status;
private Date createAt;
private Date updateAt;
private Integer brokerOrderCount;
private Integer brokerOrderAmount;
private Date firstBrokerDate;
private Date lastBrokerDate;
}

View File

@ -18,6 +18,8 @@ public class BrokerReqQuery extends BaseQueryParameterReq {
private Long id;
@ApiModelProperty("推客名称")
private String name;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("专属优惠码")
private String promoCode;
@ApiModelProperty("状态0禁用1启用")

View File

@ -0,0 +1,19 @@
package com.ycwl.basic.model.pc.scenic.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("scenic_account")
public class ScenicAccountEntity {
private Long id;
private Long scenicId;
private Integer isSuper;
private String name;
private String account;
private String password;
private Date createTime;
private Date updateTime;
}

View File

@ -22,6 +22,11 @@ public class ScenicAddOrUpdateReq {
*/
@ApiModelProperty("景区名称")
private String name;
/**
* 景区电话
*/
@ApiModelProperty("联系电话")
private String phone;
/**
* 景区介绍
*/
@ -75,4 +80,9 @@ public class ScenicAddOrUpdateReq {
private ScenicConfigEntity scenicConfig;
@ApiModelProperty("景区源素材价格,元")
private BigDecimal price;
@ApiModelProperty("账号")
private String account;
@ApiModelProperty("密码")
private String password;
}

View File

@ -23,6 +23,16 @@ public class ScenicRespVO {
*/
@ApiModelProperty("景区名称")
private String name;
/**
* 账号
*/
@ApiModelProperty("账号")
private String account;
/**
* 联系电话
*/
@ApiModelProperty("联系电话")
private String phone;
/**
* 景区介绍
*/

View File

@ -8,6 +8,7 @@ import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import com.ycwl.basic.service.pc.RenderWorkerService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -44,6 +45,10 @@ public class RenderWorkerServiceImpl implements RenderWorkerService {
@Override
public ApiResponse<Integer> add(RenderWorkerEntity renderWorker) {
renderWorker.setId(SnowFlakeUtil.getLongId());
if (StringUtils.isEmpty(renderWorker.getAccessKey())) {
renderWorker.setAccessKey(SnowFlakeUtil.getId());
}
renderWorker.setStatus(0);
int add = renderWorkerMapper.add(renderWorker);
if (add == 0) {
return ApiResponse.fail("渲染机添加失败");

View File

@ -2,7 +2,9 @@ package com.ycwl.basic.service.impl.pc;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.pc.ScenicAccountMapper;
import com.ycwl.basic.mapper.pc.ScenicMapper;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicAddOrUpdateReq;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
@ -10,6 +12,7 @@ import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.service.pc.ScenicService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -24,6 +27,8 @@ import java.util.List;
public class ScenicServiceImpl implements ScenicService {
@Autowired
private ScenicMapper scenicMapper;
@Autowired
private ScenicAccountMapper scenicAccountMapper;
@Override
public ApiResponse<PageInfo<ScenicRespVO>> pageQuery(ScenicReqQuery scenicReqQuery) {
@ -46,9 +51,21 @@ public class ScenicServiceImpl implements ScenicService {
@Override
@Transactional(rollbackFor = Exception.class)
public ApiResponse<Boolean> add(ScenicAddOrUpdateReq scenicAddReq) {
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
if (scenicAccount != null) {
return ApiResponse.fail("账号已存在");
}
Long scenicId = SnowFlakeUtil.getLongId();
scenicAddReq.setId(scenicId);
int add = scenicMapper.add(scenicAddReq);
ScenicAccountEntity account = new ScenicAccountEntity();
account.setId(SnowFlakeUtil.getLongId());
account.setScenicId(scenicId);
account.setName(scenicAddReq.getName() + "管理员");
account.setAccount(scenicAddReq.getAccount());
account.setPassword(scenicAddReq.getPassword());
account.setIsSuper(1);
scenicAccountMapper.add(account);
if (add > 0) {
return ApiResponse.success(true);
}else {
@ -62,6 +79,7 @@ public class ScenicServiceImpl implements ScenicService {
int i = scenicMapper.deleteById(id);
if (i > 0) {
scenicMapper.deleteConfigByscenicId(id);
scenicAccountMapper.deleteByScenicId(id);
return ApiResponse.success(true);
}else {
return ApiResponse.fail("景区删除失败");
@ -70,6 +88,29 @@ public class ScenicServiceImpl implements ScenicService {
@Override
public ApiResponse<Boolean> update(ScenicAddOrUpdateReq scenicUpdateReq) {
if (StringUtils.isNotBlank(scenicUpdateReq.getAccount()) && StringUtils.isNotBlank(scenicUpdateReq.getPassword())) {
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicUpdateReq.getAccount());
if (scenicAccount != null) {
if (!scenicAccount.getScenicId().equals(scenicUpdateReq.getId())) {
return ApiResponse.fail("账号已存在");
}
}
ScenicAccountEntity account = scenicAccountMapper.getSuperAccountOfScenic(scenicUpdateReq.getId());
if (account != null) {
account.setAccount(scenicUpdateReq.getAccount());
account.setPassword(scenicUpdateReq.getPassword());
scenicAccountMapper.update(account);
} else {
account = new ScenicAccountEntity();
account.setId(SnowFlakeUtil.getLongId());
account.setScenicId(scenicUpdateReq.getId());
account.setName(scenicUpdateReq.getName() + "管理员");
account.setAccount(scenicUpdateReq.getAccount());
account.setPassword(scenicUpdateReq.getPassword());
account.setIsSuper(1);
scenicAccountMapper.add(account);
}
}
int i = scenicMapper.update(scenicUpdateReq);
if (i > 0) {
return ApiResponse.success(true);

View File

@ -23,12 +23,20 @@
delete from broker where id = #{id}
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.broker.entity.BrokerEntity">
select id, `name`, promo_code, status, create_at, update_at
select id, `name`, phone, promo_code, status,
(select count(1) from `order` where broker_id = broker.id) as broker_order_count,
(select sum(pay_price) from `order` where broker_id = broker.id) as broker_order_amount,
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at desc limit 1) as last_broker_date,
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at asc limit 1) as first_broker_date,
create_at, update_at
from broker
<where>
<if test="name!= null and name!= ''">
and `name` like concat('%', #{name}, '%')
</if>
<if test="phone!= null and phone!= ''">
and `phone` like concat('%', #{phone}, '%')
</if>
<if test="promoCode!= null and promoCode!= ''">
and promo_code like concat('%', #{promoCode}, '%')
</if>

View File

@ -0,0 +1,52 @@
<?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.ycwl.basic.mapper.pc.ScenicAccountMapper">
<insert id="add">
insert into scenic_account(id, scenic_id, is_super, name, account, password, create_time, update_time)
values (#{id}, #{scenicId}, #{isSuper}, #{name}, #{account}, #{password}, now(), now())
</insert>
<update id="update">
update scenic_account
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="account != null and account != ''">
account = #{account},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
update_time = now()
</set>
where id = #{id}
</update>
<update id="updateStatus">
update scenic_account
set status = (CASE
WHEN status = 1 THEN
0
WHEN status = 0 THEN
1
ELSE null
END)
where id = #{id}
</update>
<delete id="deleteById">
delete from scenic_account where id = #{id}
</delete>
<delete id="deleteByScenicId">
delete from scenic_account where scenic_id = #{scenicId}
</delete>
<select id="getSuperAccountOfScenic"
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select id, scenic_id, is_super, name, account, password, create_time, update_time
from scenic_account
where scenic_id = #{scenicId} and is_super = 1
</select>
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select id, scenic_id, is_super, name, account, password, create_time, update_time
from scenic_account
where account = #{account}
</select>
</mapper>

View File

@ -16,6 +16,9 @@
<if test="name!=null and name!=''">
`name`=#{name},
</if>
<if test="phone!=null and phone!=''">
`phone`=#{phone},
</if>
<if test="introduction!=null and introduction!=''">
introduction=#{introduction},
</if>
@ -77,8 +80,10 @@
delete from scenic_config where scenic_id = #{scenicId}
</delete>
<select id="list" resultMap="scenicAndConfig">
select s.id, `name`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
c.start_time, c.end_time, c.is_default, c.create_time
select s.id, `name`, `phone`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
c.start_time, c.end_time,
(select scenic_account.account from scenic_account where scenic_account.scenic_id = s.id and scenic_account.is_super = 1 limit 1) as account,
c.is_default, c.create_time
from scenic s
left join scenic_config c on s.id = c.id
<where>
@ -106,7 +111,7 @@
</where>
</select>
<select id="getById" resultMap="scenicAndConfig">
select s.id, `name`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
select s.id, `name`, `phone`, introduction, longitude, latitude, radius, province, city, area, address, `status`, s.create_time, update_time,
c.start_time, c.end_time, c.is_default, c.create_time,s.price
from scenic s
left join scenic_config c on s.id = c.id
@ -114,8 +119,10 @@
</select>
<resultMap id="scenicAndConfig" type="com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO">
<id property="id" column="s.id"/>
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="account" column="account"/>
<result property="phone" column="phone"/>
<result property="introduction" column="introduction"/>
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>