|
@@ -34,9 +34,31 @@ class TransactionService extends CrudService {
|
|
|
const newdata = { ...data, username, product_name, market_username };
|
|
|
console.log(data);
|
|
|
const operationlogdata = { dockid, userid, product_id, market_userid, description, status, username, product_name, market_username, type: '1' };
|
|
|
- this.omodel.create(operationlogdata);
|
|
|
+ await this.omodel.create(operationlogdata);
|
|
|
return await this.model.create(newdata);
|
|
|
}
|
|
|
+
|
|
|
+ async update({ id }, data) {
|
|
|
+ const { dockid, userid, product_id, market_userid, description, status, username, product_name, market_username } = data;
|
|
|
+ const transaction = await this.model.findById(id);
|
|
|
+ if (!username) {
|
|
|
+ const user = await this.umodel.findById(userid);
|
|
|
+ username = user.name;
|
|
|
+ }
|
|
|
+ if (!product_name) {
|
|
|
+ const product = await this.pmodel.findById(product_id);
|
|
|
+ product_name = product.name;
|
|
|
+ }
|
|
|
+ if (!market_username) {
|
|
|
+ const market_user = await this.umodel.findById(market_userid);
|
|
|
+ market_username = market_user.name;
|
|
|
+ }
|
|
|
+ transaction.status = status;
|
|
|
+ const operationlogdata = { dockid, userid, product_id, market_userid, description, status, username, product_name, market_username, type: '1' };
|
|
|
+ await this.omodel.create(operationlogdata);
|
|
|
+ return await transaction.save();
|
|
|
+ }
|
|
|
+
|
|
|
async findTransactionList({ product_id }) {
|
|
|
const product = await this.model.find({ product_id });
|
|
|
return product;
|