Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
adf0ae1d42
@ -7,6 +7,7 @@ use Next\VarDumper\Dumper;
|
||||
use Next\VarDumper\DumperHandler;
|
||||
use support\exception\BusinessException;
|
||||
use support\exception\Handler;
|
||||
use support\Log;
|
||||
use Throwable;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
@ -22,6 +23,7 @@ class ExceptionHandler extends Handler
|
||||
return \response(self::convertToHtml($exception));
|
||||
}elseif ($exception instanceof BusinessException) {
|
||||
if ($request->expectsJson()) {
|
||||
Log::error('BusinessException:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
return json(['code' => 0, 'msg' => $exception->getMessage(),'show'=>1]);
|
||||
}
|
||||
return response($exception->getMessage());
|
||||
@ -35,9 +37,12 @@ class ExceptionHandler extends Handler
|
||||
$error['file'] = $exception->getFile();
|
||||
$error['line'] = $exception->getLine();
|
||||
}
|
||||
Log::error('Exception:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
return response(json_encode($error, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
// 非json请求则返回一个页面
|
||||
Log::error('other:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
|
||||
return new Response(200, [], 'msg:'.$exception->getMessage().'。line:'.$exception->getLine().'。file:'.$exception->getFile());
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app;
|
||||
|
||||
use support\exception\BusinessException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class MyBusinessException extends BusinessException
|
||||
{
|
||||
public function render(Request $request): ?Response
|
||||
{
|
||||
// json请求返回json数据
|
||||
if ($request->expectsJson()) {
|
||||
return json(['code' => $this->getCode() ?: 500, 'msg' => $this->getMessage(),'show'=>1]);
|
||||
}
|
||||
// 非json请求则返回一个页面
|
||||
return new Response(200, [], $this->getMessage());
|
||||
}
|
||||
}
|
@ -411,7 +411,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
'admin_id' => $admin_id,
|
||||
'total_price' => $arr['total_price'],
|
||||
'price' => $arr['price'],
|
||||
'vip_price' => $price==0?$arr['price']:$price,
|
||||
'vip_price' => $price,
|
||||
'purchase' => $arr['purchase'],
|
||||
'oid' => $res['id'],
|
||||
'code' => $res['code'],
|
||||
@ -870,10 +870,10 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
if($order['uid']>0){
|
||||
$user_ship = User::where('id', $order['uid'])->value('user_ship');
|
||||
if($user_ship==0){
|
||||
throw new BusinessException('用户id不能为0');
|
||||
throw new BusinessException('用户角色id不能为0');
|
||||
}
|
||||
}else{
|
||||
throw new BusinessException('用户id不能为0');
|
||||
throw new BusinessException('该订单没选择会员用户');
|
||||
}
|
||||
$total_price = 0;
|
||||
$pay_price = 0;
|
||||
|
@ -346,31 +346,28 @@ class WarehouseProductLogic extends BaseLogic
|
||||
//减少
|
||||
private static function decStock($res)
|
||||
{
|
||||
$res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||
->where('product_id', $res['product_id'])
|
||||
->dec('nums', $res['nums'])
|
||||
->save();
|
||||
SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], -1, Request()->url());
|
||||
$res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||
->where('product_id', $res['product_id'])->find();
|
||||
$res1->save(['nums'=>bcsub($res1['nums'], $res['nums'],2)]);
|
||||
SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], -1, Request()->url());
|
||||
|
||||
$res2 = StoreBranchProduct::where('id', $res['id'])
|
||||
->dec('stock', $res['nums'])
|
||||
->update();
|
||||
$res2 = StoreBranchProduct::where('id', $res['id'])->find();
|
||||
$res2->save(['stock'=>bcsub($res2['stock'], $res['nums'],2)]);
|
||||
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], -1, Request()->url());
|
||||
}
|
||||
|
||||
//增加
|
||||
private static function incStock($res, $params)
|
||||
{
|
||||
$res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||
$res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||
->where('product_id', $res['product_id'])
|
||||
->inc('nums', $params['nums'])
|
||||
->save();
|
||||
SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], 1, Request()->url());
|
||||
->find();
|
||||
$res1->save(['nums'=>bcadd($res1['nums'], $params['nums'],2)]);
|
||||
|
||||
SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], 1, Request()->url());
|
||||
|
||||
|
||||
$res2 = StoreBranchProduct::where('id', $res['id'])
|
||||
->inc('stock', $params['nums'])
|
||||
->save();
|
||||
$res2 = StoreBranchProduct::where('id', $res['id'])->find();
|
||||
$res2->save(['stock'=>bcadd($res2['stock'], $params['nums'],2)]);
|
||||
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], 1, Request()->url());
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use app\common\enum\AdminTerminalEnum;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\MyBusinessException;
|
||||
use support\exception\BusinessException;
|
||||
use Webman\Config;
|
||||
|
||||
|
@ -9,8 +9,7 @@ use app\common\model\order\Cart;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\MyBusinessException;
|
||||
use think\Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,34 @@ class StoreBranchProduct extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'store_branch_product';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public $ignoreLogFields = [
|
||||
'top_cate_id',
|
||||
'two_cate_id',
|
||||
'cate_id',
|
||||
'store_name',
|
||||
'image',
|
||||
'price',
|
||||
'vip_price',
|
||||
'cost',
|
||||
'purchase',
|
||||
'total_price',
|
||||
'store_info',
|
||||
'keyword',
|
||||
'bar_code',
|
||||
'rose',
|
||||
'status',
|
||||
'product_type',
|
||||
'unit',
|
||||
'batch',
|
||||
'store_batch',
|
||||
'sort',
|
||||
'label_id',
|
||||
'is_lack',
|
||||
'manufacturer_information',
|
||||
'status',
|
||||
'create_time',
|
||||
'update_time',
|
||||
];
|
||||
|
||||
|
||||
public function unitName()
|
||||
|
@ -18,7 +18,34 @@ class WarehouseProduct extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'warehouse_product';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public $ignoreLogFields = [
|
||||
'price',
|
||||
'total_price',
|
||||
'status',
|
||||
'pay_type',
|
||||
'is_pay',
|
||||
'vip_price',
|
||||
'cost',
|
||||
'purchase',
|
||||
'total_price',
|
||||
'mark',
|
||||
'after_nums',
|
||||
'before_nums',
|
||||
'batch',
|
||||
'enter_admin_id',
|
||||
'admin_id',
|
||||
'financial_pm',
|
||||
'expiration_date',
|
||||
'manufacture',
|
||||
'code',
|
||||
'oid',
|
||||
'unit',
|
||||
'store_id',
|
||||
'supplier_id',
|
||||
'warehouse_id',
|
||||
'create_time',
|
||||
'update_time',
|
||||
];
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
|
@ -18,7 +18,11 @@ class WarehouseProductStorege extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'warehouse_product_storege';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public $ignoreLogFields = [
|
||||
'price',
|
||||
'total_price',
|
||||
'update_time',
|
||||
];
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
|
@ -20,8 +20,6 @@ use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\store\service\AdminTokenService;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\service\FileService;
|
||||
use app\MyBusinessException;
|
||||
use think\facade\Db;
|
||||
use Webman\Config;
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,6 @@ use app\common\model\store_product\StoreProduct;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||
use app\MyBusinessException;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user