|
@@ -9,11 +9,10 @@ class TradeService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'trade');
|
|
|
this.redis = this.app.redis;
|
|
|
+ this.redisKey = this.app.config.redisKey;
|
|
|
this.shopModel = this.ctx.model.Shop.Shop;
|
|
|
this.goodsModel = this.ctx.model.Shop.Goods;
|
|
|
this.goodsSpecModel = this.ctx.model.Shop.GoodsSpec;
|
|
|
-
|
|
|
- this.orderKeyPrefix = 'orderKey:';
|
|
|
}
|
|
|
/**
|
|
|
* 检测是否可以购买该物品
|
|
@@ -70,10 +69,11 @@ class TradeService extends CrudService {
|
|
|
result.result = false;
|
|
|
return result;
|
|
|
}
|
|
|
- const key = `${this.orderKeyPrefix}${this.createNonceStr()}`;
|
|
|
+ const str = this.createNonceStr();
|
|
|
+ const key = `${this.redisKey.orderKeyPrefix}${str}`;
|
|
|
const value = JSON.stringify({ shop, goods, goodsSpec, num });
|
|
|
await this.redis.set(key, value, 'EX', 180);
|
|
|
- result.key = key;
|
|
|
+ result.key = str;
|
|
|
return result;
|
|
|
}
|
|
|
// 随机字符串产生函数
|