添加红包使用记录
This commit is contained in:
parent
528635aeb7
commit
2c06abadf4
@ -5,6 +5,7 @@ namespace app\common\dao\store;
|
|||||||
use app\common\dao\BaseDao;
|
use app\common\dao\BaseDao;
|
||||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||||
use app\common\model\store\consumption\StoreConsumption;
|
use app\common\model\store\consumption\StoreConsumption;
|
||||||
|
use app\common\model\store\consumption\StoreConsumptionDetail;
|
||||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||||
use app\common\model\store\StoreActivityOrder;
|
use app\common\model\store\StoreActivityOrder;
|
||||||
use app\common\model\store\StoreActivityUser;
|
use app\common\model\store\StoreActivityUser;
|
||||||
@ -249,6 +250,34 @@ class StoreActivityUserDao extends BaseDao
|
|||||||
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 红包获取记录
|
||||||
|
* @param int $userId
|
||||||
|
* @param int $type
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function useRecord(int $userId, int $type, int $page, int $limit)
|
||||||
|
{
|
||||||
|
$totalAmount = StoreConsumptionUser::where('uid', $userId)
|
||||||
|
->whereIn('type', $type)
|
||||||
|
->where('status', StoreConsumptionUser::STATUS_UNUSED)
|
||||||
|
->sum('balance');
|
||||||
|
$query = StoreConsumptionDetail::field('create_time,order_id,amount coupon_price,pay_price')
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->where('type', 1);
|
||||||
|
$count = $query->count();
|
||||||
|
$record = $query->page($page)->limit($limit)->select()->toArray();
|
||||||
|
foreach ($record as &$item) {
|
||||||
|
$item['order_amount'] = bcadd($item['coupon_price'], $item['pay_price'], 2);
|
||||||
|
}
|
||||||
|
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 红包余额统计
|
* 红包余额统计
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
|
@ -133,4 +133,22 @@ class StoreActivity extends BaseController
|
|||||||
return app('json')->success($result);
|
return app('json')->success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 红包获取记录
|
||||||
|
* @param StoreActivityUserDao $dao
|
||||||
|
* @return mixed
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function useRecord(StoreActivityUserDao $dao)
|
||||||
|
{
|
||||||
|
$userId = $this->request->uid();
|
||||||
|
$type = $this->request->get('type', 1);
|
||||||
|
$page = $this->request->get('page', 1);
|
||||||
|
$limit = $this->request->get('limit', 10);
|
||||||
|
$result = $dao->useRecord($userId, $type, $page, $limit);
|
||||||
|
return app('json')->success($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -476,6 +476,7 @@ Route::group('api/', function () {
|
|||||||
Route::get('total', 'api.store.StoreActivity/total'); //活动红包统计
|
Route::get('total', 'api.store.StoreActivity/total'); //活动红包统计
|
||||||
Route::get('product', 'api.store.StoreActivity/product'); //活动商品专区
|
Route::get('product', 'api.store.StoreActivity/product'); //活动商品专区
|
||||||
Route::get('district', 'api.store.StoreActivity/district'); //活动地区列表
|
Route::get('district', 'api.store.StoreActivity/district'); //活动地区列表
|
||||||
|
Route::get('useRecord', 'api.store.StoreActivity/useRecord'); //活动红包获取记录
|
||||||
});
|
});
|
||||||
})->middleware(UserTokenMiddleware::class, true);
|
})->middleware(UserTokenMiddleware::class, true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user