Compare commits

..

No commits in common. "0426a879b859aa898d93085d43e0f749a7a4b4ba" and "afbd0935e70d862ea40370d03715e3ddd5042ec4" have entirely different histories.

48 changed files with 37 additions and 1282 deletions

View File

@ -1,68 +0,0 @@
package com.agileboot.admin.controller.cabinet;
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.cabinet.operation.CabinetCellOperationApplicationService;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.command.UpdateCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import com.agileboot.domain.cabinet.operation.dto.CabinetCellOperationDTO;
import com.agileboot.domain.cabinet.operation.query.SearchCabinetCellOperationQuery;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/cabinet/cellOperations")
@RequiredArgsConstructor
@Validated
public class CabinetCellOperationController extends BaseController {
private final CabinetCellOperationApplicationService cabinetCellOperationService;
@Operation(summary = "柜机格口操作列表")
@GetMapping
public ResponseDTO<PageDTO<CabinetCellOperationDTO>> list(SearchCabinetCellOperationQuery<CabinetCellOperationEntity> query) {
PageDTO<CabinetCellOperationDTO> page = cabinetCellOperationService.getCabinetCellOperationList(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "新增柜机格口操作")
@AccessLog(title = "柜机格口操作管理", businessType = BusinessTypeEnum.ADD)
@PostMapping
public ResponseDTO<Void> add(@Validated @RequestBody AddCabinetCellOperationCommand command) {
cabinetCellOperationService.addCabinetCellOperation(command);
return ResponseDTO.ok();
}
@Operation(summary = "修改柜机格口操作")
@AccessLog(title = "柜机格口操作管理", businessType = BusinessTypeEnum.MODIFY)
@PutMapping("/{operationId}")
public ResponseDTO<Void> edit(@PathVariable Long operationId, @Validated @RequestBody UpdateCabinetCellOperationCommand command) {
command.setOperationId(operationId);
cabinetCellOperationService.updateCabinetCellOperation(command);
return ResponseDTO.ok();
}
@Operation(summary = "删除柜机格口操作")
@AccessLog(title = "柜机格口操作管理", businessType = BusinessTypeEnum.DELETE)
@DeleteMapping("/{ids}")
public ResponseDTO<Void> remove(@PathVariable @NotNull List<Long> ids) {
cabinetCellOperationService.deleteCabinetCellOperation(new BulkOperationCommand<>(ids));
return ResponseDTO.ok();
}
}

View File

@ -1,68 +0,0 @@
package com.agileboot.admin.controller.shop;
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.command.UpdatePaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import com.agileboot.domain.shop.paymentOperationLog.dto.PaymentOperationLogDTO;
import com.agileboot.domain.shop.paymentOperationLog.query.SearchPaymentOperationLogQuery;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/shop/paymentOperationLogs")
@RequiredArgsConstructor
@Validated
public class PaymentOperationLogController extends BaseController {
private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
@Operation(summary = "支付操作日志列表")
@GetMapping
public ResponseDTO<PageDTO<PaymentOperationLogDTO>> list(SearchPaymentOperationLogQuery<PaymentOperationLogEntity> query) {
PageDTO<PaymentOperationLogDTO> page = paymentOperationLogApplicationService.getPaymentOperationLogList(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "新增支付操作日志")
@AccessLog(title = "支付操作日志管理", businessType = BusinessTypeEnum.ADD)
@PostMapping
public ResponseDTO<Void> add(@Validated @RequestBody AddPaymentOperationLogCommand command) {
paymentOperationLogApplicationService.addPaymentOperationLog(command);
return ResponseDTO.ok();
}
@Operation(summary = "修改支付操作日志")
@AccessLog(title = "支付操作日志管理", businessType = BusinessTypeEnum.MODIFY)
@PutMapping("/{logId}")
public ResponseDTO<Void> edit(@PathVariable Long logId, @Validated @RequestBody UpdatePaymentOperationLogCommand command) {
command.setLogId(logId);
paymentOperationLogApplicationService.updatePaymentOperationLog(command);
return ResponseDTO.ok();
}
@Operation(summary = "删除支付操作日志")
@AccessLog(title = "支付操作日志管理", businessType = BusinessTypeEnum.DELETE)
@DeleteMapping("/{ids}")
public ResponseDTO<Void> remove(@PathVariable @NotNull List<Long> ids) {
paymentOperationLogApplicationService.deletePaymentOperationLog(new BulkOperationCommand<>(ids));
return ResponseDTO.ok();
}
}

View File

@ -1,29 +1,18 @@
package com.agileboot.admin.controller.shop;
import cn.hutool.json.JSONUtil;
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.common.utils.poi.CustomExcelUtil;
import com.agileboot.domain.shop.order.OrderApplicationService;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.dto.ShopOrderExcelDTO;
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@RestController
@RequestMapping("/shop/order")
@RequiredArgsConstructor
@ -36,19 +25,7 @@ public class ShopOrderController extends BaseController {
// @PreAuthorize("@permission.has('shop:goods:list')")
@GetMapping("/list")
public ResponseDTO<PageDTO<ShopOrderEntity>> list(SearchShopOrderQuery<ShopOrderEntity> query) {
log.info("订单列表查询参数:{}", JSONUtil.toJsonStr(query));
PageDTO<ShopOrderEntity> page = orderApplicationService.getOrderList(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "订单列表导出")
@AccessLog(title = "订单管理", businessType = BusinessTypeEnum.EXPORT)
@GetMapping("/excel")
public void exportOrderByExcel(HttpServletResponse response, SearchShopOrderQuery<ShopOrderEntity> query) {
query.setPaymentMethod("wechat");
query.setPayStatus(2);
List<ShopOrderEntity> list = orderApplicationService.list(query);
List<ShopOrderExcelDTO> excelDTOList = list.stream().map(ShopOrderExcelDTO::new).collect(Collectors.toList());
CustomExcelUtil.writeToResponse(excelDTOList, ShopOrderExcelDTO.class, response);
}
}

View File

@ -1,25 +1,16 @@
package com.agileboot.api.controller;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.cell.model.CabinetCellModel;
import com.agileboot.domain.cabinet.cell.model.CabinetCellModelFactory;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModel;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.agileboot.domain.mqtt.MqttService;
import com.agileboot.domain.shop.goods.model.GoodsModel;
import com.agileboot.domain.shop.goods.model.GoodsModelFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@Slf4j
@ -30,9 +21,6 @@ import java.util.List;
public class CabinetCellController {
private final SmartCabinetApplicationService smartCabinetApplicationService;
private final MqttService mqttService;
private final CabinetCellOperationModelFactory cabinetCellOperationModelFactory;
private final CabinetCellModelFactory cabinetCellModelFactory;
private final GoodsModelFactory goodsModelFactory;
@GetMapping("/detail")
public ResponseDTO<List<CabinetDetailDTO>> getCabinetDetail() {
@ -40,15 +28,7 @@ public class CabinetCellController {
}
@PostMapping("/openCabinet/{lockControlNo}/{pinNo}")
public ResponseDTO<?> openCabinet(@PathVariable Integer lockControlNo, @PathVariable Integer pinNo,
@RequestBody AddCabinetCellOperationCommand operationCommand) {
if (null == operationCommand){
operationCommand = new AddCabinetCellOperationCommand();
}
operationCommand.setOperationType(2);
operationCommand.setStatus(1);
CabinetCellOperationModel cellOperationModel = cabinetCellOperationModelFactory.create();
public ResponseDTO<?> openCabinet(@PathVariable Integer lockControlNo, @PathVariable Integer pinNo) {
// 发送指令
String mqttDate = "8A";
mqttDate += String.format("%02X", lockControlNo);
@ -58,28 +38,7 @@ public class CabinetCellController {
mqttService.publish(mqttDate);
} catch (Exception e) {
log.error("mqtt publish error", e);
operationCommand.setStatus(2);
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "发送指令失败");
} finally {
// 记录操作日志
operationCommand.initBaseEntity();
if (operationCommand.getCellId() == null) {
log.error("openCabinet 格口ID为空");
} else {
CabinetCellModel cabinetCellModel = cabinetCellModelFactory.loadById(operationCommand.getCellId());
operationCommand.setGoodsId(cabinetCellModel.getGoodsId());
operationCommand.setGoodsName("");
if (cabinetCellModel.getGoodsId() != null) {
GoodsModel goodsModel = goodsModelFactory.loadById(cabinetCellModel.getGoodsId());
operationCommand.setGoodsName(goodsModel.getGoodsName());
}
log.info("openCabinet lockControlNo: {}, pinNo: {}, operationCommand: {}", lockControlNo, pinNo, JSONUtil.toJsonStr(operationCommand));
cellOperationModel.loadAddCommand(operationCommand);
cellOperationModel.insert();
}
}
return ResponseDTO.ok();
}

View File

@ -1,9 +1,7 @@
package com.agileboot.api.controller;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
import com.agileboot.domain.shop.order.model.OrderGoodsModelFactory;
@ -52,10 +50,8 @@ public class OrderController extends BaseController {
* @return 空响应
*/
@PostMapping("/openCabinet/{orderId}/{orderGoodsId}")
public ResponseDTO<?> openCabinet(@PathVariable Long orderId, @PathVariable Long orderGoodsId,
@RequestBody AddCabinetCellOperationCommand operationCommand) {
// log.info("openCabinet orderId: {}, orderGoodsId: {}, operationCommand: {}", orderId, orderGoodsId, JSONUtil.toJsonStr(operationCommand));
orderApplicationService.openOrderGoodsCabinet(orderId, orderGoodsId, operationCommand);
public ResponseDTO<?> openCabinet(@PathVariable Long orderId, @PathVariable Long orderGoodsId) {
orderApplicationService.openOrderGoodsCabinet(orderId, orderGoodsId);
return ResponseDTO.ok();
}

View File

@ -179,9 +179,7 @@ public class PaymentController {
OpenidResponse openidResponse = QywxApiUtil.convertToOpenid(qyAccessToken.getAccessToken(), userid);
QyUserEntity qyUserEntity = qyUserApplicationService.getUserByUserId(userid, corpid);
return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, qyUserEntity.getName()));
return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin));
} catch (RestClientException e) {
log.error("qyLogin失败", e);
return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "微信服务调用失败"));

View File

@ -43,11 +43,4 @@ public class BaseEntity<T extends Model<?>> extends Model<T> {
@TableLogic
private Boolean deleted;
public void initBaseEntity() {
this.creatorId = 0L;
this.createTime = new Date();
this.updaterId = 0L;
this.updateTime = new Date();
this.deleted = false;
}
}

View File

@ -1,57 +0,0 @@
package com.agileboot.domain.cabinet.operation;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.command.UpdateCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationService;
import com.agileboot.domain.cabinet.operation.dto.CabinetCellOperationDTO;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModel;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModelFactory;
import com.agileboot.domain.cabinet.operation.query.SearchCabinetCellOperationQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
@RequiredArgsConstructor
public class CabinetCellOperationApplicationService {
private final CabinetCellOperationService cabinetCellOperationService;
private final CabinetCellOperationModelFactory cabinetCellOperationModelFactory;
public PageDTO<CabinetCellOperationDTO> getCabinetCellOperationList(SearchCabinetCellOperationQuery<CabinetCellOperationEntity> query) {
Page<CabinetCellOperationEntity> page = cabinetCellOperationService.getOperationList(query);
List<CabinetCellOperationDTO> dtoList = page.getRecords().stream()
.map(CabinetCellOperationDTO::new)
.collect(Collectors.toList());
return new PageDTO<>(dtoList, page.getTotal());
}
public void addCabinetCellOperation(AddCabinetCellOperationCommand command) {
CabinetCellOperationModel model = cabinetCellOperationModelFactory.create();
model.loadAddCommand(command);
model.insert();
}
public void updateCabinetCellOperation(UpdateCabinetCellOperationCommand command) {
CabinetCellOperationModel model = cabinetCellOperationModelFactory.loadById(command.getOperationId());
model.loadUpdateCommand(command);
model.updateById();
}
public void deleteCabinetCellOperation(BulkOperationCommand<Long> command) {
for (Long id : command.getIds()) {
CabinetCellOperationModel model = cabinetCellOperationModelFactory.loadById(id);
model.deleteById();
}
}
public CabinetCellOperationEntity getByOperationId(Long operationId) {
return cabinetCellOperationService.getById(operationId);
}
}

View File

@ -1,11 +0,0 @@
package com.agileboot.domain.cabinet.operation.command;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class AddCabinetCellOperationCommand extends CabinetCellOperationEntity {
}

View File

@ -1,16 +0,0 @@
package com.agileboot.domain.cabinet.operation.command;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UpdateCabinetCellOperationCommand extends AddCabinetCellOperationCommand {
@NotNull
@PositiveOrZero
private Long operationId;
}

View File

@ -1,76 +0,0 @@
package com.agileboot.domain.cabinet.operation.db;
import com.agileboot.common.core.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 柜机格口操作记录表
* </p>
*
* @author valarchie
* @since 2025-04-21
*/
@Getter
@Setter
@TableName("cabinet_cell_operation")
@ApiModel(value = "CabinetCellOperationEntity对象", description = "柜机格口操作记录表")
public class CabinetCellOperationEntity extends BaseEntity<CabinetCellOperationEntity> {
private static final long serialVersionUID = 1L;
@ApiModelProperty("操作流水号")
@TableId(value = "operation_id", type = IdType.AUTO)
private Long operationId;
@ApiModelProperty("关联格口ID")
@TableField("cell_id")
private Long cellId;
@ApiModelProperty("关联商品ID")
@TableField("goods_id")
private Long goodsId;
@ApiModelProperty("商品名称")
@TableField("goods_name")
private String goodsName;
@ApiModelProperty("企业微信用户ID")
@TableField("userid")
private String userid;
@ApiModelProperty("是否内部用户0否 1是")
@TableField("is_internal")
private Integer isInternal;
@ApiModelProperty("成员名称")
@TableField("`name`")
private String name;
@ApiModelProperty("手机号码")
@TableField("mobile")
private String mobile;
@ApiModelProperty("操作类型1用户 2管理员")
@TableField("operation_type")
private Integer operationType;
@ApiModelProperty("操作状态1正常 2操作失败")
@TableField("`status`")
private Integer status;
@Override
public Serializable pkVal() {
return this.operationId;
}
}

View File

@ -1,43 +0,0 @@
package com.agileboot.domain.cabinet.operation.db;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 柜机格口操作记录表 Mapper 接口
* </p>
*
* @author valarchie
* @since 2025-04-21
*/
public interface CabinetCellOperationMapper extends BaseMapper<CabinetCellOperationEntity> {
@Select("SELECT * " +
"FROM cabinet_cell_operation " +
"${ew.customSqlSegment}")
Page<CabinetCellOperationEntity> getOperationList(
Page<CabinetCellOperationEntity> page,
@Param(Constants.WRAPPER) Wrapper<CabinetCellOperationEntity> queryWrapper
);
@Select("SELECT * " +
"FROM cabinet_cell_operation " +
"WHERE status = '1' " +
"ORDER BY operation_id DESC " +
"LIMIT 1")
CabinetCellOperationEntity selectFirstEnabledOperation();
@Select("SELECT * " +
"FROM cabinet_cell_operation " +
"WHERE status = '1' " +
"ORDER BY operation_id DESC")
List<CabinetCellOperationEntity> selectAll();
@Select("SELECT * FROM cabinet_cell_operation WHERE cell_id = #{cellId} LIMIT 1")
CabinetCellOperationEntity selectByCellId(@Param("cellId") Long cellId);
}

View File

@ -1,18 +0,0 @@
package com.agileboot.domain.cabinet.operation.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 柜机格口操作记录表 服务类
* </p>
*
* @author valarchie
* @since 2025-04-21
*/
public interface CabinetCellOperationService extends IService<CabinetCellOperationEntity> {
Page<CabinetCellOperationEntity> getOperationList(AbstractPageQuery<CabinetCellOperationEntity> query);
}

View File

@ -1,24 +0,0 @@
package com.agileboot.domain.cabinet.operation.db;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* <p>
* 柜机格口操作记录表 服务实现类
* </p>
*
* @author valarchie
* @since 2025-04-21
*/
@Service
public class CabinetCellOperationServiceImpl extends ServiceImpl<CabinetCellOperationMapper, CabinetCellOperationEntity> implements CabinetCellOperationService {
@Override
public Page<CabinetCellOperationEntity> getOperationList(AbstractPageQuery<CabinetCellOperationEntity> query) {
return this.page(query.toPage(), query.toQueryWrapper());
}
}

View File

@ -1,76 +0,0 @@
package com.agileboot.domain.cabinet.operation.dto;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.agileboot.common.annotation.ExcelColumn;
import com.agileboot.common.annotation.ExcelSheet;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import lombok.Data;
@ExcelSheet(name = "柜机格口操作记录列表")
@Data
public class CabinetCellOperationDTO {
public CabinetCellOperationDTO(CabinetCellOperationEntity entity) {
if (entity != null) {
BeanUtil.copyProperties(entity, this);
this.statusDesc = convertStatus(entity.getStatus());
this.createTimeStr = DateUtil.format(entity.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
}
}
private String convertStatus(Integer status) {
if (status == null) return "未知状态";
switch(status) {
case 1: return "正常";
case 2: return "操作失败";
default: return "未知状态";
}
}
@ExcelColumn(name = "操作流水号")
private Long operationId;
@ExcelColumn(name = "关联格口ID")
private Long cellId;
@ExcelColumn(name = "关联商品ID")
private Long goodsId;
@ExcelColumn(name = "商品名称")
private String goodsName;
@ExcelColumn(name = "企业微信用户ID")
private String userid;
@ExcelColumn(name = "是否内部用户")
private Boolean isInternal;
@ExcelColumn(name = "成员名称")
private String name;
@ExcelColumn(name = "手机号码")
private String mobile;
@ExcelColumn(name = "操作类型")
private Integer operationType;
@ExcelColumn(name = "操作状态")
private Integer status;
@ExcelColumn(name = "操作状态")
private String statusDesc;
@ExcelColumn(name = "操作人")
private String operator;
@ExcelColumn(name = "创建时间")
private Date createTime;
@ExcelColumn(name = "创建时间")
private String createTimeStr;
}

View File

@ -1,39 +0,0 @@
package com.agileboot.domain.cabinet.operation.model;
import cn.hutool.core.bean.BeanUtil;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.command.UpdateCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationService;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class CabinetCellOperationModel extends CabinetCellOperationEntity {
private CabinetCellOperationService cabinetCellOperationService;
public CabinetCellOperationModel(CabinetCellOperationEntity entity, CabinetCellOperationService cabinetCellOperationService) {
this(cabinetCellOperationService);
if (entity != null) {
BeanUtil.copyProperties(entity, this);
}
}
public CabinetCellOperationModel(CabinetCellOperationService cabinetCellOperationService) {
this.cabinetCellOperationService = cabinetCellOperationService;
}
public void loadAddCommand(AddCabinetCellOperationCommand command) {
if (command != null) {
BeanUtil.copyProperties(command, this, "id");
}
}
public void loadUpdateCommand(UpdateCabinetCellOperationCommand command) {
if (command != null) {
loadAddCommand(command);
}
}
}

View File

@ -1,27 +0,0 @@
package com.agileboot.domain.cabinet.operation.model;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationEntity;
import com.agileboot.domain.cabinet.operation.db.CabinetCellOperationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class CabinetCellOperationModelFactory {
private final CabinetCellOperationService cabinetCellOperationService;
public CabinetCellOperationModel loadById(Long operationId) {
CabinetCellOperationEntity entity = cabinetCellOperationService.getById(operationId);
if (entity == null) {
throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, operationId, "柜机操作记录");
}
return new CabinetCellOperationModel(entity, cabinetCellOperationService);
}
public CabinetCellOperationModel create() {
return new CabinetCellOperationModel(cabinetCellOperationService);
}
}

View File

@ -1,49 +0,0 @@
package com.agileboot.domain.cabinet.operation.query;
import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchCabinetCellOperationQuery<T> extends AbstractPageQuery<T> {
private Long operationId;
private Long cellId;
private Long goodsId;
private String userid;
private String goodsName;
private Boolean isInternal;
private String name;
private String mobile;
private Integer operationType;
private Integer status;
private Date startTime;
private Date endTime;
@Override
public QueryWrapper<T> addQueryCondition() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper
.eq(operationId != null, "operation_id", operationId)
.eq(cellId != null, "cell_id", cellId)
.eq(goodsId != null, "goods_id", goodsId)
.eq(StrUtil.isNotEmpty(userid), "userid", userid)
.like(StrUtil.isNotEmpty(goodsName), "goods_name", goodsName)
.eq(isInternal != null, "is_internal", isInternal)
.like(StrUtil.isNotEmpty(name), "name", name)
.like(StrUtil.isNotEmpty(mobile), "mobile", mobile)
.eq(operationType != null, "operation_type", operationType)
.eq(status != null, "status", status)
.between(startTime != null && endTime != null, "create_time", startTime, endTime)
.orderByDesc("create_time");
this.timeRangeColumn = "create_time";
return queryWrapper;
}
}

View File

@ -10,5 +10,4 @@ public class QyLoginDTO {
private String userid;
private String openid;
private Integer isCabinetAdmin;
private String name;
}

View File

@ -59,7 +59,6 @@ public class MqttService implements MqttCallback {
}
public void publish(String data) throws MqttException {
// lockCmd((byte) 0x8A, (byte) 0x01, (byte) 0x01, (byte) 0x33, null);
String bcc = BCCCalculator.calculateBCC(data);
MqttMessage message = new MqttMessage(BCCCalculator.hexStringToByteArray(data + bcc));
client.publish(TOPIC, message);
@ -84,45 +83,4 @@ public class MqttService implements MqttCallback {
@Override
public void deliveryComplete(IMqttDeliveryToken token) {}
/******************************************************
*函数名称: lockCmd
* : 指令地址码通道号指令参数
* : 是否发送成功rsMsg反馈消息
* : 通过串口发送指定的指令并解析返回数据
指令0x7A控制A型电机指令
指令0x7B控制B型电机指令
指令0x7C开锁cmdSub指定开锁次数
指令0x7E设置开锁超时时间 cmdSub时间单位秒
指令0x7F开锁cmdSub设置限位状态只有 00或11两种值有效
指令0x80读锁状态指令
指令0x8A开锁指令
指令0x8D设置关门是否自动上传状态cmdSub0关闭1开启
指令0x9A常开指令
指令0x9B关闭指令
指令0x9D一键全开指令
指令0x9E读取所有锁状态
指令中未标注cmdSub指令参数的固定为0x33
*******************************************************/
private boolean lockCmd(byte cmdNo, byte boardNo, byte lockNo, byte cmdSub, String[] rsMsg)
{
try
{
byte[] sendData= new byte[5];
sendData[0]= cmdNo;
sendData[1]= boardNo;
sendData[2]= lockNo;
sendData[3]= cmdSub;
sendData[4]= (byte) (sendData[0] ^ sendData[1] ^ sendData[2] ^sendData[3]);
//发送数据并获取返回值
MqttMessage message = new MqttMessage(sendData);
client.publish(TOPIC, message);
} catch(Exception e) {
log.error("lockCmd", e);
}
return false;
}
}

View File

@ -65,7 +65,6 @@ public class ReturnApprovalApplicationService {
private final AccessTokenApplicationService accessTokenApplicationService;
private final QyUserService qyUserService;
private final CabinetCellModelFactory cabinetCellModelFactory;
private final QyUserService userService;
/**
* 获取退货审批列表
@ -142,8 +141,7 @@ public class ReturnApprovalApplicationService {
throw new IllegalArgumentException("退款金额不能超过订单总额");
}
if (Objects.equals(orderModel.getPaymentMethod(), "wechat")) {
// 微信退款
if (!Objects.equals(orderModel.getPaymentMethod(), "balance")) {
RefundVO refundVO = null;
try {
refundVO = paymentApplicationService.refund(
@ -157,19 +155,6 @@ public class ReturnApprovalApplicationService {
if (null == refundVO || !refundVO.getSuccess()) {
throw new RuntimeException("退款失败");
}
} else if (Objects.equals(orderModel.getPaymentMethod(), "balance")) {
// 余额退款
try {
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid("QWTONG_YS_WXSHOP", WeixinConstants.corpid);
String userid = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), orderModel.getOpenid()).getUserid();
QyUserEntity qyUser = userService.getUserByUserId(userid, WeixinConstants.corpid);
if (null != qyUser) {
qyUser.setBalance(qyUser.getBalance().add(command.getReturnAmount()));
}
userService.updateById(qyUser);
} catch (Exception e) {
log.error("余额退款失败", e);
}
}
// 审批人信息

View File

@ -1,16 +1,12 @@
package com.agileboot.domain.shop.order;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModel;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetEntity;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetService;
import com.agileboot.domain.common.command.BulkOperationCommand;
@ -68,18 +64,13 @@ public class OrderApplicationService {
private final MqttService mqttService;
private final QyUserService userService;
private final QyUserModelFactory qyUserModelFactory;
private final CabinetCellOperationModelFactory cabinetCellOperationModelFactory;
public PageDTO<ShopOrderEntity> getOrderList(SearchShopOrderQuery<ShopOrderEntity> query) {
Page<ShopOrderEntity> page = orderService.page(query.toPage(), query.toQueryWrapper());
return new PageDTO<>(page.getRecords(), page.getTotal());
}
public List<ShopOrderEntity> list(SearchShopOrderQuery<ShopOrderEntity> query) {
return orderService.list(query.toQueryWrapper());
}
public void openOrderGoodsCabinet(Long orderId, Long orderGoodsId, AddCabinetCellOperationCommand operationCommand) {
public void openOrderGoodsCabinet(Long orderId, Long orderGoodsId) {
OrderModel orderModel = orderModelFactory.loadById(orderId);
// 验证订单状态
if (orderModel.getStatus() != 2) {
@ -105,12 +96,6 @@ public class OrderApplicationService {
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "柜子不存在");
}
operationCommand.setCellId(goodsEntity.getCellId());
operationCommand.setGoodsId(goodsEntity.getGoodsId());
operationCommand.setGoodsName(goodsEntity.getGoodsName());
operationCommand.setStatus(1);
CabinetCellOperationModel cellOperationModel = cabinetCellOperationModelFactory.create();
// 构造MQTT开柜指令
// 指令格式8A + 锁控编号(2位HEX) + 引脚号(2位HEX) + 操作码11
String mqttDate = "8A";
@ -121,17 +106,7 @@ public class OrderApplicationService {
mqttService.publish(mqttDate);
} catch (Exception e) {
log.error("mqtt publish error", e);
operationCommand.setStatus(2);
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "发送指令失败");
} finally {
// 记录操作日志
operationCommand.setCreatorId(0L);
operationCommand.setCreateTime(new Date());
operationCommand.setUpdaterId(0L);
operationCommand.setUpdateTime(new Date());
operationCommand.setDeleted(false);
cellOperationModel.loadAddCommand(operationCommand);
cellOperationModel.insert();
}
}
@ -155,7 +130,6 @@ public class OrderApplicationService {
orderModel.setIsInternal(command.getIsInternal());
orderModel.setUserid(command.getQyUserid());
orderModel.setName(command.getName());
orderModel.setIsDeductStock(0);
orderModel.insert();
processOrderGoods(orderModel, goodsList);
@ -222,17 +196,12 @@ public class OrderApplicationService {
// 计算商品金额并验证库存
goodsModel.calculateTotal();
goodsModel.validateQuantity();
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(goodsModel.getCellId());
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < goodsModel.getQuantity()) {
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
}
// 保存订单商品
goodsModel.insert();
// 扣减库存
// 改为收到支付成功后扣减库存
// deductGoodsStock(goodsModel.getGoodsId(), goodsModel.getQuantity(), goodsModel.getCellId());
deductGoodsStock(goodsModel.getGoodsId(), goodsModel.getQuantity(), goodsModel.getCellId());
totalAmount = totalAmount.add(goodsModel.getTotalAmount());
}
@ -243,6 +212,24 @@ public class OrderApplicationService {
orderModel.updateById();
}
private void deductGoodsStock(Long goodsId, Integer quantity, Long cellId) {
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(cellId);
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < quantity) {
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
}
ShopGoodsEntity goods = goodsService.getById(goodsId);
if (goods == null || goods.getStock() < quantity) {
throw new ApiException(ErrorCode.FAILED, "商品库存不足");
}
// 扣减库存
cabinetCellEntity.setStock(cabinetCellEntity.getStock() - quantity);
cabinetCellService.updateById(cabinetCellEntity);
goods.setStock(goods.getStock() - quantity);
goodsService.updateById(goods);
}
@Transactional
public void cancelOrder(Long orderId) {
OrderModel orderModel = orderModelFactory.loadById(orderId);

View File

@ -77,10 +77,6 @@ public class ShopOrderEntity extends BaseEntity<ShopOrderEntity> {
@TableField("pay_status")
private Integer payStatus;
@ApiModelProperty("已扣减库存0否 1是")
@TableField("is_deduct_stock")
private Integer isDeductStock;
@ApiModelProperty("支付方式")
@TableField("payment_method")
private String paymentMethod;

View File

@ -5,8 +5,6 @@ import org.apache.ibatis.annotations.Select;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* 订单商品明细表 Mapper 接口
@ -20,6 +18,4 @@ public interface ShopOrderGoodsMapper extends BaseMapper<ShopOrderGoodsEntity> {
@Select("SELECT * FROM shop_order_goods WHERE order_id = #{orderId} AND goods_id = #{goodsId} LIMIT 1")
ShopOrderGoodsEntity selectByOrderIdAndGoodsId(@Param("orderId") Long orderId, @Param("goodsId") Long goodsId);
@Select("SELECT * FROM shop_order_goods WHERE order_id = #{orderId} AND deleted = 0")
List<ShopOrderGoodsEntity> selectByOrderId(@Param("orderId") Long orderId);
}

View File

@ -2,8 +2,6 @@ package com.agileboot.domain.shop.order.db;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 订单商品明细表 服务类
@ -14,6 +12,4 @@ import java.util.List;
*/
public interface ShopOrderGoodsService extends IService<ShopOrderGoodsEntity> {
ShopOrderGoodsEntity getByOrderIdAndGoodsId(Long orderId, Long goodsId);
List<ShopOrderGoodsEntity> selectByOrderId(Long orderId);
}

View File

@ -3,8 +3,6 @@ package com.agileboot.domain.shop.order.db;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 订单商品明细表 服务实现类
@ -21,9 +19,4 @@ public class ShopOrderGoodsServiceImpl extends ServiceImpl<ShopOrderGoodsMapper,
return baseMapper.selectByOrderIdAndGoodsId(orderId, goodsId);
}
@Override
public List<ShopOrderGoodsEntity> selectByOrderId(Long orderId) {
return baseMapper.selectByOrderId(orderId);
}
}

View File

@ -41,8 +41,6 @@ public class ShopOrderDTO {
private Integer status;
@ApiModelProperty("支付状态1未支付 2已支付 3退款中 4已退款")
private Integer payStatus;
@ApiModelProperty("已扣减库存0否 1是")
private Integer isDeductStock;
@ApiModelProperty("支付方式")
private String paymentMethod;
@ApiModelProperty("支付时间")

View File

@ -1,50 +0,0 @@
package com.agileboot.domain.shop.order.dto;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.agileboot.common.annotation.ExcelColumn;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class ShopOrderExcelDTO {
public ShopOrderExcelDTO(ShopOrderEntity entity) {
if (entity != null) {
BeanUtil.copyProperties(entity, this);
this.payTimeStr = entity.getPayTime() != null ? DateUtil.format(entity.getPayTime(), "yyyy-MM-dd HH:mm:ss"): "";
this.createTimeStr = entity.getCreateTime()!= null? DateUtil.format(entity.getCreateTime(), "yyyy-MM-dd HH:mm:ss"): "";
switch (entity.getPayStatus()) {
case 1:
this.payStatusStr = "未支付";
break;
case 2:
this.payStatusStr = "已支付";
break;
case 3:
this.payStatusStr = "退款中";
break;
case 4:
this.payStatusStr = "已退款";
break;
default:
this.payStatusStr = "";
break;
}
}
}
@ExcelColumn(name = "订单ID")
private Long orderId;
@ExcelColumn(name = "订单金额(元)")
private BigDecimal totalAmount;
@ExcelColumn(name = "支付状态")
private String payStatusStr;
@ExcelColumn(name = "支付时间")
private String payTimeStr;
@ExcelColumn(name = "创建时间")
private String createTimeStr;
}

View File

@ -5,10 +5,6 @@ import cn.hutool.core.date.DateUtil;
import com.agileboot.common.config.AgileBootConfig;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
import com.agileboot.domain.shop.goods.db.ShopGoodsEntity;
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderService;
@ -25,23 +21,18 @@ public class OrderModel extends ShopOrderEntity {
private ShopOrderService orderService;
private ShopOrderGoodsService orderGoodsService;
private CabinetCellService cabinetCellService;
private ShopGoodsService goodsService;
public OrderModel(ShopOrderEntity entity, ShopOrderService orderService,
ShopOrderGoodsService orderGoodsService, CabinetCellService cabinetCellService, ShopGoodsService goodsService) {
this(orderService, orderGoodsService, cabinetCellService, goodsService);
ShopOrderGoodsService orderGoodsService) {
this(orderService, orderGoodsService);
if (entity != null) {
BeanUtil.copyProperties(entity, this);
}
}
public OrderModel(ShopOrderService orderService, ShopOrderGoodsService orderGoodsService,
CabinetCellService cabinetCellService, ShopGoodsService goodsService) {
public OrderModel(ShopOrderService orderService, ShopOrderGoodsService orderGoodsService) {
this.orderService = orderService;
this.orderGoodsService = orderGoodsService;
this.cabinetCellService = cabinetCellService;
this.goodsService = goodsService;
}
public void calculateTotalAmount(List<Long> goodsIds) {
@ -93,16 +84,7 @@ public class OrderModel extends ShopOrderEntity {
} catch (Exception e) {
log.error("支付时间转换失败", e);
}
boolean isDeductStock = this.getIsDeductStock().equals(1);
this.setIsDeductStock(1);
this.updateById();
if (!isDeductStock) {
orderGoodsService.selectByOrderId(this.getOrderId()).forEach(orderGoods -> {
// 扣减库存
deductGoodsStock(orderGoods.getGoodsId(), orderGoods.getQuantity(), orderGoods.getCellId());
});
}
}
public void handleRefundSuccess() {
@ -110,22 +92,4 @@ public class OrderModel extends ShopOrderEntity {
this.setPayStatus(4);
this.updateById();
}
private void deductGoodsStock(Long goodsId, Integer quantity, Long cellId) {
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(cellId);
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < quantity) {
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
}
ShopGoodsEntity goods = goodsService.getById(goodsId);
if (goods == null || goods.getStock() < quantity) {
throw new ApiException(ErrorCode.FAILED, "商品库存不足");
}
// 扣减库存
cabinetCellEntity.setStock(cabinetCellEntity.getStock() - quantity);
cabinetCellService.updateById(cabinetCellEntity);
goods.setStock(goods.getStock() - quantity);
goodsService.updateById(goods);
}
}

View File

@ -2,8 +2,6 @@ package com.agileboot.domain.shop.order.model;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderService;
@ -16,15 +14,13 @@ public class OrderModelFactory {
private final ShopOrderService orderService;
private final ShopOrderGoodsService orderGoodsService;
private final CabinetCellService cabinetCellService;
private final ShopGoodsService goodsService;
public OrderModel create(ShopOrderEntity entity) {
return new OrderModel(entity, orderService, orderGoodsService, cabinetCellService, goodsService);
return new OrderModel(entity, orderService, orderGoodsService);
}
public OrderModel create() {
return new OrderModel(orderService, orderGoodsService, cabinetCellService, goodsService);
return new OrderModel(orderService, orderGoodsService);
}
public OrderModel loadById(Long orderId) {
@ -32,6 +28,6 @@ public class OrderModelFactory {
if (entity == null) {
throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, orderId, "订单");
}
return new OrderModel(entity, orderService, orderGoodsService, cabinetCellService, goodsService);
return new OrderModel(entity, orderService, orderGoodsService);
}
}

View File

@ -1,6 +1,5 @@
package com.agileboot.domain.shop.order.query;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -17,8 +16,6 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
private Integer payStatus;
private Date startTime;
private Date endTime;
private Date payTime;
private String paymentMethod;
@Override
public QueryWrapper<T> addQueryCondition() {
@ -28,11 +25,7 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
.like(StrUtil.isNotEmpty(orderNumber), "order_number", orderNumber)
.eq(status != null, "status", status)
.eq(payStatus != null, "pay_status", payStatus)
.eq(StrUtil.isNotEmpty(paymentMethod), "payment_method", paymentMethod)
.between(startTime != null && endTime != null, "create_time", startTime, endTime)
.between(payTime != null, "pay_time",
payTime == null ? null : DateUtil.beginOfDay(payTime).toJdkDate(),
payTime == null ? null : DateUtil.endOfDay(payTime).toJdkDate())
.eq("deleted", 0)
.orderByDesc("create_time");

View File

@ -1,57 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.command.UpdatePaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogService;
import com.agileboot.domain.shop.paymentOperationLog.dto.PaymentOperationLogDTO;
import com.agileboot.domain.shop.paymentOperationLog.model.PaymentOperationLogModel;
import com.agileboot.domain.shop.paymentOperationLog.model.PaymentOperationLogModelFactory;
import com.agileboot.domain.shop.paymentOperationLog.query.SearchPaymentOperationLogQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
public class PaymentOperationLogApplicationService {
private final PaymentOperationLogService paymentOperationLogService;
private final PaymentOperationLogModelFactory paymentOperationLogModelFactory;
public PageDTO<PaymentOperationLogDTO> getPaymentOperationLogList(SearchPaymentOperationLogQuery<PaymentOperationLogEntity> query) {
Page<PaymentOperationLogEntity> page = paymentOperationLogService.getPaymentLogList(query);
List<PaymentOperationLogDTO> dtoList = page.getRecords().stream()
.map(PaymentOperationLogDTO::new)
.collect(Collectors.toList());
return new PageDTO<>(dtoList, page.getTotal());
}
public void addPaymentOperationLog(AddPaymentOperationLogCommand command) {
PaymentOperationLogModel model = paymentOperationLogModelFactory.create();
model.loadAddCommand(command);
model.insert();
}
public void updatePaymentOperationLog(UpdatePaymentOperationLogCommand command) {
PaymentOperationLogModel model = paymentOperationLogModelFactory.loadById(command.getLogId());
model.loadUpdateCommand(command);
model.updateById();
}
public void deletePaymentOperationLog(BulkOperationCommand<Long> command) {
for (Long logId : command.getIds()) {
PaymentOperationLogModel model = paymentOperationLogModelFactory.loadById(logId);
model.deleteById();
}
}
public PaymentOperationLogEntity selectLatestByOrderId(Long orderId) {
return paymentOperationLogService.selectLatestByOrderId(orderId);
}
}

View File

@ -1,11 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.command;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class AddPaymentOperationLogCommand extends PaymentOperationLogEntity {
}

View File

@ -1,16 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.command;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UpdatePaymentOperationLogCommand extends AddPaymentOperationLogCommand {
@NotNull
@PositiveOrZero
private Long logId;
}

View File

@ -1,52 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.db;
import com.agileboot.common.core.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 支付操作日志表
* </p>
*
* @author valarchie
* @since 2025-04-25
*/
@Getter
@Setter
@TableName("payment_operation_log")
@ApiModel(value = "PaymentOperationLogEntity对象", description = "支付操作日志表")
public class PaymentOperationLogEntity extends BaseEntity<PaymentOperationLogEntity> {
private static final long serialVersionUID = 1L;
@ApiModelProperty("日志ID")
@TableId(value = "log_id", type = IdType.AUTO)
private Long logId;
@ApiModelProperty("订单ID关联shop_order.order_id")
@TableField("order_id")
private Long orderId;
@ApiModelProperty("操作状态1成功 2失败")
@TableField("`status`")
private Integer status;
@ApiModelProperty("操作备注")
@TableField("remark")
private String remark;
@Override
public Serializable pkVal() {
return this.logId;
}
}

View File

@ -1,40 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.db;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 支付操作日志表 Mapper 接口
* </p>
*
* @author valarchie
* @since 2025-04-25
*/
public interface PaymentOperationLogMapper extends BaseMapper<PaymentOperationLogEntity> {
@Select("SELECT * " +
"FROM payment_operation_log " +
"${ew.customSqlSegment}")
Page<PaymentOperationLogEntity> getPaymentLogList(
Page<PaymentOperationLogEntity> page,
@Param(Constants.WRAPPER) Wrapper<PaymentOperationLogEntity> queryWrapper
);
@Select("SELECT * FROM payment_operation_log WHERE order_id = #{orderId} ORDER BY create_time DESC LIMIT 1")
PaymentOperationLogEntity selectLatestByOrderId(Long orderId);
@Select("SELECT * FROM payment_operation_log WHERE status = #{status} ORDER BY create_time DESC")
List<PaymentOperationLogEntity> selectByStatus(Integer status);
@Select("SELECT * FROM payment_operation_log WHERE order_id = #{orderId} AND status = #{status}")
PaymentOperationLogEntity selectByOrderAndStatus(
@Param("orderId") Long orderId,
@Param("status") Integer status
);
}

View File

@ -1,26 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 支付操作日志表 服务类
* </p>
*
* @author valarchie
* @since 2025-04-25
*/
public interface PaymentOperationLogService extends IService<PaymentOperationLogEntity> {
Page<PaymentOperationLogEntity> getPaymentLogList(AbstractPageQuery<PaymentOperationLogEntity> query);
List<PaymentOperationLogEntity> selectAll();
PaymentOperationLogEntity selectLatestByOrderId(Long orderId);
PaymentOperationLogEntity selectByOrderAndStatus(Long orderId, Integer status);
}

View File

@ -1,40 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 支付操作日志表 服务实现类
* </p>
*
* @author valarchie
* @since 2025-04-25
*/
@Service
public class PaymentOperationLogServiceImpl extends ServiceImpl<PaymentOperationLogMapper, PaymentOperationLogEntity> implements PaymentOperationLogService {
@Override
public Page<PaymentOperationLogEntity> getPaymentLogList(AbstractPageQuery<PaymentOperationLogEntity> query) {
return this.page(query.toPage(), query.toQueryWrapper());
}
@Override
public List<PaymentOperationLogEntity> selectAll() {
return this.list();
}
@Override
public PaymentOperationLogEntity selectLatestByOrderId(Long orderId) {
return baseMapper.selectLatestByOrderId(orderId);
}
@Override
public PaymentOperationLogEntity selectByOrderAndStatus(Long orderId, Integer status) {
return baseMapper.selectByOrderAndStatus(orderId, status);
}
}

View File

@ -1,37 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.dto;
import cn.hutool.core.bean.BeanUtil;
import com.agileboot.common.annotation.ExcelColumn;
import com.agileboot.common.annotation.ExcelSheet;
import com.agileboot.domain.common.cache.CacheCenter;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import com.agileboot.domain.system.user.db.SysUserEntity;
import lombok.Data;
@ExcelSheet(name = "支付操作日志列表")
@Data
public class PaymentOperationLogDTO {
public PaymentOperationLogDTO(PaymentOperationLogEntity entity) {
if (entity != null) {
BeanUtil.copyProperties(entity, this);
this.statusStr = entity.getStatus() == 1 ? "成功" : "失败";
}
}
@ExcelColumn(name = "日志ID")
private Long logId;
@ExcelColumn(name = "订单ID")
private Long orderId;
@ExcelColumn(name = "操作状态")
private String statusStr;
@ExcelColumn(name = "操作备注")
private String remark;
@ExcelColumn(name = "操作人")
private String operatorName;
}

View File

@ -1,39 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.model;
import cn.hutool.core.bean.BeanUtil;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.command.UpdatePaymentOperationLogCommand;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogService;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class PaymentOperationLogModel extends PaymentOperationLogEntity {
private PaymentOperationLogService paymentOperationLogService;
public PaymentOperationLogModel(PaymentOperationLogEntity entity, PaymentOperationLogService paymentOperationLogService) {
this(paymentOperationLogService);
if (entity != null) {
BeanUtil.copyProperties(entity, this);
}
}
public PaymentOperationLogModel(PaymentOperationLogService paymentOperationLogService) {
this.paymentOperationLogService = paymentOperationLogService;
}
public void loadAddCommand(AddPaymentOperationLogCommand command) {
if (command != null) {
BeanUtil.copyProperties(command, this, "logId");
}
}
public void loadUpdateCommand(UpdatePaymentOperationLogCommand command) {
if (command != null) {
loadAddCommand(command);
}
}
}

View File

@ -1,27 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.model;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogEntity;
import com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class PaymentOperationLogModelFactory {
private final PaymentOperationLogService paymentOperationLogService;
public PaymentOperationLogModel loadById(Long logId) {
PaymentOperationLogEntity entity = paymentOperationLogService.getById(logId);
if (entity == null) {
throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, logId, "支付操作日志");
}
return new PaymentOperationLogModel(entity, paymentOperationLogService);
}
public PaymentOperationLogModel create() {
return new PaymentOperationLogModel(paymentOperationLogService);
}
}

View File

@ -1,34 +0,0 @@
package com.agileboot.domain.shop.paymentOperationLog.query;
import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchPaymentOperationLogQuery<T> extends AbstractPageQuery<T> {
private Long orderId;
private Integer status;
private String remark;
private Date startTime;
private Date endTime;
@Override
public QueryWrapper<T> addQueryCondition() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper
.eq(orderId != null, "order_id", orderId)
.eq(status != null, "`status`", status)
.like(StrUtil.isNotEmpty(remark), "remark", remark)
.between(startTime != null && endTime != null, "create_time", startTime, endTime);
this.timeRangeColumn = "create_time";
return queryWrapper;
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.agileboot.domain.cabinet.operation.db.CabinetCellOperationMapper">
</mapper>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.agileboot.domain.shop.paymentOperationLog.db.PaymentOperationLogMapper">
</mapper>

View File

@ -27,8 +27,8 @@ public class MethodLogAspect {
@Around("dbService()")
public Object aroundDbService(ProceedingJoinPoint joinPoint) throws Throwable {
Object proceed = joinPoint.proceed();
/*log.info("DB SERVICE : {} ; REQUEST{} ; RESPONSE : {}", joinPoint.getSignature().toShortString(),
safeToJson(joinPoint.getArgs()), safeToJson(proceed));*/
log.info("DB SERVICE : {} ; REQUEST{} ; RESPONSE : {}", joinPoint.getSignature().toShortString(),
safeToJson(joinPoint.getArgs()), safeToJson(proceed));
return proceed;
}
@ -46,8 +46,8 @@ public class MethodLogAspect {
@Around("applicationServiceLog()")
public Object aroundApplicationService(ProceedingJoinPoint joinPoint) throws Throwable {
Object proceed = joinPoint.proceed();
/*log.info("APPLICATION SERVICE : {} ; REQUEST{} ; RESPONSE : {}", joinPoint.getSignature().toShortString(),
safeToJson(joinPoint.getArgs()), safeToJson(proceed));*/
log.info("APPLICATION SERVICE : {} ; REQUEST{} ; RESPONSE : {}", joinPoint.getSignature().toShortString(),
safeToJson(joinPoint.getArgs()), safeToJson(proceed));
return proceed;
}

View File

@ -61,7 +61,7 @@ public class CodeGenerator {
//生成的类 放在orm子模块下的/target/generated-code目录底下
.module("/agileboot-orm/target/generated-code")
.parentPackage("com.agileboot")
.tableName("payment_operation_log")
.tableName("wx_user_info")
// 决定是否继承基类
.isExtendsFromBaseEntity(true)
.build();

View File

@ -25,6 +25,3 @@ CREATE TABLE `cabinet_cell_operation` (
ALTER TABLE `shop_goods`
ADD COLUMN `auto_approval` TINYINT NOT NULL DEFAULT 0 COMMENT '免审批0否 1是' AFTER `status`;
ALTER TABLE `shop_order`
ADD COLUMN `is_deduct_stock` TINYINT NOT NULL DEFAULT 0 COMMENT '已扣减库存0否 1是' AFTER `pay_status`;

View File

@ -1,15 +0,0 @@
DROP TABLE IF EXISTS `payment_operation_log`;
CREATE TABLE `payment_operation_log` (
`log_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '日志ID',
`order_id` BIGINT NULL COMMENT '订单ID关联shop_order.order_id',
`status` TINYINT NOT NULL DEFAULT 1 COMMENT '操作状态1成功 2失败',
`creator_id` BIGINT NOT NULL DEFAULT 0 COMMENT '创建者ID',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater_id` BIGINT NOT NULL DEFAULT 0 COMMENT '更新者ID',
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`remark` TEXT DEFAULT NULL COMMENT '操作备注',
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '删除标志0存在 1删除',
PRIMARY KEY (`log_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='支付操作日志表';