|
|
@@ -103,12 +103,23 @@ class EnshrineService extends BaseService
|
|
|
$item['guibai_check'] = $wash? $wash : 0;
|
|
|
|
|
|
// 花
|
|
|
- $item['hua'] = ['id'=> 0,'url'=> ''];
|
|
|
- $hua =
|
|
|
+ $item['hua'] = ['id'=> 0,'icon'=> '','icon_real'=> ''];
|
|
|
+ $hua = $this->getOrderGoodsInfo($item['id'], $userId, $item['type'], 2);
|
|
|
+ if($hua){
|
|
|
+ $item['hua'] = $hua;
|
|
|
+ }
|
|
|
// 水果
|
|
|
- $item['guo'] = ['id'=> 0,'url'=> ''];
|
|
|
+ $item['guo'] = ['id'=> 0,'icon'=> '','icon_real'=> ''];
|
|
|
+ $guo = $this->getOrderGoodsInfo($item['id'], $userId, $item['type'], 2);
|
|
|
+ if($guo){
|
|
|
+ $item['guo'] = $guo;
|
|
|
+ }
|
|
|
// 香烛
|
|
|
- $item['xiang'] = ['id'=> 0,'url'=> ''];
|
|
|
+ $item['xiang'] = ['id'=> 0,'icon'=> '','icon_real'=> ''];
|
|
|
+ $xiang = $this->getOrderGoodsInfo($item['id'], $userId, $item['type'], 2);
|
|
|
+ if($xiang){
|
|
|
+ $item['xiang'] = $xiang;
|
|
|
+ }
|
|
|
}
|
|
|
unset($item);
|
|
|
}
|
|
|
@@ -122,17 +133,40 @@ class EnshrineService extends BaseService
|
|
|
];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public function getOrderGoodsInfo($sid, $goodsId, $userId, $type, $goodsType){
|
|
|
- $cacheKey = "caches:enshrine:orders_goods:u{$userId}_s{$sid}_g{$goodsId}_{$type}_{$goodsType}";
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 获取已经购买供奉物品信息
|
|
|
+ * @param $sid
|
|
|
+ * @param $userId
|
|
|
+ * @param $type
|
|
|
+ * @param $goodsType
|
|
|
+ * @return array|mixed
|
|
|
+ */
|
|
|
+ public function getOrderGoodsInfo($sid, $userId, $type, $goodsType){
|
|
|
+ $cacheKey = "caches:enshrine:orders_goods:u{$userId}_s{$sid}_{$type}_{$goodsType}";
|
|
|
+ $info = RedisService::get($cacheKey);
|
|
|
+ if($info){
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ $expireTime = ConfigService::make()->getConfigByCode('enshrine_expire_time');
|
|
|
+ $expireTime = $expireTime? $expireTime : 0;
|
|
|
$info = EnshrineOrdersModel::from('enshrine_orders as eo')
|
|
|
->leftJoin('offerings as g','g.id','=','eo.goods_id')
|
|
|
- ->where(['eo.source_id'=> $sid,'eo.goods_id'=> $goodsId,'eo.user_id'=> $userId,'eo.type'=> $type,'g.goods_type'=> $goodsType])
|
|
|
- ->where('eo.create_time','>=', time()-3600)
|
|
|
- ->select(['g.name','g.goods_type','g.code','g.icon','g.icon_real','eo.source_id','eo.status'])
|
|
|
+ ->where(['eo.source_id'=> $sid,'eo.user_id'=> $userId,'eo.type'=> $type,'g.goods_type'=> $goodsType])
|
|
|
+ ->where(function($query) use($expireTime){
|
|
|
+ if($expireTime>0){
|
|
|
+ $query->where('create_time','>=', time()- $expireTime*3600);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->select(['g.name','g.goods_type','g.code','g.icon','g.icon_real','eo.source_id','eo.status','eo.create_time'])
|
|
|
->orderBy('eo.create_time','desc')
|
|
|
->first();
|
|
|
+ $info = $info? $info->toArray() : [];
|
|
|
+ if($info){
|
|
|
+ $info['icon'] = $info['icon']? get_image_url($info['icon']) : '';
|
|
|
+ $info['icon_real'] = $info['icon_real']? get_image_url($info['icon_real']) : '';
|
|
|
+ RedisService::set($cacheKey, $info, rand(3, 5));
|
|
|
+ }
|
|
|
+ return $info;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -410,14 +444,7 @@ class EnshrineService extends BaseService
|
|
|
// 是否未到期
|
|
|
$expireTime = ConfigService::make()->getConfigByCode('enshrine_expire_time');
|
|
|
$expireTime = $expireTime? $expireTime : 0;
|
|
|
- $info = EnshrineOrdersModel::where(['source_id'=> $enshrineId,'goods_id'=> $id,'user_id'=> $userId,'type'=> $type])
|
|
|
- ->where(function($query) use($expireTime){
|
|
|
- if($expireTime>0){
|
|
|
- $query->where('create_time','>=', time()- $expireTime*3600);
|
|
|
- }
|
|
|
- })
|
|
|
- ->select(['id','source_id','create_time'])
|
|
|
- ->first();
|
|
|
+ $info = $this->getOrderGoodsInfo($enshrineId, $userId, $type, $goodsInfo->goods_type);
|
|
|
if($info){
|
|
|
$enshrineTime = (time() - $info->ceate_time);
|
|
|
$hour = intval($enshrineTime/3600);
|