Merge branch 'devops-staging' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend
This commit is contained in:
commit
a2e81f1c53
44
src/product/history-status/history-status.service.ts
Normal file
44
src/product/history-status/history-status.service.ts
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { EntityNotFoundError, IsNull, Repository } from 'typeorm';
|
||||||
|
import { ProductHistoryStatus } from '../entities/product-history-status.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProductHistoryStatusService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(ProductHistoryStatus)
|
||||||
|
private productHistoryStatusRepository: Repository<ProductHistoryStatus>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async create(dataProduct: ProductHistoryStatus) {
|
||||||
|
const result = await this.productHistoryStatusRepository.insert(
|
||||||
|
dataProduct,
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOneActive(productId: string, partnerId: string) {
|
||||||
|
try {
|
||||||
|
return await this.productHistoryStatusRepository.findOneOrFail({
|
||||||
|
relations: ['product'],
|
||||||
|
where: {
|
||||||
|
product: productId,
|
||||||
|
partner: partnerId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Product not active',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import { ProductSubCategoriesService } from './product-sub-categories.service';
|
||||||
import { UsersModule } from '../users/users.module';
|
import { UsersModule } from '../users/users.module';
|
||||||
import { ProductHistoryPriceService } from './history-price/history-price.service';
|
import { ProductHistoryPriceService } from './history-price/history-price.service';
|
||||||
import {ProductHistoryStatus} from "./entities/product-history-status.entity";
|
import {ProductHistoryStatus} from "./entities/product-history-status.entity";
|
||||||
|
import {ProductHistoryStatusService} from "./history-status/history-status.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -29,7 +30,8 @@ import {ProductHistoryStatus} from "./entities/product-history-status.entity";
|
||||||
ProductCategoriesService,
|
ProductCategoriesService,
|
||||||
ProductSubCategoriesService,
|
ProductSubCategoriesService,
|
||||||
ProductHistoryPriceService,
|
ProductHistoryPriceService,
|
||||||
|
ProductHistoryStatusService,
|
||||||
],
|
],
|
||||||
exports: [ProductService, ProductHistoryPriceService],
|
exports: [ProductService, ProductHistoryPriceService, ProductHistoryStatusService],
|
||||||
})
|
})
|
||||||
export class ProductModule {}
|
export class ProductModule {}
|
||||||
|
|
|
@ -12,7 +12,8 @@ import { UsersModule } from 'src/users/users.module';
|
||||||
import { ConfigurableModule } from '../configurable/configurable.module';
|
import { ConfigurableModule } from '../configurable/configurable.module';
|
||||||
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||||
import { CallbackPartner } from './entities/callback-partner.entity';
|
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||||
import {ProductHistoryPrice} from "../product/entities/product-history-price.entity";
|
import { ProductHistoryPrice } from '../product/entities/product-history-price.entity';
|
||||||
|
import { ProductHistoryStatus } from '../product/entities/product-history-status.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -23,6 +24,7 @@ import {ProductHistoryPrice} from "../product/entities/product-history-price.ent
|
||||||
CheckBillHistory,
|
CheckBillHistory,
|
||||||
CallbackPartner,
|
CallbackPartner,
|
||||||
ProductHistoryPrice,
|
ProductHistoryPrice,
|
||||||
|
ProductHistoryStatus,
|
||||||
]),
|
]),
|
||||||
ProductModule,
|
ProductModule,
|
||||||
ConfigurableModule,
|
ConfigurableModule,
|
||||||
|
|
|
@ -37,6 +37,7 @@ import axios from 'axios';
|
||||||
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||||
import { CallbackPartner } from './entities/callback-partner.entity';
|
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||||
import { doAuthorizeHemat } from '../helper/sihemat-authorization';
|
import { doAuthorizeHemat } from '../helper/sihemat-authorization';
|
||||||
|
import { ProductHistoryStatusService } from '../product/history-status/history-status.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionService {
|
export class TransactionService {
|
||||||
|
@ -58,6 +59,7 @@ export class TransactionService {
|
||||||
private coaService: CoaService,
|
private coaService: CoaService,
|
||||||
private productService: ProductService,
|
private productService: ProductService,
|
||||||
private productHistoryPriceService: ProductHistoryPriceService,
|
private productHistoryPriceService: ProductHistoryPriceService,
|
||||||
|
private productHistoryStatusService: ProductHistoryStatusService,
|
||||||
private userService: UsersService,
|
private userService: UsersService,
|
||||||
private commissionService: CommissionService,
|
private commissionService: CommissionService,
|
||||||
private supplierService: SupplierService,
|
private supplierService: SupplierService,
|
||||||
|
@ -520,6 +522,20 @@ export class TransactionService {
|
||||||
product.supplier.code,
|
product.supplier.code,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const statusProduct = await this.productHistoryStatusService.findOneActive(
|
||||||
|
product.id,
|
||||||
|
userData.partner.id ? userData.partner.id : null,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (statusProduct.status == 'NOT ACTIVE') {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: `Transaction Failed because product is not active`,
|
||||||
|
},
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
console.log('userdatapartnerid', userData.partner?.id);
|
console.log('userdatapartnerid', userData.partner?.id);
|
||||||
|
|
||||||
let product_price = await this.productHistoryPriceService.findOne(
|
let product_price = await this.productHistoryPriceService.findOne(
|
||||||
|
@ -592,7 +608,7 @@ export class TransactionService {
|
||||||
let hitLoginHemat;
|
let hitLoginHemat;
|
||||||
|
|
||||||
if (supplier.code == 'Hemat') {
|
if (supplier.code == 'Hemat') {
|
||||||
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hitSupplier = supplier.code == 'Hemat' ?
|
let hitSupplier = supplier.code == 'Hemat' ?
|
||||||
|
@ -618,8 +634,8 @@ export class TransactionService {
|
||||||
console.log('iniresponsupplier', hitSupplier.harga)
|
console.log('iniresponsupplier', hitSupplier.harga)
|
||||||
console.log(supplier.code, 'sdkfjsd');
|
console.log(supplier.code, 'sdkfjsd');
|
||||||
console.log(product_price, 'price');
|
console.log(product_price, 'price');
|
||||||
|
|
||||||
|
|
||||||
if (supplier.code == 'metro') {
|
if (supplier.code == 'metro') {
|
||||||
const parsingResponse = hitSupplier.split(' ');
|
const parsingResponse = hitSupplier.split(' ');
|
||||||
console.log('parsingResponse', parsingResponse)
|
console.log('parsingResponse', parsingResponse)
|
||||||
|
@ -651,7 +667,7 @@ export class TransactionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(hitSupplier, 'newhitSupplier');
|
console.log(hitSupplier, 'newhitSupplier');
|
||||||
|
|
||||||
// const hitSupplier = {
|
// const hitSupplier = {
|
||||||
// harga: 2000,
|
// harga: 2000,
|
||||||
// success: true,
|
// success: true,
|
||||||
|
@ -768,7 +784,7 @@ export class TransactionService {
|
||||||
amount: product_price.mark_up_price + product_price.price,
|
amount: product_price.mark_up_price + product_price.price,
|
||||||
status: status,
|
status: status,
|
||||||
};
|
};
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async orderTransactionBillProd(
|
async orderTransactionBillProd(
|
||||||
|
@ -839,7 +855,7 @@ export class TransactionService {
|
||||||
let hitLoginHemat;
|
let hitLoginHemat;
|
||||||
|
|
||||||
if (supplier.code == 'Hemat') {
|
if (supplier.code == 'Hemat') {
|
||||||
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hitSupplier = supplier.code == 'Hemat' ?
|
let hitSupplier = supplier.code == 'Hemat' ?
|
||||||
|
@ -995,7 +1011,7 @@ export class TransactionService {
|
||||||
let hitLoginHemat;
|
let hitLoginHemat;
|
||||||
|
|
||||||
if (supplier.code == 'Hemat') {
|
if (supplier.code == 'Hemat') {
|
||||||
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hitSupplier = supplier.code == 'Hemat' ? await doTransaction(
|
let hitSupplier = supplier.code == 'Hemat' ? await doTransaction(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user