2023-06-22-01-bug

master
喻忠伟 1 year ago
parent 658e7e6349
commit af1e203355
  1. 37
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/mapper/ZyOrdersMapper.java
  2. 46
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/mapper/xml/ZyOrdersMapper.xml
  3. 21
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/IZyOrdersService.java
  4. 171
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/impl/ZyOrdersServiceImpl.java
  5. 12
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/vo/Groups.java
  6. 11
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/vo/OrderSource.java
  7. 11
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/vo/ShopNameAndPayTime.java
  8. 11
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/vo/SourceType.java
  9. 24
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/vo/UserAge.java
  10. 25
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/controller/LargeScreenController.java

@ -1,10 +1,13 @@
package org.jeecg.modules.demo.zyorders.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.zyorders.entity.ZyOrders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.demo.zyorders.vo.ShopNameAndPayTime;
import org.jeecg.modules.demo.zyorders.vo.UserAge;
import org.jeecg.modules.demo.zyorders.vo.ZyNameAndPayMoney;
import org.jeecg.modules.demo.zyorders.vo.ZyOrderPayAndTime;
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo;
@ -23,7 +26,41 @@ public interface ZyOrdersMapper extends BaseMapper<ZyOrders> {
*/
TodayOrderAndQIriVo getTotalOrderAndWeek();
/**
*查询所有店铺上月销售额
* @param start_time
* @param end_time
* @param org_code
* @return
*/
List<ZyNameAndPayMoney> selectAllShopSalesVolumeByLastM( @Param("start_time") String start_time,@Param("end_time") String end_time,@Param("org_code") String org_code);
/**
* 查询店铺12月销售额
* @param id
* @param start_time
* @param end_time
* @return
*/
List<ZyOrderPayAndTime> selectCurrentSales(@Param("id")String id, @Param("start_time")String start_time, @Param("end_time")String end_time);
/**
* 订单来源
* @param org_code
* @return
*/
List<Date> selectSourceType(@Param("org_code") String org_code);
/**
* 订单消费群体
* @return
*/
List<UserAge> consumerGroups();
/**
* 订单销售分析
* @param lastSevenDay
* @return
*/
List<ShopNameAndPayTime> selectOrderSale(@Param("lastSevenDay") String lastSevenDay);
}

