Commit ebe2fd7a by yink

fix: 修复多处逻辑错误和优化代码

1. 修复UserPointChangeRecController中用户昵称筛选字段错误
2. 修复OrderDivideRecord中现金支付比例计算错误
3. 优化StoreAdminUsersController中金额显示精度
4. 修复OrderController中支付方式设置遗漏问题
5. 重构SystemSettingController中二维码生成逻辑,改为从数据库读取
parent 0e86f962
......@@ -19,7 +19,6 @@ protected function grid()
{
return Grid::make(UserPointChangeRec::with('user'), function (Grid $grid) {
$grid->model()->orderBy('created_at', 'DESC');
$grid->column('id', 'ID')->sortable();
$grid->column('user_id', '用户ID');
......@@ -49,7 +48,7 @@ protected function grid()
$filter->panel();
$filter->equal('user_id', '用户ID')->width(3);
// 添加用户昵称筛选
$filter->like('user.nickname', '用户昵称')->width(3);
$filter->like('user.name', '用户昵称')->width(3);
$filter->equal('change_type', '增减类别')->radio([
1 => '增加',
0 => '减少'
......
......@@ -348,6 +348,7 @@ public function pay(Request $request)
$order_amount = $order->order_amount; //订单金额
//判断支付方式
if ($pay_type == 1) {
$order->pay_type = $pay_type; //支付方式
$order->point_amount = $point_amount; //积分抵扣金额
$order->pay_cs += 1;
} else if ($pay_type == 2) {
......@@ -361,6 +362,7 @@ public function pay(Request $request)
}
//积分支付
$order->pay_type = $pay_type; //支付方式
$order->point_amount = $order_amount; //积分抵扣金额
$order->pay_cs += 1;
$order->order_amount = 0; //订单金额0
......@@ -381,6 +383,7 @@ public function pay(Request $request)
return $this->JsonResponse('', '网络异常,积分抵扣失败!003', 500);
}
$order_amount = $order_amount - $userObj->balance;
$order->pay_type = $pay_type; //支付方式
$order->point_amount = $userObj->balance; //积分抵扣金额
$order->order_amount = $order_amount;
$order->pay_cs += 1;
......
......@@ -108,11 +108,11 @@ public function info(Request $request)
$balance02= $orderDivideRecord->where('is_div', 0)->sum('divide_price'); //冻结中
//已提现==分佣记录中,状态为2的
$cashout = number_format($orderDivideRecord->where('is_div', 1)->sum('divide_price'), 4); //已分账
$cashout = number_format($orderDivideRecord->where('is_div', 1)->sum('divide_price'), 2); //已分账
//冻结中=分佣记录中,状态为1的+订单状态为已支付,未分账的应该分佣金额
$balance = number_format($balance01 + $balance02, 4); //冻结中
$total_revenue = number_format($balance + $cashout, 4); //总佣金
$balance = number_format($balance01 + $balance02, 2); //冻结中
$total_revenue = number_format($balance + $cashout, 2); //总佣金
Log::info('balance:'.$balance);
}
......
......@@ -3,7 +3,8 @@
namespace App\Http\Controllers\Api;
use App\Command\Log;
use App\Models\OrderGoods;
use App\Models\OrderInfo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Models\SystemSetting as SystemSettingModel;
......@@ -20,44 +21,65 @@ class SystemSettingController extends BaseController
{
//返回核销用的二维码
public function verificationGrCode(Request $request)
{
$user_id = $request->user()->id;
//$user_id = $request->user()->id;
$code = $request->code;
$writer = new PngWriter();
//$str = "#小程序://留日指南/AYpQ1H8PIFNvUaC";
$qrCode = QrCode::create($code)
->setEncoding(new Encoding('UTF-8'))
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
->setSize(300)
->setMargin(10)
->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
->setForegroundColor(new Color(0, 0, 0))
->setBackgroundColor(new Color(255, 255, 255));
$result = $writer->write($qrCode);
$dataUri = $result->getDataUri();
// 指定保存路径
$folder_name = "/qrcode/" . date("Ymd", time());
$filename = md5("verifi_code_" . $code . "_" . $user_id) . ".png";
$savePath = public_path() . "/uploads" . $folder_name . "/";
if (!file_exists($savePath)) {
mkdir($savePath, 0755, true);
}
$result->saveToFile($savePath . $filename);
$filepath = env('IMAGE_URL') . $folder_name . "/" . $filename;
//$qrCode->writeFile($savePath);
return $this->JsonResponse(['qrcode' => $dataUri, 'filepath' => $filepath]);
//查询数据库,获取二维码
$codeimg = OrderInfo::where(['verification_code' => $code])->value('verification_code_img');
$codeimg= env('IMAGE_URL'). $codeimg;
return $this->JsonResponse(['filepath' => $codeimg]);
// $writer = new PngWriter();
// //$str = "#小程序://留日指南/AYpQ1H8PIFNvUaC";
// $qrCode = QrCode::create($code)
// ->setEncoding(new Encoding('UTF-8'))
// ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
// ->setSize(300)
// ->setMargin(10)
// ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
// ->setForegroundColor(new Color(0, 0, 0))
// ->setBackgroundColor(new Color(255, 255, 255));
// $result = $writer->write($qrCode);
// $dataUri = $result->getDataUri();
// // 指定保存路径
// $folder_name = "/qrcode/" . date("Ymd", time());
// $filename = md5("verifi_code_" . $code . "_" . $user_id) . ".png";
// $savePath = public_path() . "/uploads" . $folder_name . "/";
// if (!file_exists($savePath)) {
// mkdir($savePath, 0755, true);
// }
// $result->saveToFile($savePath . $filename);
// $filepath = env('IMAGE_URL') . $folder_name . "/" . $filename;
// //$qrCode->writeFile($savePath);
// return $this->JsonResponse(['qrcode' => $dataUri, 'filepath' => $filepath]);
// 返回二维码图片的Base64编码
//return response()->json(['status' => 'success', 'qrcode' => 'data:image/png;base64,' . base64_encode($qrCode)]);
}
//返回分享用的二维码
public function qrCode(Request $request)
{
$user_id = $request->user()->id;
$writer = new PngWriter();
// 检查用户是否已有二维码
$folder_name = "/qrcode";
$filename = "qrcode_" . $user_id . ".png";
$filepath = public_path() . "/uploads" . $folder_name . "/" . $filename;
if (file_exists($filepath)) {
return $this->JsonResponse([
'qrcode' => '',
'filepath' => env('API_URL') . "/uploads" . $folder_name . "/" . $filename
]);
}
$writer = new PngWriter();
$spurl = env("API_URL") . "/share?code=" . $user_id;
$qrCode = QrCode::create($spurl)
......@@ -69,21 +91,17 @@ public function qrCode(Request $request)
->setForegroundColor(new Color(0, 0, 0))
->setBackgroundColor(new Color(255, 255, 255));
$result = $writer->write($qrCode);
$dataUri = $result->getDataUri();
// 指定保存路径
$folder_name = "/qrcode/" . date("Ymd", time());
$filename = "qrcode_" . $user_id . ".png";
$savePath = public_path() . "/uploads" . $folder_name . "/";
if (!file_exists($savePath)) {
mkdir($savePath, 0755, true);
}
$result->saveToFile($savePath . $filename);
$filepath = env('API_URL') . "/uploads" . $folder_name . "/" . $filename;
//$qrCode->writeFile($savePath);
return $this->JsonResponse(['qrcode' => $dataUri, 'filepath' => $filepath]);
// 返回二维码图片的Base64编码
//return response()->json(['status' => 'success', 'qrcode' => 'data:image/png;base64,' . base64_encode($qrCode)]);
$result->saveToFile($filepath);
return $this->JsonResponse([
'filepath' => env('API_URL') . "/uploads" . $folder_name . "/" . $filename
]);
}
//
......@@ -148,7 +166,7 @@ public static function GetQrCode($code)
// 指定保存路径
$folder_name = "/qrcode/" . date("Ymd", time());
$filename = md5( $code ).date("YmdHis", time()) . ".png";
$filename = md5($code) . date("YmdHis", time()) . ".png";
$savePath = public_path() . "/uploads" . $folder_name . "/";
if (!file_exists($savePath)) {
mkdir($savePath, 0755, true);
......@@ -156,7 +174,7 @@ public static function GetQrCode($code)
$result->saveToFile($savePath . $filename);
//加个判断
if (!file_exists($savePath. $filename)) {
if (!file_exists($savePath . $filename)) {
Log::add('getQrCode', [
'code' => $code,
'msg' => '二维码生成失败'
......@@ -172,7 +190,4 @@ public static function GetQrCode($code)
// 返回二维码图片的Base64编码
//return response()->json(['status' => 'success', 'qrcode' => 'data:image/png;base64,' . base64_encode($qrCode)]);
}
}
......@@ -94,14 +94,14 @@ public static function divide($order_id, $payconfirm_no = '')
->select(DB::raw('SUM(goods_price * goods_number) as total'))
->value('total');
//计算现金支付比例
$cash_ratio = number_format(($orderObj->order_amount / $orderGoodCash) / 100, 4); //保留4位小数
$cash_ratio = number_format(($orderObj->order_amount / $orderGoodCash), 4); //保留4位小数
}
Log::add('divide', "订单ID:{$order_id},支付类型:{$orderObj->pay_type},现金支付比例:{$cash_ratio}");
foreach ($ogList as $kk => $item) {
$goods_amount = $item->goods_price * $item->goods_number;
$total_amount += $goods_amount;
$total_amount += number_format($goods_amount*$cash_ratio,2);
//商品信息
$goodObj = Good::find($item->goods_id);
$merchant_commission = $goodObj->merchant_commission;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment