Search in sources :

Example 1 with NoRepeatSubmit

use of co.yixiang.modules.aop.NoRepeatSubmit in project yshopmall by guchengwuyue.

the class SystemGroupDataController method create.

@NoRepeatSubmit
@Log("新增数据配置")
@ApiOperation(value = "新增数据配置")
@PostMapping(value = "/yxSystemGroupData")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true)
@PreAuthorize("hasAnyRole('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_CREATE')")
public ResponseEntity create(@RequestBody String jsonStr) {
    JSONObject jsonObject = JSON.parseObject(jsonStr);
    if (ObjectUtil.isNotNull(jsonObject.get("name"))) {
        if (StrUtil.isEmpty(jsonObject.get("name").toString())) {
            throw new BadRequestException("名称必须填写");
        }
    }
    if (ObjectUtil.isNotNull(jsonObject.get("title"))) {
        if (StrUtil.isEmpty(jsonObject.get("title").toString())) {
            throw new BadRequestException("标题必须填写");
        }
    }
    if (ObjectUtil.isNotNull(jsonObject.get("info"))) {
        if (StrUtil.isEmpty(jsonObject.get("info").toString())) {
            throw new BadRequestException("简介必须填写");
        }
    }
    if (ObjectUtil.isNotNull(jsonObject.get("pic"))) {
        if (StrUtil.isEmpty(jsonObject.get("pic").toString())) {
            throw new BadRequestException("图片必须上传");
        }
    }
    YxSystemGroupData yxSystemGroupData = new YxSystemGroupData();
    yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString());
    jsonObject.remove("groupName");
    yxSystemGroupData.setValue(jsonObject.toJSONString());
    yxSystemGroupData.setStatus(jsonObject.getInteger("status"));
    yxSystemGroupData.setSort(jsonObject.getInteger("sort"));
    return new ResponseEntity(yxSystemGroupDataService.save(yxSystemGroupData), HttpStatus.CREATED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) JSONObject(com.alibaba.fastjson.JSONObject) BadRequestException(co.yixiang.exception.BadRequestException) YxSystemGroupData(co.yixiang.modules.shop.domain.YxSystemGroupData) Log(co.yixiang.modules.logging.aop.log.Log) CacheEvict(org.springframework.cache.annotation.CacheEvict) NoRepeatSubmit(co.yixiang.modules.aop.NoRepeatSubmit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with NoRepeatSubmit

use of co.yixiang.modules.aop.NoRepeatSubmit in project yshopmall by guchengwuyue.

the class SystemStoreStaffController method create.

@NoRepeatSubmit
@PostMapping
@Log("新增门店店员")
@ApiOperation("新增门店店员")
@PreAuthorize("@el.check('yxSystemStoreStaff:add')")
public ResponseEntity<Object> create(@Validated @RequestBody YxSystemStoreStaff resources) {
    YxSystemStore systemStore = yxSystemStoreService.getOne(Wrappers.<YxSystemStore>lambdaQuery().eq(YxSystemStore::getId, resources.getStoreId()));
    resources.setStoreName(systemStore.getName());
    return new ResponseEntity<>(yxSystemStoreStaffService.save(resources), HttpStatus.CREATED);
}
Also used : YxSystemStore(co.yixiang.modules.shop.domain.YxSystemStore) ResponseEntity(org.springframework.http.ResponseEntity) Log(co.yixiang.modules.logging.aop.log.Log) NoRepeatSubmit(co.yixiang.modules.aop.NoRepeatSubmit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with NoRepeatSubmit

use of co.yixiang.modules.aop.NoRepeatSubmit in project yshopmall by guchengwuyue.

the class StoreOrderController method editOrder.

@NoRepeatSubmit
@Log("修改订单")
@ApiOperation(value = "修改订单")
@PostMapping(value = "/yxStoreOrder/edit")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity editOrder(@RequestBody YxStoreOrder resources) {
    if (ObjectUtil.isNull(resources.getPayPrice())) {
        throw new BadRequestException("请输入支付金额");
    }
    if (resources.getPayPrice().doubleValue() < 0) {
        throw new BadRequestException("金额不能低于0");
    }
    YxStoreOrderDto storeOrder = generator.convert(yxStoreOrderService.getById(resources.getId()), YxStoreOrderDto.class);
    // 判断金额是否有变动,生成一个额外订单号去支付
    int res = NumberUtil.compare(storeOrder.getPayPrice().doubleValue(), resources.getPayPrice().doubleValue());
    if (res != 0) {
        String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
        resources.setExtendOrderId(orderSn);
    }
    yxStoreOrderService.saveOrUpdate(resources);
    YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus();
    storeOrderStatus.setOid(resources.getId());
    storeOrderStatus.setChangeType(OrderLogEnum.ORDER_EDIT.getValue());
    storeOrderStatus.setChangeMessage("修改订单价格为:" + resources.getPayPrice());
    storeOrderStatus.setChangeTime(new Date());
    yxStoreOrderStatusService.save(storeOrderStatus);
    return new ResponseEntity(HttpStatus.OK);
}
Also used : YxStoreOrderDto(co.yixiang.modules.shop.service.dto.YxStoreOrderDto) ResponseEntity(org.springframework.http.ResponseEntity) YxStoreOrderStatus(co.yixiang.modules.shop.domain.YxStoreOrderStatus) BadRequestException(co.yixiang.exception.BadRequestException) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(co.yixiang.modules.logging.aop.log.Log) NoRepeatSubmit(co.yixiang.modules.aop.NoRepeatSubmit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with NoRepeatSubmit

use of co.yixiang.modules.aop.NoRepeatSubmit in project yshopmall by guchengwuyue.

the class StoreOrderController method check.

@NoRepeatSubmit
@ApiOperation(value = "订单核销")
@PutMapping(value = "/yxStoreOrder/check")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity check(@Validated @RequestBody YxStoreOrder resources) {
    if (StrUtil.isBlank(resources.getVerifyCode())) {
        throw new BadRequestException("核销码不能为空");
    }
    YxStoreOrderDto storeOrderDTO = generator.convert(yxStoreOrderService.getById(resources.getId()), YxStoreOrderDto.class);
    if (!resources.getVerifyCode().equals(storeOrderDTO.getVerifyCode())) {
        throw new BadRequestException("核销码不对");
    }
    if (OrderInfoEnum.PAY_STATUS_0.getValue().equals(storeOrderDTO.getPaid())) {
        throw new BadRequestException("订单未支付");
    }
    /**
     *         if(storeOrderDTO.getStatus() > 0) throw new BadRequestException("订单已核销");
     *
     *         if(storeOrderDTO.getCombinationId() > 0 && storeOrderDTO.getPinkId() > 0){
     *         YxStorePinkDTO storePinkDTO = storePinkService.findById(storeOrderDTO.getPinkId());
     *         if(!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePinkDTO.getStatus())){
     *         throw new BadRequestException("拼团订单暂未成功无法核销");
     *         }
     *         }
     */
    // 远程调用API
    RestTemplate rest = new RestTemplate();
    String url = StrUtil.format(apiUrl + "/order/admin/order_verific/{}", resources.getVerifyCode());
    String text = rest.getForObject(url, String.class);
    JSONObject jsonObject = JSON.parseObject(text);
    Integer status = jsonObject.getInteger("status");
    String msg = jsonObject.getString("msg");
    if (status != 200) {
        throw new BadRequestException(msg);
    }
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
Also used : YxStoreOrderDto(co.yixiang.modules.shop.service.dto.YxStoreOrderDto) ResponseEntity(org.springframework.http.ResponseEntity) JSONObject(com.alibaba.fastjson.JSONObject) RestTemplate(org.springframework.web.client.RestTemplate) BadRequestException(co.yixiang.exception.BadRequestException) NoRepeatSubmit(co.yixiang.modules.aop.NoRepeatSubmit) ApiOperation(io.swagger.annotations.ApiOperation) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with NoRepeatSubmit

use of co.yixiang.modules.aop.NoRepeatSubmit in project yshopmall by guchengwuyue.

the class StoreOrderController method update.

@NoRepeatSubmit
@ApiOperation(value = "发货")
@PutMapping(value = "/yxStoreOrder")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreOrder resources) {
    if (StrUtil.isBlank(resources.getDeliveryName())) {
        throw new BadRequestException("请选择快递公司");
    }
    if (StrUtil.isBlank(resources.getDeliveryId())) {
        throw new BadRequestException("快递单号不能为空");
    }
    YxExpressDto expressDTO = generator.convert(yxExpressService.getById(Integer.valueOf(resources.getDeliveryName())), YxExpressDto.class);
    if (ObjectUtil.isNull(expressDTO)) {
        throw new BadRequestException("请先添加快递公司");
    }
    resources.setStatus(1);
    resources.setDeliveryType("express");
    resources.setDeliveryName(expressDTO.getName());
    resources.setDeliverySn(expressDTO.getCode());
    yxStoreOrderService.update(resources);
    YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus();
    storeOrderStatus.setOid(resources.getId());
    storeOrderStatus.setChangeType("delivery_goods");
    storeOrderStatus.setChangeMessage("已发货 快递公司:" + resources.getDeliveryName() + " 快递单号:" + resources.getDeliveryId());
    storeOrderStatus.setChangeTime(new Date());
    yxStoreOrderStatusService.save(storeOrderStatus);
    // 模板消息通知
    try {
        String openid = this.getUserOpenid(resources.getUid());
        if (StrUtil.isNotBlank(openid)) {
            templateService.deliverySuccessNotice(resources.getOrderId(), expressDTO.getName(), resources.getDeliveryId(), openid);
        }
    } catch (Exception e) {
        log.info("当前用户不是微信用户不能发送模板消息哦!");
    }
    // 加入redis,7天后自动确认收货
    String redisKey = String.valueOf(StrUtil.format("{}{}", ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM, resources.getId()));
    redisTemplate.opsForValue().set(redisKey, resources.getOrderId(), ShopConstants.ORDER_OUTTIME_UNCONFIRM, TimeUnit.DAYS);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) YxStoreOrderStatus(co.yixiang.modules.shop.domain.YxStoreOrderStatus) BadRequestException(co.yixiang.exception.BadRequestException) YxExpressDto(co.yixiang.modules.shop.service.dto.YxExpressDto) Date(java.util.Date) BadRequestException(co.yixiang.exception.BadRequestException) ParseException(java.text.ParseException) IOException(java.io.IOException) NoRepeatSubmit(co.yixiang.modules.aop.NoRepeatSubmit) ApiOperation(io.swagger.annotations.ApiOperation) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

NoRepeatSubmit (co.yixiang.modules.aop.NoRepeatSubmit)9 ApiOperation (io.swagger.annotations.ApiOperation)9 ResponseEntity (org.springframework.http.ResponseEntity)9 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 Log (co.yixiang.modules.logging.aop.log.Log)7 BadRequestException (co.yixiang.exception.BadRequestException)5 JSONObject (com.alibaba.fastjson.JSONObject)4 CacheEvict (org.springframework.cache.annotation.CacheEvict)3 YxStoreOrderStatus (co.yixiang.modules.shop.domain.YxStoreOrderStatus)2 YxSystemGroupData (co.yixiang.modules.shop.domain.YxSystemGroupData)2 YxSystemStore (co.yixiang.modules.shop.domain.YxSystemStore)2 YxStoreOrderDto (co.yixiang.modules.shop.service.dto.YxStoreOrderDto)2 Date (java.util.Date)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 YxStoreCoupon (co.yixiang.modules.activity.domain.YxStoreCoupon)1 YxSystemConfig (co.yixiang.modules.shop.domain.YxSystemConfig)1 YxExpressDto (co.yixiang.modules.shop.service.dto.YxExpressDto)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1