use of co.yixiang.modules.shop.domain.YxStoreOrderStatus 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.shop.domain.YxStoreOrderStatus 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