Browse Source

no message

倚楼听风雨 3 years ago
parent
commit
3616c40f32

+ 4 - 4
cool-admin-midway-master/src/app/modules/shuyou/entity/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-16 22:09:01
+ * @LastEditTime: 2022-09-19 18:00:10
  * @Description: file content
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
  */
@@ -36,16 +36,16 @@ export class ShuyouRentComputerEntity extends BaseEntity {
   @Column({  type:'datetime', comment: '到期时间'})
   rent_end: Date;
 
-  @Column({ type: "double",comment: '租机价格', default: 0.00, scale: 2})
+  @Column({ comment: '租机价格', type: 'decimal', precision: 10, scale: 2, default: 0})
   rent_price: number;
 
-  @Column({ type: "double",comment: '折算天租金', default: 0.00, scale: 2})
+  @Column({ comment: '折算天租金', type: 'decimal', precision: 10, scale: 5, default: 0})
   rent_price_day: number;
 
   @Column({ comment: '结算方式 0:先付后用 1:先用后付 2:其他方式', default: 0, type: 'tinyint' })
   pay_method: number;
 
-  @Column({ type: "double",comment: '当前租赁期内已产生多少租金', default: 0.00, scale: 2})
+  @Column({ type: "decimal",comment: '当前租赁期内已产生多少租金', precision: 10, scale: 5, default: 0})
   rent_price_used: number;
 
   @Column({ comment: '租赁人', nullable: true })

+ 4 - 4
cool-admin-midway-master/src/app/modules/shuyou/entity/rent_ledger_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-02 10:07:27
+ * @LastEditTime: 2022-09-19 18:00:20
  * @Description: file content
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_ledger_computer.ts
  */
@@ -29,13 +29,13 @@ export class ShuyouRentLedgerComputerEntity extends BaseEntity {
   @Column({  type:'datetime', comment: '当时的到期时间', nullable: true })
   rent_end_then: Date;
 
-  @Column({ type: "double",comment: '当时的租机价格', default: 0.00, scale: 2})
+  @Column({ type: "decimal",comment: '当时的租机价格', precision: 10, scale: 2, default: 0})
   rent_price_then: number;
 
-  @Column({ type: "double",comment: '当天租金', default: 0.00, scale: 2})
+  @Column({ type: "decimal",comment: '当天租金', precision: 10, scale: 5, default: 0})
   rent_price_day: number;
 
-  @Column({ type: "double",comment: '当前租赁期内已产生多少租金', default: 0.00, scale: 2})
+  @Column({ type: "decimal",comment: '当前租赁期内已产生多少租金', precision: 10, scale: 5, default: 0})
   rent_price_used_then: number;
 
   @Column({ comment: '游戏任务,多个游戏以英文逗号隔开', nullable: true })

+ 26 - 17
cool-admin-midway-master/src/app/modules/shuyou/service/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-17 22:27:10
+ * @LastEditTime: 2022-09-19 17:55:06
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
@@ -28,7 +28,7 @@ export class ShuyouRentComputerService extends BaseService {
    */
   async add(param) {
     const existsTask = await this.ShuyouRentComputerEntity.findOne({
-      pc_num: param.pc_num
+      pc_num: param.pc_num,
     });
     if (!_.isEmpty(existsTask)) {
       throw new CoolCommException('已存在相同编号的租机');
@@ -37,6 +37,9 @@ export class ShuyouRentComputerService extends BaseService {
     param.updateTime = new Date();
     param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
 
+    console.log('rent_price_day');
+    console.log(param.rent_price_day);
+
     await this.updateTaskGame(param);
     return super.add(param);
   }
@@ -45,25 +48,28 @@ export class ShuyouRentComputerService extends BaseService {
    * 更新租机-任务关系
    * @param pc_task
    */
-   async updateTaskGame(pc_task) {
+  async updateTaskGame(pc_task) {
     await this.ShuyouRentComputerUsageEntity.delete({ pc_num: pc_task.pc_num });
     if (pc_task.taskIdList) {
       for (const task_id of pc_task.taskIdList) {
         // console.log(task_id)
-        await this.ShuyouRentComputerUsageEntity.save({ pc_num: pc_task.pc_num, task_id });
+        await this.ShuyouRentComputerUsageEntity.save({
+          pc_num: pc_task.pc_num,
+          task_id,
+        });
       }
     }
   }
 
   //表编码格式不一致导致报错解决办法
-      //SHOW CREATE TABLE shuyou_rent_computer_usage;
-      //ALTER TABLE shuyou_rent_computer_usage DEFAULT CHARACTER SET utf8mb4 COLLATE=utf8mb4_german2_ci;
-     // ALTER TABLE shuyou_rent_computer_usage CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci;
+  //SHOW CREATE TABLE shuyou_rent_computer_usage;
+  //ALTER TABLE shuyou_rent_computer_usage DEFAULT CHARACTER SET utf8mb4 COLLATE=utf8mb4_german2_ci;
+  // ALTER TABLE shuyou_rent_computer_usage CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci;
   /**
    * 根据ID获得信息
    * @param id
    */
-   public async info(id) {
+  public async info(id) {
     const info = await this.ShuyouRentComputerEntity.findOne({ id });
     if (info) {
       const taskIds = await this.nativeQuery(
@@ -87,20 +93,26 @@ export class ShuyouRentComputerService extends BaseService {
    * 修改
    * @param param 数据
    */
-   async update(param) {
+  async update(param) {
     // console.log(param)
-    const taskInfo = await this.ShuyouRentComputerEntity.findOne({ id: param.id });
+    const taskInfo = await this.ShuyouRentComputerEntity.findOne({
+      id: param.id,
+    });
     if (!taskInfo) {
       throw new CoolCommException('租机不存在');
     }
+    param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
+
+    console.log('rent_price_day');
+    console.log(param.rent_price_day);
+
     await this.ShuyouRentComputerEntity.save(param);
     await this.updateTaskGame(param);
-
   }
   /**
-  * 重写分页查询
-  * @param query
-  */
+   * 重写分页查询
+   * @param query
+   */
   async page(query) {
     const { pc_num } = query;
     const sql = `
@@ -122,7 +134,4 @@ export class ShuyouRentComputerService extends BaseService {
         `;
     return this.sqlRenderPage(sql, query);
   }
-
-
-
 }

+ 1 - 1
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_computer.vue

@@ -421,7 +421,7 @@ export default defineComponent({
 		}
 		// 计算租机到期时间
 		function calculateRentDuration(scope: { rent_end: Date; rent_start: string; rent_duration: string; }) {
-			scope.rent_end = new Date(Date.parse(scope.rent_start) + 1 * 24 * 60 * 60 * 1000 * parseInt(scope.rent_duration))
+			scope.rent_end = new Date(Date.parse(scope.rent_start) + 1 * 24 * 60 * 60 * 1000 * (parseInt(scope.rent_duration) - 1 ))
 		}
 		// 监听
 		watch(