添加:获取兑换二维码显示

This commit is contained in:
wuhui_zzw 2024-01-15 14:37:43 +08:00
parent 5e61da43a2
commit 63946b2c81
2 changed files with 69 additions and 1 deletions

View File

@ -12,7 +12,10 @@ use app\common\repositories\user\ExchangePickupPointRepository;
use app\common\repositories\user\ExchangePickupRecordRepository;
use app\common\repositories\user\ExchangeQuotaRepository;
use crmeb\basic\BaseController;
use crmeb\services\QrcodeService;
use crmeb\services\wechat\MiniProgram;
use think\App;
use think\exception\ValidateException;
use think\facade\Db;
class Exchange extends BaseController{
@ -68,13 +71,14 @@ class Exchange extends BaseController{
*/
public function exchangeHandle(){
// 参数获取
$uid = $this->request->uid();
$data = $this->request->params(['total_money','use_integral','diff_money','diff_money_pay','point_id','staff_uid']);
if ((float)$data['total_money'] <= 0) return app('json')->fail('价值必须大于0');
if ((float)$data['point_id'] <= 0) return app('json')->fail('请选择提货点!');
if ((float)$data['staff_uid'] <= 0) return app('json')->fail('请选择操作员!');
if ($data['staff_uid'] == $uid) return app('json')->fail('操作员和消费用户不能是同一人!');
// 添加兑换记录
try{
$uid = $this->request->uid();
Db::transaction(function () use ($data, $uid) {
// 添加兑换记录
ExchangePickupRecord::insert([
@ -148,7 +152,65 @@ class Exchange extends BaseController{
}
/**
* Common: 获取当前用户身为管理员时 参与管理的站点
* Author: wu-hui
* Time: 2024/01/15 11:22
* @return mixed
*/
public function siteList(){
$search = $this->request->params(['uid','address']);
$search['uid'] = $this->request->uid();
[$page, $limit] = $this->getPage();
$data = app()->make(ExchangePickupPointRepository::class)->getList($search, $page, $limit);
return app('json')->success($data);
}
/**
* Common: 获取当前用户身为管理员时 操作的兑换记录
* Author: wu-hui
* Time: 2024/01/15 11:20
* @return mixed
*/
public function siteExchangeRecord(){
$params = $this->request->params(['staff_uid','address','uid']);
$params['staff_uid'] = $this->request->uid();
[$page, $limit] = $this->getPage();
$data = app()->make(ExchangePickupRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 获取兑换二维码显示
* Author: wu-hui
* Time: 2024/01/15 14:37
* @return mixed
*/
public function siteQrCode(){
// 参数获取
$uid = $this->request->uid();
$params = $this->request->params(['point_id']);
if((int)$params['point_id'] > 0){
try{
$valueData = 'staff_uid=' . $uid . '&point_id=' . $params['point_id'];
$name = md5($valueData) . '.jpg';
// pages/users/online_payment/exchange/index
$qrcode = app()->make(QrcodeService::class)->getRoutineQrcodePath($name, 'pages/users/online_payment/exchange/index', $valueData);
if (!$qrcode) throw new \Exception('二维码生成失败');
return app('json')->success([
'qr_code' => $qrcode
]);
}catch(\Exception $e){
return app('json')->fail($e->getMessage());
}catch(\Throwable $e){
return app('json')->fail($e->getMessage());
}
}
return app('json')->fail('小程序码生成失败!');
}

View File

@ -348,10 +348,16 @@ Route::group('api/', function () {
})->prefix('api.store.order.');
// 商品兑换
Route::group('exchange', function () {
// 兑换相关
Route::get('pointList', 'Exchange/getPointList');
Route::get('userHold', 'Exchange/getUserHold');
Route::get('exchangeHandle', 'Exchange/exchangeHandle');
Route::get('exchangeRecord', 'Exchange/exchangeRecord');
// 站点管理相关
Route::get('site_list', 'Exchange/siteList');
Route::get('site_exchange_record', 'Exchange/siteExchangeRecord');
Route::get('site_qr_code', 'Exchange/siteQrCode');
})->prefix('api.user.');