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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations