1.3.3新增 后台微信图文发送功能,小程序配置,增加小程序授权等,修复一些bug等

This commit is contained in:
hupeng
2019-11-29 19:03:46 +08:00
parent 8c4c9b0387
commit 33a592b833
57 changed files with 1726 additions and 170 deletions

View File

@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -38,6 +39,8 @@ public class RedisServiceImpl implements RedisService {
if (s.toString().indexOf("role::loadPermissionByUser") != -1 || s.toString().indexOf("user::loadUserByUsername") != -1) {
continue;
}
DataType dataType = redisTemplate.type(s.toString());
if(dataType.code().equals("hash")) continue;
RedisVo redisVo = new RedisVo(s.toString(),redisTemplate.opsForValue().get(s.toString()).toString());
redisVos.add(redisVo);
}

View File

@ -1,8 +1,12 @@
package co.yixiang.modules.shop.repository;
import co.yixiang.modules.shop.domain.YxStoreOrder;
import co.yixiang.modules.shop.service.dto.ChartDataDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* @author hupeng
@ -10,6 +14,36 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
*/
public interface YxStoreOrderRepository extends JpaRepository<YxStoreOrder, Integer>, JpaSpecificationExecutor {
//今天 //上周 //本月
int countByPayTimeGreaterThanEqual(int time);
//昨天
int countByPayTimeLessThanAndPayTimeGreaterThanEqual(int timeO,int timeT);
@Query(value = "select IFNULL(sum(pay_price),0) from yx_store_order " +
"where refund_status=0 and is_del=0 and paid=1 and pay_time >= ?1",nativeQuery = true)
double sumPrice(Integer time);
@Query(value = "select IFNULL(sum(pay_price),0) from yx_store_order " +
"where refund_status=0 and is_del=0 and paid=1 and pay_time >= ?1 and pay_time < ?2",nativeQuery = true)
double sumTPrice(Integer timeO,Integer timeT);
@Query(value = "SELECT IFNULL(sum(pay_price),0) as num," +
"FROM_UNIXTIME(add_time, '%m-%d') as time " +
" FROM yx_store_order where refund_status=0 and is_del=0 and paid=1 and pay_time >= ?1" +
" GROUP BY FROM_UNIXTIME(add_time,'%Y-%m-%d') " +
" ORDER BY add_time ASC",nativeQuery = true)
List<ChartDataDTO> chartList(Integer time);
@Query(value = "SELECT count(id) as num," +
"FROM_UNIXTIME(add_time, '%m-%d') as time " +
" FROM yx_store_order where refund_status=0 and is_del=0 and paid=1 and pay_time >= ?1" +
" GROUP BY FROM_UNIXTIME(add_time,'%Y-%m-%d') " +
" ORDER BY add_time ASC",nativeQuery = true)
List<ChartDataDTO> chartListT(Integer time);
/**
* findByUnique
* @param unique

View File

@ -36,6 +36,8 @@ public class YxStoreCategoryController {
@GetMapping(value = "/yxStoreCategory")
@PreAuthorize("hasAnyRole('ADMIN','YXSTORECATEGORY_ALL','YXSTORECATEGORY_SELECT')")
public ResponseEntity getYxStoreCategorys(YxStoreCategoryQueryCriteria criteria, Pageable pageable){
List<YxStoreCategoryDTO> categoryDTOList = yxStoreCategoryService.queryAll(criteria);
return new ResponseEntity(yxStoreCategoryService.buildTree(categoryDTOList),HttpStatus.OK);
}

View File

@ -33,6 +33,19 @@ public class YxStoreOrderController {
@Autowired
private YxStoreOrderStatusService yxStoreOrderStatusService;
@GetMapping(value = "/data/count")
//@PreAuthorize("hasAnyRole('ADMIN','YXSTOREORDER_ALL','YXSTOREORDER_SELECT')")
public ResponseEntity getCount(){
return new ResponseEntity(yxStoreOrderService.getOrderTimeData(),HttpStatus.OK);
}
@GetMapping(value = "/data/chart")
//@PreAuthorize("hasAnyRole('ADMIN','YXSTOREORDER_ALL','YXSTOREORDER_SELECT')")
public ResponseEntity getChart(){
return new ResponseEntity(yxStoreOrderService.chartCount(),HttpStatus.OK);
}
@ApiOperation(value = "查询订单")
@GetMapping(value = "/yxStoreOrder")

View File

@ -58,6 +58,7 @@ public class YxStoreProductController {
@PutMapping(value = "/yxStoreProduct")
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreProduct resources){
//if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
yxStoreProductService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@ -106,6 +107,7 @@ public class YxStoreProductController {
@ApiOperation(value = "清除属性")
@PostMapping(value = "/yxStoreProduct/clearAttr/{id}")
public ResponseEntity clearAttr(@PathVariable Integer id){
//if(id > 0) throw new BadRequestException("演示环境禁止操作");
yxStoreProductService.clearProductAttr(id,true);
return new ResponseEntity(HttpStatus.OK);
}

View File

@ -1,6 +1,7 @@
package co.yixiang.modules.shop.service;
import co.yixiang.modules.shop.domain.YxStoreOrder;
import co.yixiang.modules.shop.service.dto.OrderTimeDataDTO;
import co.yixiang.modules.shop.service.dto.YxStoreOrderDTO;
import co.yixiang.modules.shop.service.dto.YxStoreOrderQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -13,6 +14,9 @@ import java.util.List;
*/
//@CacheConfig(cacheNames = "yxStoreOrder")
public interface YxStoreOrderService {
OrderTimeDataDTO getOrderTimeData();
Map<String,Object> chartCount();
String orderType(int id,int pinkId,int combinationId);

View File

@ -0,0 +1,19 @@
package co.yixiang.modules.shop.service.dto;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import java.io.Serializable;
/**
* @ClassName ChartDataDTO
* @Author hupeng <610796224@qq.com>
* @Date 2019/11/25
**/
//@Data
public interface ChartDataDTO{
// @Value("#{target.adminCount}")
Double getNum();
String getTime();
}

View File

@ -0,0 +1,23 @@
package co.yixiang.modules.shop.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName OrderTimeDataDTO
* @Author hupeng <610796224@qq.com>
* @Date 2019/11/25
**/
@Data
public class OrderTimeDataDTO implements Serializable {
private Double todayPrice; //今日成交额
private Integer todayCount; //今日订单数
private Double proPrice; //昨日成交额
private Integer proCount;//昨日订单数
private Double monthPrice;//本月成交额
private Integer monthCount;//本月订单数
private Integer lastWeekCount;//上周
private Double lastWeekPrice; //上周
}

View File

@ -17,9 +17,7 @@ import co.yixiang.modules.shop.service.YxStoreOrderService;
import co.yixiang.modules.shop.service.YxStoreOrderStatusService;
import co.yixiang.modules.shop.service.YxUserBillService;
import co.yixiang.modules.shop.service.YxUserService;
import co.yixiang.modules.shop.service.dto.YxStoreOrderDTO;
import co.yixiang.modules.shop.service.dto.YxStoreOrderQueryCriteria;
import co.yixiang.modules.shop.service.dto.YxUserDTO;
import co.yixiang.modules.shop.service.dto.*;
import co.yixiang.modules.shop.service.mapper.YxStoreOrderMapper;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.QueryHelp;
@ -27,7 +25,6 @@ import co.yixiang.utils.ValidationUtil;
import com.alibaba.fastjson.JSON;
import co.yixiang.modules.shop.domain.StoreOrderCartInfo;
import co.yixiang.modules.shop.repository.YxStoreOrderCartInfoRepository;
import co.yixiang.modules.shop.service.dto.StoreOrderCartInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -70,6 +67,44 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
@Autowired
private YxStorePinkRepository storePinkRepository;
@Override
public OrderTimeDataDTO getOrderTimeData() {
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
int yesterday = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.
yesterday()));
int lastWeek = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.lastWeek()));
int nowMonth = OrderUtil.dateToTimestampT(DateUtil
.beginOfMonth(new Date()));
OrderTimeDataDTO orderTimeDataDTO = new OrderTimeDataDTO();
orderTimeDataDTO.setTodayCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(today));
orderTimeDataDTO.setTodayPrice(yxStoreOrderRepository.sumPrice(today));
orderTimeDataDTO.setProCount(yxStoreOrderRepository
.countByPayTimeLessThanAndPayTimeGreaterThanEqual(today,yesterday));
orderTimeDataDTO.setProPrice(yxStoreOrderRepository.sumTPrice(today,yesterday));
orderTimeDataDTO.setLastWeekCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(lastWeek));
orderTimeDataDTO.setLastWeekPrice(yxStoreOrderRepository.sumPrice(lastWeek));
orderTimeDataDTO.setMonthCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(nowMonth));
orderTimeDataDTO.setMonthPrice(yxStoreOrderRepository.sumPrice(nowMonth));
return orderTimeDataDTO;
}
@Override
public Map<String, Object> chartCount() {
Map<String, Object> map = new LinkedHashMap<>();
int nowMonth = OrderUtil.dateToTimestampT(DateUtil
.beginOfMonth(new Date()));
map.put("chart",yxStoreOrderRepository.chartList(nowMonth));
map.put("chartT",yxStoreOrderRepository.chartListT(nowMonth));
return map;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void refund(YxStoreOrder resources) {

View File

@ -102,7 +102,7 @@ public class RoleController {
@PutMapping(value = "/roles/menu")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity updateMenu(@RequestBody Role resources){
//if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
//
roleService.updateMenu(resources,roleService.findById(resources.getId()));
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@ -111,7 +111,7 @@ public class RoleController {
@DeleteMapping(value = "/roles/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
//if(id > 0) throw new BadRequestException("演示环境禁止操作");
// if(id > 0) throw new BadRequestException("演示环境禁止操作");
try {
roleService.delete(id);
}catch (Throwable e){

View File

@ -162,6 +162,7 @@ public class UserController {
*/
@PostMapping(value = "/users/updateAvatar")
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
//if(ObjectUtil.isNotNull(file)) throw new BadRequestException("演示环境禁止操作");
userService.updateAvatar(file);
return new ResponseEntity(HttpStatus.OK);
}

View File

@ -2,6 +2,7 @@ package co.yixiang.modules.system.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
@ -10,7 +11,7 @@ import java.util.List;
* @date 2018-12-17
*/
@Data
public class MenuDTO {
public class MenuDTO implements Serializable {
private Long id;

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.wechat.domain.YxSystemConfig;
import co.yixiang.utils.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import co.yixiang.aop.log.Log;
@ -51,6 +52,7 @@ public class YxSystemConfigController {
YxSystemConfig yxSystemConfigModel = new YxSystemConfig();
yxSystemConfigModel.setMenuName(key);
yxSystemConfigModel.setValue(value.toString());
RedisUtil.set(key,value.toString());
if(ObjectUtil.isNull(yxSystemConfig)){
yxSystemConfigService.create(yxSystemConfigModel);
}else{
@ -63,23 +65,6 @@ public class YxSystemConfigController {
return new ResponseEntity(HttpStatus.CREATED);
}
@Log("修改YxSystemConfig")
@ApiOperation(value = "修改YxSystemConfig")
@PutMapping(value = "/yxSystemConfig")
@PreAuthorize("hasAnyRole('ADMIN','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxSystemConfig resources){
//if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
yxSystemConfigService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log("删除YxSystemConfig")
@ApiOperation(value = "删除YxSystemConfig")
@DeleteMapping(value = "/yxSystemConfig/{id}")
@PreAuthorize("hasAnyRole('ADMIN','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_DELETE')")
public ResponseEntity delete(@PathVariable Integer id){
//if(id > 0) throw new BadRequestException("演示环境禁止操作");
yxSystemConfigService.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
}

View File

@ -35,7 +35,9 @@ public class YxSystemConfigServiceImpl implements YxSystemConfigService {
@Override
public Map<String,Object> queryAll(YxSystemConfigQueryCriteria criteria, Pageable pageable){
Page<YxSystemConfig> page = yxSystemConfigRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
Page<YxSystemConfig> page = yxSystemConfigRepository
.findAll((root, criteriaQuery, criteriaBuilder)
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(yxSystemConfigMapper::toDto));
}