@ -46,4 +46,50 @@
</where>
</select>
<!-- 订单来源 -->
<select id="selectSourceType" resultType="java.util.Date">
SELECT orders.payment_time as pay_time FROM
zy_orders AS orders
LEFT JOIN order_goods ON order_goods.orders_id=orders.id
LEFT JOIN zy_goods AS goods ON goods.id=order_goods.goods_id
LEFT JOIN sys_depart AS dep ON dep.id=goods.enterprises_id
<where>
orders.ischild=1 and dep.org_category=#{org_code}
</where>
</select>
<!--订单消费群体-->
<select id="consumerGroups" resultType="org.jeecg.modules.demo.zyorders.vo.UserAge">
SELECT
a.id,
a.birthday,
NOW( ) nowtime,
TIMESTAMPDIFF( YEAR, a.birthday, CURDATE( ) ) age
FROM
sys_user a,
zy_orders b
WHERE
a.id = b.user_id
GROUP BY
a.id
ORDER BY
age
</select>
<!-- 订单销售分析 -->
<select id="selectOrderSale" resultType="org.jeecg.modules.demo.zyorders.vo.ShopNameAndPayTime">
SELECT orders.payment_time as pay_time,dep.depart_name as name FROM
zy_orders AS orders
LEFT JOIN order_goods ON order_goods.orders_id=orders.id
LEFT JOIN zy_goods AS goods ON goods.id=order_goods.goods_id
LEFT JOIN sys_depart AS dep ON dep.id=goods.enterprises_id
<where>
orders.ischild=1
AND orders.payment_time LIKE concat(concat('',#{lastSevenDay}),'%')
</where>
</select>
</mapper>

@ -5,8 +5,11 @@ import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk;
import org.jeecg.modules.demo.zyorders.entity.ZyOrders;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk;
import org.jeecg.modules.demo.zyorders.vo.Groups;
import org.jeecg.modules.demo.zyorders.vo.OrderSource;
import org.jeecg.modules.largeScreen.vo.Type;
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo;
import org.jeecg.modules.shop.vo.OrderSales;
import java.util.List;
import java.util.Map;
@ -46,4 +49,22 @@ public interface IZyOrdersService extends IService<ZyOrders> {
* @return
*/
List<Type> getsales12Month();
/**
* 订单来源
* @return
*/
List<OrderSource> selectSourceType();
/**
* 订单消费群体
* @return
*/
List<Groups> consumerGroups();
/**
* 订单销售分析
* @return
*/
List<OrderSales> selectOrderSale();
}

@ -28,8 +28,7 @@ import org.jeecg.modules.demo.zyorders.entity.ZyOrders;
import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk;
import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper;
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService;
import org.jeecg.modules.demo.zyorders.vo.ZyNameAndPayMoney;
import org.jeecg.modules.demo.zyorders.vo.ZyOrderPayAndTime;
import org.jeecg.modules.demo.zyorders.vo.*;
import org.jeecg.modules.largeScreen.vo.Type;
import org.jeecg.modules.largeScreen.vo.ZyShopSales;
import org.jeecg.modules.message.entity.ZySpeechMessage;
@ -37,6 +36,8 @@ import org.jeecg.modules.message.mapper.ZySpeechMessageMapper;
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo;
import org.jeecg.modules.shop.utils.GetTime;
import org.jeecg.modules.shop.utils.mapSort;
import org.jeecg.modules.shop.vo.OrderSales;
import org.jeecg.modules.shop.vo.OrderSalesH;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.factory.annotation.Autowired;
@ -444,6 +445,172 @@ public class ZyOrdersServiceImpl extends ServiceImpl<ZyOrdersMapper, ZyOrders> i
return ls;
}
/**
* 订单来源
* @return
*/
@Override
public List<OrderSource> selectSourceType() {
List<OrderSource> orderSources = new ArrayList<>();
List<String> sourceTypeArr=new ArrayList<>();
sourceTypeArr.add("4");
sourceTypeArr.add("5");
int i=1;
for (String code:sourceTypeArr){
List<Date> list = baseMapper.selectSourceType(code);
OrderSource orderSource = new OrderSource();
List<SourceType> sourceTypeList = new ArrayList<>();
for (int l = 7; l>=1; l--){
String lastSevenDay = GetTime.getLastSevenDay(l);
SourceType sourceType = new SourceType();
sourceType.setPayTime(lastSevenDay);
sourceType.setNumber(0);
sourceTypeList.add(sourceType);
}
Map<String,Integer> map = new HashMap<>();
for (int j = 1;j<=7;j++){
String lastSevenDay = GetTime.getLastSevenDay(j);
map.put(lastSevenDay,0);
}
for (int k = 0;k<list.size();k++){
Date date = list.get(k);
String format = String.format("%tF", date);
if (map.containsKey(format)){
Integer integer = map.get(format);
integer = integer + 1;
map.put(format,integer);
}
}
for (String key:map.keySet()){
for (int m = 0;m<sourceTypeList.size();m++){
String payTime = sourceTypeList.get(m).getPayTime();
if (payTime.equals(key)){
sourceTypeList.get(m).setNumber(map.get(key));
}
}
}
orderSource.setSourceType(i);
orderSource.setLs(sourceTypeList);
orderSources.add(orderSource);
i++;
}
return orderSources;
}
/**
* 订单消费群体
* @return
*/
@Override
public List<Groups> consumerGroups() {
int one = 0, two = 0, three = 0, four = 0, five = 0;
String[] s = {"18-24", "24-30", "30-36", "36-42", "其他"};
List<UserAge> userAges = baseMapper.consumerGroups();
List<Integer> ages = new ArrayList<>();
List<Groups> groups = new ArrayList<>();
for (int i = 0; i < userAges.size(); i++) {
Integer age = userAges.get(i).getAge();
int n = age / 6;
switch (n) {
case 3:
one++;
break;
case 4:
two++;
break;
case 5:
three++;
break;
case 6:
four++;
break;
default:
five++;
break;
}
}
ages.add(0, one);
ages.add(1, two);
ages.add(2, three);
ages.add(3, four);
ages.add(4, five);
for (int i = 0; i < 5; i++) {
Groups groups1 = new Groups();
groups1.setGroup(s[i]);
groups1.setNum(ages.get(i));
groups.add(i, groups1);
}
return groups;
}
/**
* 订单销售分析
* @return
*/
@Override
public List<OrderSales> selectOrderSale() {
String lastSevenDay = GetTime.getLastSevenDay(1);
//查找所有店铺
QueryWrapper<SysDepart> depWra=new QueryWrapper();
String[] a3 = {"4","5"};
depWra.in("org_category",a3);
List<SysDepart> depList = sysDepartService.list(depWra);
List<ShopNameAndPayTime> shopNameAndPayTimes = baseMapper.selectOrderSale(lastSevenDay);
List<OrderSales> ls = new ArrayList<>();
for(SysDepart item:depList){
//for (int j = 0;j<list.size();j++){
// String s = list.get(j);
Map<Integer,Integer> map = new HashMap<>();
List<OrderSalesH> orderSalesHList = new ArrayList<>();
for (int l = 0;l<=18;l=l+6){
OrderSalesH orderSalesH = new OrderSalesH();
orderSalesH.setTime(l);
orderSalesH.setNumber(0);
orderSalesHList.add(orderSalesH);
}
for (int i = 0;i<=18;i=i+6){
map.put(i,0);
}
for (int k = 0;k<shopNameAndPayTimes.size();k++){
String name = shopNameAndPayTimes.get(k).getName();
if (name.equals(item.getDepartName())){
Date payTime = shopNameAndPayTimes.get(k).getPayTime();
String format = String.format("%tH", payTime);
int i = Integer.parseInt(format);
for (int z = 0;z<=18;z=z+6){
if (i>=z && i<=z+6){
i = z;
}
}
if (map.containsKey(i)){
Integer integer = map.get(i);
map.put(i,integer+1);
}
}
}
for(Integer key:map.keySet()) {
for (int m = 0;m<orderSalesHList.size();m++){
Integer time = orderSalesHList.get(m).getTime();
if (key == time){
orderSalesHList.get(m).setNumber(map.get(key));
}
}
}
OrderSales orderSales = new OrderSales();
orderSales.setName(item.getDepartName());
orderSales.setLs(orderSalesHList);
ls.add(orderSales);
}
return ls;
}
/**
* 生成订单编号

@ -0,0 +1,12 @@
package org.jeecg.modules.demo.zyorders.vo;
import lombok.Data;
@Data
public class Groups {
private String group;
private Integer num;
}

@ -0,0 +1,11 @@
package org.jeecg.modules.demo.zyorders.vo;
import lombok.Data;
import java.util.List;
@Data
public class OrderSource {
private Integer sourceType;
List<SourceType> ls;
}

@ -0,0 +1,11 @@
package org.jeecg.modules.demo.zyorders.vo;
import lombok.Data;
import java.util.Date;
@Data
public class ShopNameAndPayTime {
private String name;
private Date payTime;
}

@ -0,0 +1,11 @@
package org.jeecg.modules.demo.zyorders.vo;
import lombok.Data;
@Data
public class SourceType {
//支付时间
private String payTime;
//支付类型
private Integer number;
}

@ -0,0 +1,24 @@
package org.jeecg.modules.demo.zyorders.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class UserAge {
private String id;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date brithday;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date nowtime;
private Integer age;
}

@ -12,6 +12,8 @@ import org.jeecg.modules.demo.ordergoods.entity.OrderGoods;
import org.jeecg.modules.demo.ordergoods.service.IOrderGoodsService;
import org.jeecg.modules.demo.zyorders.entity.ZyOrders;
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService;
import org.jeecg.modules.demo.zyorders.vo.Groups;
import org.jeecg.modules.demo.zyorders.vo.OrderSource;
import org.jeecg.modules.largeScreen.vo.LargeOrderVo;
import org.jeecg.modules.largeScreen.vo.Type;
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo;
@ -141,6 +143,14 @@ public class LargeScreenController {
return Result.OK(list);
}
@AutoLog(value = "订单来源")
@ApiOperation(value = "订单来源", notes = "订单来源")
@GetMapping("/selectSourceType")
public Result<?> selectSourceType(){
List<OrderSource> list = zyOrdersService.selectSourceType();
return Result.OK(list);
}
@AutoLog(value = "获取最新订单")
@ApiOperation(value = "获取最新订单", notes = "获取最新订单")
@GetMapping("/getNewOder")
@ -225,4 +235,19 @@ public class LargeScreenController {
return Result.OK(list);
}
@AutoLog(value = "订单消费群体")
@ApiOperation(value = "订单消费群体", notes = "订单消费群体")
@GetMapping("/consumerGroups")
public Result<?> consumerGroups() {
List<Groups> groups = zyOrdersService.consumerGroups();
return Result.OK(groups);
}
@AutoLog(value = "订单销售分析")
@ApiOperation(value = "订单销售分析", notes = "订单销售分析")
@GetMapping("/selectOrderSale")
public Result<?> selectOrderSale(){
List<OrderSales> list = zyOrdersService.selectOrderSale();
return Result.OK(list);
}
}

Loading…
Cancel
Save