Browse Source

统计营收

Signed-off-by: fengb <fengbin1989@aliyun.com>
cangku
fengb 3 years ago
parent
commit
a984cf0d24
  1. 2
      hiver-core/src/main/java/cc/hiver/core/entity/User.java
  2. 26
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
  3. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
  4. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopDao.java
  5. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  6. 25
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ShopRevenue.java
  7. 27
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/QueryShopRevenueVO.java
  8. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java
  9. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java
  10. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

2
hiver-core/src/main/java/cc/hiver/core/entity/User.java

@ -79,7 +79,7 @@ public class User extends HiverBaseEntity {
@ApiModelProperty(value = "用户头像")
private String avatar = UserConstant.USER_DEFAULT_AVATAR;
@ApiModelProperty(value = "用户类型 0普通用户 1管理员")
@ApiModelProperty(value = "用户类型 0普通用户 1管理员 2客户")
private Integer type = UserConstant.USER_TYPE_NORMAL;
@ApiModelProperty(value = "状态 默认0正常 -1拉黑")

26
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java

@ -1,7 +1,10 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.enums.LogType;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.utils.StringUtils;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
@ -14,6 +17,7 @@ import cc.hiver.core.service.UserService;
import cc.hiver.mall.entity.Customer;
import cc.hiver.mall.pojo.dto.DebtCustomer;
import cc.hiver.mall.service.mybatis.CustomerService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,9 +31,11 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@ -49,6 +55,9 @@ public class CustomerController {
@Autowired
private RoleService roleService;
@Autowired
private SecurityUtil securityUtil;
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "新增客户")
@Transactional
@ -151,4 +160,21 @@ public class CustomerController {
return new ResultUtil<List<DebtCustomer>>().setData(list);
}
@RequestMapping(value = "/userType", method = RequestMethod.POST)
@ApiOperation(value = "判断登录用户是否为客户,1-是,0-否")
public Result userType(@RequestParam String username,
@RequestParam String password) {
User user = securityUtil.checkUserPassword(username, password);
if(ObjectUtils.isEmpty(user)){
return ResultUtil.error("账号或密码错误");
}
if (user.getType() == 2){
return ResultUtil.success("1");
}else{
return ResultUtil.success("0");
}
}
}

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java

@ -23,6 +23,8 @@ import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.entity.ShopArea;
import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.pojo.dto.ShopRevenue;
import cc.hiver.mall.pojo.vo.QueryShopRevenueVO;
import cc.hiver.mall.service.ShopAreaService;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.ShopUserService;
@ -179,4 +181,12 @@ public class ShopController {
List<Shop> list = shopService.getShopInfoByUserid(userId);
return new ResultUtil<List<Shop>>().setData(list);
}
@RequestMapping(value = "/getShopRevenue", method = RequestMethod.GET)
@ApiOperation(value = "统计店铺营收")
public Result<List<ShopRevenue>> getShopRevenue(QueryShopRevenueVO queryShopRevenueVO) {
List<ShopRevenue> list = shopService.getShopRevenue(queryShopRevenueVO);
return new ResultUtil<List<ShopRevenue>>().setData(list);
}
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopDao.java

@ -17,6 +17,8 @@ package cc.hiver.mall.dao;
import cc.hiver.mall.entity.Shop;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.pojo.dto.ShopRevenue;
import cc.hiver.mall.pojo.vo.QueryShopRevenueVO;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -51,4 +53,5 @@ public interface ShopDao extends HiverBaseDao<Shop, String> {
*/
@Query(value = "select * from t_shop where id in (select shop_id from t_shop_user where user_id = ?)",nativeQuery = true)
List<Shop> getShopInfoByUserid(String userId);
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java

@ -2,6 +2,8 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.entity.SaleExample;
import cc.hiver.mall.pojo.dto.ShopRevenue;
import cc.hiver.mall.pojo.vo.QueryShopRevenueVO;
import cc.hiver.mall.pojo.vo.SaleAllVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@ -36,4 +38,5 @@ public interface SaleMapper extends BaseMapper<Sale> {
SaleAllVO saleMaxAmount(SaleExample example);
List<ShopRevenue> getShopRevenue(QueryShopRevenueVO queryShopRevenueVO);
}

25
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ShopRevenue.java

@ -0,0 +1,25 @@
package cc.hiver.mall.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @类描述
* @作者 冯彬
* @时间 2023/9/25-下午10:41
*/
@Data
@ApiModel(value = "商铺营收")
public class ShopRevenue {
@ApiModelProperty(value = "营收")
private BigDecimal realAmount;
@ApiModelProperty(value = "日期")
private Date dt;
}

27
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/QueryShopRevenueVO.java

@ -0,0 +1,27 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @类描述
* @作者 冯彬
* @时间 2023/9/25-下午10:39
*/
@Data
@ApiModel(value = "商铺营收查询条件")
public class QueryShopRevenueVO {
@ApiModelProperty(value = "商铺id")
private String shopId;
@ApiModelProperty(value = "起始日期")
private Date startDate;
@ApiModelProperty(value = "结束日期")
private Date endDate;
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopService.java

@ -17,6 +17,8 @@ package cc.hiver.mall.service;
import cc.hiver.mall.entity.Shop;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.pojo.dto.ShopRevenue;
import cc.hiver.mall.pojo.vo.QueryShopRevenueVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@ -57,4 +59,6 @@ public interface ShopService extends HiverBaseService<Shop, String> {
* @param userId
*/
List<Shop> getShopInfoByUserid(String userId);
List<ShopRevenue> getShopRevenue(QueryShopRevenueVO queryShopRevenueVO);
}

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopServiceImpl.java

@ -16,7 +16,10 @@ limitations under the License.
package cc.hiver.mall.serviceimpl;
import cc.hiver.mall.dao.ShopDao;
import cc.hiver.mall.dao.mapper.SaleMapper;
import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.pojo.dto.ShopRevenue;
import cc.hiver.mall.pojo.vo.QueryShopRevenueVO;
import cc.hiver.mall.service.ShopService;
import cc.hiver.core.base.HiverBaseDao;
import cn.hutool.core.util.StrUtil;
@ -43,6 +46,9 @@ public class ShopServiceImpl implements ShopService {
@Autowired
private ShopDao shopDao;
@Autowired
private SaleMapper saleMapper;
@Override
public HiverBaseDao<Shop, String> getRepository() {
return shopDao;
@ -86,4 +92,9 @@ public class ShopServiceImpl implements ShopService {
return shopDao.getShopInfoByUserid(userId);
}
@Override
public List<ShopRevenue> getShopRevenue(QueryShopRevenueVO queryShopRevenueVO) {
return saleMapper.getShopRevenue(queryShopRevenueVO);
}
}

12
hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

@ -495,4 +495,16 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="getShopRevenue" parameterType="cc.hiver.mall.pojo.vo.QueryShopRevenueVO" resultType="cc.hiver.mall.pojo.dto.ShopRevenue">
select DATE_FORMAT(create_time, '%Y-%m-%d') dt,sum(real_amount) real_amount
from t_sale
where 1=1
and create_time &gt;= #{startDate,jdbcType=TIMESTAMP}
and create_time &lt;= #{endDate,jdbcType=TIMESTAMP}
and shop_id = #{shopId,jdbcType=VARCHAR}
group by DATE_FORMAT(create_time, '%Y-%m-%d')
</select>
</mapper>
Loading…
Cancel
Save