Merge pull request 'dev' (#423) from dev into main

Reviewed-on: #423
This commit is contained in:
mkm 2025-01-04 10:53:37 +08:00
commit 59523fc637
104 changed files with 402 additions and 1134 deletions

View File

@ -130,83 +130,5 @@ class StoreProductController extends BaseAdminController
public function import()
{
return $this->fail('接口已关闭');
$product_arr = $this->request->post('product_arr');
$store_arr = $this->request->post('store_arr');
$stock_type = $this->request->post('stock_type', 1);
$warehouse_id = $this->request->post('warehouse_id');
$count = count($store_arr);
foreach ($product_arr as $key => $arr) {
$stock = bcmul($arr['stock'], $count);
$nums = WarehouseProductStorege::where('warehouse_id', $warehouse_id)->where('product_id', $arr['id'])->value('nums');
if ($nums < $stock) {
return $this->fail('商品库存不足');
}
}
if ($count == 1) {
$store_id = $store_arr[0];
foreach ($product_arr as $key => $arr) {
$data = [
'warehouse_id' => $warehouse_id,
'product_id' => $arr['id'],
'store_id' => $store_id,
'financial_pm' => 0,
'batch' => 1,
'nums' => $arr['stock'],
'status' => 1,
'admin_id' => $this->adminId,
];
if ($arr['stock'] == 0) {
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
} else {
WarehouseProductLogic::add($data);
$find = StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->find();
if ($find) {
StoreBranchProduct::where('id', $find['id'])->inc('stock', $arr['stock'])->update();
} else {
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
}
}
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
}
} else {
foreach ($product_arr as $key => $arr) {
foreach ($store_arr as $k => $store_id) {
$data = [
'warehouse_id' => $warehouse_id,
'product_id' => $arr['id'],
'store_id' => $store_id,
'financial_pm' => 0,
'batch' => 1,
'nums' => $arr['stock'],
'status' => 1,
'admin_id' => $this->adminId,
];
if ($arr['stock'] == 0) {
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
} else {
WarehouseProductLogic::add($data);
$find = StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->find();
if ($find) {
StoreBranchProduct::where('id', $find['id'])->inc('stock', $arr['stock'])->update();
} else {
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
}
}
// $find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
}
}
}
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
}
}

View File

@ -82,14 +82,22 @@ class InventoryTransferLogic extends BaseLogic
'two_id' => $params['two_id']
]);
if($params['one_type']==1){
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update();
$find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->find();
$find->save(['stock' =>bcsub( $find['stock'],$params['nums'],2)]);
SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], -1, Request()->url());
} elseif ($params['one_type'] == 2) {
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update();
$find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->find();
$find->save(['nums' =>bcsub( $find['nums'],$params['nums'],2)]);
SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], -1, Request()->url());
}
if($params['two_type']==1){
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update();
$find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->find();
$find->save(['stock' =>bcadd( $find['stock'],$params['nums'],2)]);
SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], 1, Request()->url());
} elseif ($params['two_type'] == 2) {
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update();
$find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->find();
$find->save(['nums' =>bcadd( $find['nums'],$params['nums'],2)]);
SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], 1, Request()->url());
}
Db::commit();
return true;

View File

@ -271,10 +271,13 @@ class WarehouseLogic extends BaseLogic
{
if ($parmas['type'] == 1) {
$res = StoreProduct::where('id', $parmas['id'])->update(['stock' => 0]);
SqlChannelLog('StoreProduct', $parmas['id'], 0, 0, Request()->url());
} elseif ($parmas['type'] == 2) {
$res = StoreBranchProduct::where('id', $parmas['id'])->update(['stock' => 0]);
SqlChannelLog('StoreBranchProduct', $parmas['id'], 0, 0, Request()->url());
} elseif ($parmas['type'] == 3) {
$res = WarehouseProductStorege::where('id', $parmas['id'])->update(['nums' => 0]);
SqlChannelLog('WarehouseProductStorege', $parmas['id'], 0, 0, Request()->url());
}
return $res;
}

View File

@ -88,6 +88,7 @@ class StoreBranchProductLogic extends BaseLogic
$branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2);
StoreBranchProduct::update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=> $params['id']]);
SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], 1, Request()->url());
StoreProduct::update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=> $params['product_id']]);
} else {
@ -95,6 +96,7 @@ class StoreBranchProductLogic extends BaseLogic
$stock = bcsub($find['stock'], $params['nums'], 2);
StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=>$params['id']]);
SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], -1, Request()->url());
StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=>$params['product_id']]);
}

View File

@ -70,11 +70,13 @@ class SystemStoreStorageLogic extends BaseLogic
$branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find();
if($branch_product){
$branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]);
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url());
}else{
$storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty();
$storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct);
$storeBranchProduct->stock = $find['nums'];
$storeBranchProduct->save();
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url());
}
}else{
$find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'确认时间:'.date('Y-m-d H:i:s',time())]);
@ -136,6 +138,7 @@ class SystemStoreStorageLogic extends BaseLogic
$storage->status = 1;
$storage->staff_id = $params['staff_id'];
$storage->save();
SqlChannelLog('StoreBranchProduct', $storage['id'], $storage['nums'], 1,Request()->url());
Db::commit();
return true;
} catch (\Exception $e) {

View File

@ -37,7 +37,6 @@ class WarehouseProductLogic extends BaseLogic
{
// Db::startTrans();
try {
$before_nums = 0;
$after_nums = 0;
if ($params['order_type'] != 6) {
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
@ -48,23 +47,24 @@ class WarehouseProductLogic extends BaseLogic
if (!$storeProduct) {
throw new BusinessException('商品不存在');
}
if($storeProduct['purchase']<=0){
$total_price=0;
}else{
if ($storeProduct['purchase'] <= 0) {
$total_price = 0;
} else {
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
}
WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]);
SqlChannelLog('WarehouseProductStorege', $storege['id'], $after_nums, 1, Request()->url());
}
$before_nums = $storege['nums'];
} else {
$after_nums = $params['nums'];
$storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty();
if (!$storeProduct) {
throw new BusinessException('商品不存在');
}
if($storeProduct['purchase']<=0){
$total_price=0;
}else{
if ($storeProduct['purchase'] <= 0) {
$total_price = 0;
} else {
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
}
$data = [
@ -77,6 +77,8 @@ class WarehouseProductLogic extends BaseLogic
$data['nums'] = -$params['nums'];
}
$storege = WarehouseProductStorege::create($data);
SqlChannelLog('WarehouseProductStorege', $storege['id'], -$params['nums'], 1, Request()->url());
}
}
$batch_count = WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm'], 'store_id' => $params['store_id']])->count();
@ -89,8 +91,8 @@ class WarehouseProductLogic extends BaseLogic
'financial_pm' => $params['financial_pm'],
'batch' => $batch_count + 1,
'nums' => $params['nums'],
'before_nums' => $before_nums,
'after_nums' => $after_nums,
'before_nums' => 0,
'after_nums' => 0,
'price' => $params['price'] ?? '',
'purchase' => $params['purchase'] ?? '',
// 'cost' => $params['cost'] ?? '',
@ -108,6 +110,8 @@ class WarehouseProductLogic extends BaseLogic
$data['expiration_date'] = strtotime($params['expiration_date']);
}
$res = WarehouseProduct::create($data);
SqlChannelLog('WarehouseProduct', $res['id'], $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url());
return $res;
} catch (\Throwable $e) {
throw new BusinessException($e->getMessage());
@ -125,7 +129,7 @@ class WarehouseProductLogic extends BaseLogic
if ($params['order_type'] != 6) {
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
if ($storege) {
if(in_array($params['order_type'],[1,4])){
if (in_array($params['order_type'], [1, 4])) {
SystemStoreStorage::create([
'store_id' => $params['store_id'],
'admin_id' => $params['admin_id'],
@ -140,6 +144,7 @@ class WarehouseProductLogic extends BaseLogic
$after_nums = bcsub($storege['nums'], $params['nums']);
$total_price = bcmul($after_nums, $params['purchase'], 2);
WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]);
SqlChannelLog('WarehouseProductStorege', $storege['id'], bcsub($storege['nums'], $params['nums']), -1, Request()->url());
} else {
$data = [
'warehouse_id' => $params['warehouse_id'],
@ -148,6 +153,7 @@ class WarehouseProductLogic extends BaseLogic
'total_price' => 0
];
$storege = WarehouseProductStorege::create($data);
SqlChannelLog('WarehouseProductStorege', $storege->id, -$params['nums'], -1, Request()->url());
}
} else {
$storege['nums'] = 0;
@ -176,6 +182,8 @@ class WarehouseProductLogic extends BaseLogic
'mark' => $params['mark'] ?? '',
];
$res = WarehouseProduct::create($data);
SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url());
Db::commit();
return $res;
} catch (\Throwable $e) {
@ -195,42 +203,20 @@ class WarehouseProductLogic extends BaseLogic
{
Db::startTrans();
try {
$before_nums = 0;
$after_nums = 0;
$find = WarehouseOrder::where('id', $params['oid'])->find();
if ($find) {
$res = WarehouseProduct::where('id', $params['id'])->find();
if ($find['financial_pm'] == 1) {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $params['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
$before_nums = $warehouseProductStorege['nums'];
$after_nums = $warehouseProductStorege['nums'] + $params['nums'];
} else {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $params['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
$before_nums = $warehouseProductStorege['nums'];
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
}
self::decStock($res);
self::incStock($res, $params);
$datas = [
'nums' => $params['nums'],
'before_nums' => $before_nums,
'after_nums' => $after_nums,
'total_price' => $params['total_price'],
];
if($find['financial_pm']==1){
if ($find['financial_pm'] == 1) {
$datas['supplier_id'] = $params['supplier_id'];
$datas['pay_type'] = $params['pay_type'];
$datas['purchase'] = $params['purchase'];
}else{
} else {
$datas['price'] = $params['price'];
}
if (isset($params['manufacture']) && $params['manufacture'] != '') {
@ -239,7 +225,7 @@ class WarehouseProductLogic extends BaseLogic
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
$datas['expiration_date'] = strtotime($params['expiration_date']);
}
WarehouseProduct::where('id', $params['id'])->update($datas);
$res->save($datas);
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
if ($finds) {
WarehouseOrder::where('id', $params['oid'])->update([
@ -269,14 +255,11 @@ class WarehouseProductLogic extends BaseLogic
if ($res) {
$res->delete();
if ($res['financial_pm'] == 1) {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
$find = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->save();
SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], -1, Request()->url());
} elseif ($res['financial_pm'] == 0) {
$stock = StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->value('stock');
if ($stock < $res['nums']) {
throw new BusinessException('商品库存不足,无法退回');
}
StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->dec('stock', $res['nums'])->update();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
$find = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->save();
SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], 1, Request()->url());
}
$find = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
if ($find) {
@ -321,44 +304,15 @@ class WarehouseProductLogic extends BaseLogic
{
Db::startTrans();
try {
$res = WarehouseProduct::where('id',$params['id'])->find();
$res = WarehouseProduct::where('id', $params['id'])->find();
if ($res) {
if ($res['financial_pm'] == 1) {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $params['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
$before_nums = $warehouseProductStorege['nums'];
$after_nums = $warehouseProductStorege['nums'] + $params['nums'];
} else {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $params['nums'])->update();
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
$before_nums = $warehouseProductStorege['nums'];
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
}
if($res['financial_pm']==1){
$datas=[
'nums' => $params['nums'],
'before_nums' => $before_nums,
'after_nums' => $after_nums,
'total_price' => bcmul($params['nums'], $res['purchase'], 2),
];
}else{
$datas=[
'nums' => $params['nums'],
'before_nums' => $before_nums,
'after_nums' => $after_nums,
'total_price' => bcmul($params['nums'], $res['price'], 2),
];
}
WarehouseProduct::where('id', $params['id'])->update($datas);
self::decStock($res);
self::incStock($res, $params);
$datas = [
'nums' => $params['nums'],
'total_price' => bcmul($params['nums'], $res['price'], 2),
];
$res->save($datas);
$finds = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums')->find();
if ($finds) {
WarehouseOrder::where('id', $res['oid'])->update([
@ -388,4 +342,35 @@ class WarehouseProductLogic extends BaseLogic
}
return $data;
}
//减少
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());
$res2 = StoreBranchProduct::where('id', $res['id'])
->dec('stock', $res['nums'])
->update();
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], -1, Request()->url());
}
//增加
private static function incStock($res, $params)
{
$res = 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());
$res2 = StoreBranchProduct::where('id', $res['id'])
->inc('stock', $params['nums'])
->save();
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], 1, Request()->url());
}
}

View File

@ -114,9 +114,13 @@ class WarehouseProductReturnLogic extends BaseLogic
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
BeforehandOrder::update(['pay_price' => $total_price], ['id' => $params['bhoid']]);
}
WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->inc('nums', $params['nums'])->update();
$res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find();
$res->save(['nums' =>bcadd( $res['nums'],$params['nums'],2)]);
SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], 1, Request()->url());
} elseif ($params['financial_pm'] == 0 && $params['return_type'] == 2) {
WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->dec('nums', $params['nums'])->update();
$res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find();
$res->save(['nums' =>bcsub( $res['nums'],$params['nums'],2)]);
SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], -1, Request()->url());
}
}

View File

@ -44,6 +44,7 @@ class WarehouseProductStoregeLogic extends BaseLogic
$find=WarehouseProductStorege::where('id',$params['id'])->find();
if($find){
$find->save(['nums'=>$params['nums']]);
SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url());
}
Db::commit();
return true;

View File

@ -11,6 +11,7 @@ use app\admin\logic\tools\GeneratorLogic;
use app\api\lists\purchase_product_offer\PurchaseProductOfferListsTwo;
use app\api\logic\order\OrderLogic as OrderOrderLogic;
use app\common\cache\ExportCache;
use app\common\logic\ChangeLogLogic;
use app\common\logic\PayNotifyLogic;
use app\common\logic\store_order\StoreOrderLogic;
use app\common\model\beforehand_order_record\BeforehandOrderRecord;
@ -50,14 +51,15 @@ use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\IOFactory;
use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Style\Font;
use Chance\Log\facades\OperationLog;
class IndexController extends BaseApiController
{
public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer'];
public $notNeedLogin = ['aa','index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer'];
public function index()
{
d(1);
d(1);
$arr = Db::name('ceshi_copy')->select();
foreach ($arr as $k => $v) {
$data = [
@ -301,8 +303,8 @@ class IndexController extends BaseApiController
if ($find) {
Db::name('wps_product')->where('id', $find['id'])->update($arr);
} else {
$arr['product_id']=$data['product_id'];
$arr['name']=$data['name'];
$arr['product_id'] = $data['product_id'];
$arr['name'] = $data['name'];
Db::name('wps_product')->insert($arr);
}
}
@ -310,4 +312,53 @@ class IndexController extends BaseApiController
return $this->fail('时间不能为空');
}
}
public function aa(){
$boyd = $this->request->post();
// 计算body的MD5值
$microtime = microtime(true);
// 将秒和微秒数转换为毫秒级时间戳
$millisecondTimestamp = number_format($microtime * 1000, 0, '', '');
// 输出结果
$time = $millisecondTimestamp;
// 需要签名的数据
$data = [
'appid' => 'e328e0d083784b8cbbd8a45e2a13b430',
'timestamp' => $time,
'version' => "1.0.0"
];
$md5='{}';
if($boyd){
$md5 = md5(json_encode($boyd,true));
$data['md5']=$md5;
}else{
$md5 = md5($md5);
$data['md5']=$md5;
}
// 获取token
$token=$this->request->header('token');
if($token){
$data['token']=$token;
}
// 按字母顺序排序
ksort($data);
// 转换为JSON字符串
$jsonString = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
// RSA私钥
$privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKYtaukWByNHG8VZsvfIwEeJUKa0t2RaNNMp/IlgWj/29aK+nCZZC+zROc8xjQAAHKbQgwXeFzizzDb98Q8Qavgo+8zuNi2V45sj12+7yC1tfX4zRkm4Yqri+YifJLNXxoh46dvx9CsNrKT/e5we6irxaWJoXxGxeZ4pA1JpcrwHAgMBAAECgYBnoELe/yGMWjdzJbB42/MrqPFmQ6NpLOdsFu6oLDGbWcFrrzlooHbTQtWt4tRuf6NeUwChlBEfBt/+GvVL040gF2T2ylsMi3biktZDSlT/+DI7H5S1x4aBplIBc4yAp/vrFTyWmxdULEksap2BUf5fEqG/CVcWMI2zszORQi4QAQJBAO4z9FsOyPZ0ycrCFmQD9AYPzmnBvgTg/uU0xGY7yus8zIt29TL1uE77/ksmGxJQXXcRUt2ytPVm9YqXnXS/EgcCQQCyl9l7Kdr/eifOcRd9wAAXwsHKkjfJR1Vd1igv5wCZqSkXK2qxxvQDPE98HugosNkFxuyedFbfrbSQpPUjnIYBAkAyDXK8K4go2XOJim0ACSCeoXWjHVXbWpfU+9iFDu1drsHgUFfHpIBdAHB3xAMOPxrUqSw7b5C8vCy+OYuZe4jDAkAdpsqMAWID4sMzKmGtFjCtwT8to+MxPu+0ebcIZQEbghN5blLzm0WuN9g2kmcXQm114RYuJMC7uHpvPYQZ2oYBAkBBzytKuG5EhbsI5flwxYGTDvQtY1TGvsYVrt0anirPa9xVq+RYC2Jr9zk0j8s13QhXoVwAO6seO7cYN9n8J65t";
// 解码私钥
$privateKeyPem = "-----BEGIN PRIVATE KEY-----\n" . wordwrap($privateKey, 64, "\n", true) . "\n-----END PRIVATE KEY-----";
// 获取私钥资源
$privateKeyResource = openssl_pkey_get_private($privateKeyPem);
openssl_sign($jsonString, $signature, $privateKeyResource, OPENSSL_ALGO_SHA1);
// 将签名进行Base64编码
$signatureString = base64_encode($signature);
d($md5,$time,$signatureString);
}
}

View File

@ -1,850 +0,0 @@
<?php
namespace app\common\logic;
use app\admin\logic\user_ship\UserShipLogic;
use app\api\logic\order\OrderLogic;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\enum\user\UserShipEnum;
use app\common\enum\YesNoEnum;
use app\common\logic\user_product_storage\UserProductStorageLogic;
use app\common\model\Config;
use app\common\model\dict\DictType;
use app\common\model\finance\CapitalFlow;
use app\common\model\finance\PayNotifyLog;
use app\common\model\pay\PayNotify;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product_log\StoreProductLog;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\model\user\UserRecharge;
use app\common\model\user_ship\UserShip;
use app\common\model\user_sign\UserSign;
use app\common\model\vip_flow\VipFlow;
use app\common\service\Curl;
use app\common\service\PushService;
use support\Log;
use think\facade\Db;
use Webman\RedisQueue\Redis;
/**
* 支付成功后处理订单状态
* Class PayNotifyLogic
* @package app\api\logic
*/
class DemoPayNotifyLogic extends BaseLogic
{
public static function handle($action, $orderSn, $extra = [], $type = 'wechat')
{
Db::startTrans();
try {
self::$action($orderSn, $extra, $type);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
throw new \Exception($e->getMessage());
}
}
/**
* 余额支付
* @param $orderSn
* @param $extra
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function balancePay($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $order['uid'])->find();
if ($user['now_money'] < $order['pay_price']) {
throw new \Exception('余额不足');
}
// $order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
if ($order['is_storage'] == 1) {
$order->status = 2;
UserProductStorageLogic::add($order);
}
// 减去余额
$user->now_money = bcsub($user['now_money'], $order['pay_price'], 2);
$user->save();
if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) {
$oldUser = User::where('id', $order['spread_uid'])->value('purchase_funds');
if ($oldUser < $order['pay_price']) {
$order['pay_price'] = $oldUser;
}
}
// self::addUserSing($order);
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
// self::descStock($order['id']);
}
self::afterPay($order);
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
$checkArr = [
'cart_id' => $order['cart_id'],
'store_id' => $order['store_id'],
];
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
}
if ($extra && $extra['store_id'] && $order['reservation'] !=1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::writeOff($params);
}
if(in_array($order['shipping_type'],[1,2])){
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
}
return true;
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
}
/**
* 礼品券支付
* @param $orderSn
* @param $extra
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function gift_pay($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $order['uid'])->find();
if ($user['integral'] < $order['pay_price']) {
throw new \Exception('礼品券不足');
}
$order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
// 减去礼品券
$user->integral = bcsub($user['integral'], $order['pay_price'], 2);
$user->save();
//入礼品券表扣款记录
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '订单扣除兑换券',
'title' => 5,
'financial_pm' => 0,
'status' => 1,
'store_id' => $order['store_id'],
'number' => $order['pay_price'],
'user_ship' => $user['user_ship'],
];
UserSign::create($sing);
if ($extra && $extra['store_id']) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::lessWriteOff($params);
}
self::dealProductLog($order);
}
/**
* 采购款支付
* @param $orderSn
* @param $extra
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function purchase_funds($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
$user = User::where('id', $order['uid'])->find();
if ($user['purchase_funds'] < $order['pay_price']) {
throw new \Exception('采购款不足');
}
$order->money = $order['pay_price'];
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
if ($order['is_storage'] == 1) {
$order->status = 2;
UserProductStorageLogic::add($order);
}
// 减去采购款
$user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2);
$user->save();
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'], '', 1, $order['store_id']);
// if ($user['user_ship'] == 1) {
// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
// }
// self::addUserSing($order);
self::afterPay($order);
if ($extra && $extra['store_id'] && $order['reservation'] !=1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::writeOff($params);
}
self::dealProductLog($order);
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
$checkArr = [
'cart_id' => $order['cart_id'],
'store_id' => $order['store_id'],
];
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
}
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
if(in_array($order['shipping_type'],[1,2])){
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
}
}
/**
* @notes 微信通用回调
* @param $orderSn
* @param array $extra
* @date 2023/2/27 15:28
*/
public static function wechat_common($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true;
}
$order->status = 1;
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
if ($order['is_storage'] == 1) {
$order->status = 2;
UserProductStorageLogic::add($order);
}
if ($order->pay_type != 10) {
$order->pay_price = bcdiv($extra['amount']['payer_total'], 100, 2);
} else {
$extra['transaction_id'] = time();
}
$user = User::where('id', $order['uid'])->find();
if ($order->pay_type == OrderEnum::CASHIER_ORDER_PAY || $order->pay_type == OrderEnum::CASHIER_ORDER_ALI_PAY) { //收银台支付
$order->status = 2;
} else {
$capitalFlowDao = new CapitalFlowLogic($user);
//微信支付和用户余额无关
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']);
}
$order->save();
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
$checkArr = [
'cart_id' => $order['cart_id'],
'store_id' => $order['store_id'],
];
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
}
self::afterPay($order, $extra['transaction_id']);
// self::addUserSing($order);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
}
return true;
}
//退款
public static function refund($orderSn, $extra = [])
{
//更新状态
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
//充值
$orderRe = UserRecharge::where('order_id', $orderSn)->findOrEmpty();
if ($orderRe->isEmpty() || $orderRe->status == -1) {
return true;
}
$orderRe->status = -1;
$orderRe->refund_price = $orderRe->price;
$orderRe->refund_time = time();
$orderRe->remarks = '';
$orderRe->save();
$purchase_funds = User::where('id', $orderRe['uid'])->value('purchase_funds');
$user = User::where('id', $orderRe['uid'])->find();
$capitalFlowDao = new CapitalFlowLogic($user);
if ($purchase_funds >= $orderRe['price']) {
User::where('id', $orderRe['uid'])->dec('purchase_funds', $orderRe['refund_price'])->update();
$capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']);
} else {
User::where('id', $orderRe['uid'])->dec('purchase_funds', $purchase_funds)->update();
$capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']);
}
//退还 充值得兑换券
UserSignLogic::RefundRecharge($orderRe);
return true;
}
$order->status = OrderEnum::REFUND_PAY;
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
$order->refund_price = bcdiv($extra['amount']['refund'], 100, 2);
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
//日志记录
//加用户余额,采购款, 日志记录 加数量
$user = User::where('id', $order['uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user);
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
//对应比例得退礼品券逻辑
$discount = self::getDiscount($user->user_ship);
$total_price = bcmul($order->refund_price, $discount, 2);
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付
$user->now_money = bcadd($user->now_money, $deal_money, 2);
$user->save();
//增加数量
self::addStock($order['id']);
//退款
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
}
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
$user->save();
//增加数量
self::addStock($order['id']);
//退款
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
}
UserSignLogic::RefundOrder($order);
return true;
}
//积分
UserSignLogic::RefundOrder($order);
//微信日志 user_order_refund
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
//处理财务流水退还
(new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']);
self::addStock($order['id']); //微信
return true;
// self::afterPay($order,$extra['transaction_id']);
}
/**
* 现金退款相关
* @param $orderSn
* @param $extra
* @return true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function cash_refund($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
return true;
}
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
$order->refund_price = $order->pay_price;
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
//日志记录
$model = new StoreCashFinanceFlow();
$model->store_id = $order['store_id'] ?? 0;
$model->cash_price = $order->pay_price;
$model->receivable = $order->pay_price;
$model->remark = '退款';
$model->type = 1;
$model->status = YesNoEnum::YES;
$model->save();
//增加数量
self::addStock($order['id']);
return true;
}
/**
* 充值现金退款相关
* @param $orderId
* @param $extra
* @return true
*/
public static function recharge_cash_refund($orderId, $extra = [])
{
$order = UserRecharge::where('id', $orderId)->findOrEmpty();
if ($order->isEmpty() || $order->status == -1) {
return true;
}
$order->status = -1;
$order->refund_price = $order->price;
$order->refund_time = time();
$order->remarks = '';
$order->save();
return true;
}
/**
* 充值
*/
public static function recharge($orderSn, $extra = [], $type = 'wechat')
{
$order = UserRecharge::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true;
}
if ($type == 'wechat') {
$price = bcdiv($extra['amount']['payer_total'], 100, 2);
} else {
$price = $extra['buyer_pay_amount'];
}
$order->price = $price;
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
$order->save();
$uid = $order->uid;
$user = User::where('id', $uid)->findOrEmpty();
//check store_id
if(empty($user->store_id)){
$user->store_id = $order['store_id'];
}
//用户的财务add
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price, [], 1);
if ($user->isEmpty()) {
return true;
}
bcscale(2);
UserSignLogic::dealRechargeFrozen($user, $order, $order['user_ship']);
//更新等级
$user->user_ship = $order['user_ship'];
$user->purchase_funds = bcadd($user->purchase_funds, $price, 2);
$user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2);
$user->save();
if ($order['other_uid'] > 0) {
$uid = $order['other_uid'];
}
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
if (!empty($extra['payer']['openid'])) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
}
return true;
}
/**
* 现金支付
*/
public static function cash_pay($orderSn,$extra =[])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true;
}
$order->paid = 1;
$order->pay_time = strtotime($order['create_time']);
$order->status = 2;
if ($order['reservation'] ==1) {
$order->status = 1;
}
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
self::afterPay($order);
if ($order['is_storage'] == 1) {
UserProductStorageLogic::add($order);
}
$cashFlowLogic = new CashFlowLogic();
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
if ($extra && $extra['store_id'] && $order['reservation'] !=1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $extra['store_id'],
'staff_id' => $extra['staff_id']
];
OrderLogic::writeOff($params);
}
// Redis::send('push-platform-print', ['id' => $order['id']]);
return true;
}
/**
* @notes 阿里回调
* @param $orderSn
* @param array $extra
* @author 段誉
* @date 2023/2/27 15:28
*/
public static function alipay_cashier($orderSn, $extra = [])
{
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true;
}
if ($order->pay_type != 10) {
$order->money = $extra['buyer_pay_amount'];
$order->paid = 1;
$order->pay_time = bcadd(strtotime($order['create_time']),rand(1,300));
$order->status = 1;
$order->save();
} else {
$extra['transaction_id'] = time();
}
if ($order->pay_type == 9) {
$order->status = 2;
self::afterPay($order);
UserProductStorageLogic::add($order);
}
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// if ($order->pay_type == 9) {
// $extra['create_time'] = $order['create_time'];
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
// Redis::send('push-platform-print', ['id' => $order['id']]);
// }
// else {
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
// }
return true;
}
/**
* 支付后逻辑
* @param $order
* @return void
*/
public static function afterPay($order, $transaction_id = 0)
{
$financeLogic = new StoreFinanceFlowLogic();
$off_activity = Config::where('name', 'off_activity')->value('value');
$village_uid = 0;
$brigade_uid = 0;
$user_ship = 0;
$order['dealVipAmount'] = 0;
try {
Redis::send('order_wetcha_push_send', ['order' => $order]);
} catch (\Exception $e) {
Log::error('订单推送失败:' . $e->getMessage());
// 异常处理代码,例如记录日志或发送通知等。
}
if ($order['uid'] > 0) {
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
//用户下单该用户等级为1得时候才处理冻结金额
$user = User::where('id', $order['uid'])->find();
$user_ship = $user['user_ship'];
}
//积分写入
if(isset($user) && $user['user_ship']==0){
UserSignLogic::OrderWrite($order);
}
if ($off_activity == 1) {
//-----活动价结算更改
$financeLogic->order = $order;
$financeLogic->user = ['uid' => $order['uid']];
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->save();
return false;
}
}
/**
* 回调日志
* @param $order
* @param $extra
* @return void
*/
public static function notifyLog($order, $extra)
{
$data = [
'pay_type' => 'wechat',
'type' => OrderEnum::PAY,
'amount' => $extra['amount']['payer_total'], //分
'order_sn' => $order,
'out_trade_no' => $extra['transaction_id'],
'attach' => $extra['attach'],
'create_time' => date('Y-m-d H:i:s', time()),
];
PayNotify::create($data);
}
/**
* 冻结金额
* @param $oid
* @return int|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function dealFrozenPrice($oid)
{
$detail = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
$total_vip = 0;
foreach ($detail as $value) {
$total_vip += $value['cart_info']['vip_frozen_price'];
}
return $total_vip;
}
/**
* 处理用户为vip1时得冻结资金
* @param $order
* @param $pay_type
* @param $transaction_id
* @return true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function dealVipAmount($order, $pay_type = 1, $transaction_id = 0)
{
$total_vip = self::dealFrozenPrice($order['id']);
$data = [
'order_id' => $order['id'],
'transaction_id' => $transaction_id ?? 0,
'order_sn' => $order['order_id'],
'user_id' => $order['uid'],
'number' => $total_vip,
'all' => $order['pay_price'],
'pay_type' => $pay_type ?? 1,
'status' => 0,
'store_id' => $order['store_id'],
'staff_id' => $order['staff_id'],
'create_time' => time()
];
Db::name('vip_flow')->insert($data);
return $total_vip;
}
/**
* 商品统计逻辑
* @param $order
* @return true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function dealProductLog($order)
{
$store_id = $order['store_id'];
$cart_id = $order['cart_id'];
$uid = $order['uid'];
if ($uid && $cart_id && $store_id) {
$cart_id = explode(',', $cart_id);
$productLog = StoreProductLog::where([
'uid' => $uid
])->whereIn('cart_id', $cart_id)
->select()->toArray();
foreach ($productLog as &$value) {
$value['pay_uid'] = $uid;
$value['oid'] = $order['id'];
$value['store_id'] = $store_id;
$cart_info = StoreOrderCartInfo::where([
'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'oid' => $value['oid']
])->find();
$value['order_num'] = $cart_info['cart_num'] ?? 1;
$value['pay_num'] = $cart_info['cart_num'] ?? 1;
$value['pay_price'] = $cart_info['price'] ?? 0;
$value['cost_price'] = $cart_info['cart_info']['cost'] ?? 0;
$value['update_time'] = time();
unset($value['create_time'], $value['delete_time']);
}
(new StoreProductLog())->saveAll($productLog);
}
return true;
}
public static function descSwap($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'swap' => $StoreBranchProduct['swap'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 扣库存
* @param $oid
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function descStock($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
if ($StoreBranchProduct) {
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 加库存
* @param $oid
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function addStock($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
if ($StoreBranchProduct) {
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
// 'sales' => ['inc', $v['cart_num']]
// 'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 处理商品缺失新增到缺失列表
* @param $cart_id //购物车ids
* @param $uid //用户id
* @param $oid //订单id
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function dealGoodsLeft($cart_id, $uid, $oid)
{
if (is_array($cart_id)) {
$cart_id['cart_id'] = $cart_id;
} else {
$cart_id['cart_id'] = explode(',', $cart_id);
}
$data = OrderLogic::checkLeft($cart_id, $uid, 1);
$format = $data['detail'];
foreach ($format as &$value) {
$value['oid'] = $oid;
$value['create_time'] = time();
}
Db::name('store_product_miss')->insertAll($format);
}
/**
* 会员等级对应得折扣比例
* @param $level
* @return float|mixed
*/
public static function getDiscount($level)
{
switch ($level) {
case 0: //普通
return Config::where('name', 'ordinary_member')->value('value') ?? 0.1;
case 1: //vip
return Config::where('name', 'vip_member')->value('value') ?? 0.1;
case 4: //商户
return Config::where('name', 'merchant')->value('value') ?? 0.1;
default:
return 0.1;
}
}
}

View File

@ -34,6 +34,7 @@ use app\common\model\vip_flow\VipFlow;
use app\common\service\Curl;
use app\common\service\PushService;
use app\common\service\xpyun\XpsdkPrintApi;
use app\Request;
use support\exception\BusinessException;
use support\Log;
use think\facade\Db;
@ -627,12 +628,14 @@ class PayNotifyLogic extends BaseLogic
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
], ['id' => $branchProduct['id']]);
SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url());
} else {
StoreProductLogic::ordinary(['id' => $v['product_id']], $v['store_id'], 0, $storeProduct);
StoreBranchProduct::update([
'stock' => -$v['cart_num'],
'sales' => $v['cart_num']
], ['product_id' => $v['product_id'],'store_id'=>$v['store_id']]);
SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url());
}
}
} catch (\Throwable $e) {
@ -874,6 +877,7 @@ class PayNotifyLogic extends BaseLogic
}
(new StoreBranchProduct())->saveAll($updateData);
SqlChannelLog('StoreBranchProduct',0,0,1,Request()->url());
}

View File

@ -215,6 +215,7 @@ class StoreOrderLogic extends BaseLogic
(new StoreOrderCartInfo())->saveAll($goods_list);
$where = ['is_pay' => 0];
(new StoreBranchProduct())->saveAll($updateData);
SqlChannelLog('StoreBranchProduct', 0, $v['cart_num'], -1, Request()->url());
(new StoreProduct())->saveAll($updateDataTwo);
Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]);
Db::commit();

View File

@ -18,7 +18,9 @@ class ActivityZone extends BaseModel
use SoftDelete;
protected $name = 'activity_zone';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function product()
{
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->bind(['store_name', 'unit']);

View File

@ -15,5 +15,6 @@ class ActivityZoneForm extends BaseModel
use SoftDelete;
protected $name = 'activity_zone_form';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -6,5 +6,6 @@ namespace app\common\model;
class Config extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -7,5 +7,6 @@ namespace app\common\model;
class OperationLog extends BaseModel
{
// protected $json = ['params'];
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class AppUpdate extends BaseModel
use SoftDelete;
protected $name = 'app_update';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,7 +12,8 @@ use think\model\concern\SoftDelete;
class Admin extends BaseModel
{
use SoftDelete;
// 不生成该表的日志
public $doNotRecordLog = true;
protected $deleteTime = 'delete_time';
protected $append = [

View File

@ -18,6 +18,8 @@ use app\common\model\BaseModel;
class AdminDept extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 删除用户关联部门
* @param $adminId
@ -29,4 +31,4 @@ class AdminDept extends BaseModel
{
return self::where(['admin_id' => $adminId])->delete();
}
}
}

View File

@ -18,6 +18,8 @@ use app\common\model\BaseModel;
class AdminJobs extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 删除用户关联岗位
* @param $adminId
@ -29,4 +31,4 @@ class AdminJobs extends BaseModel
{
return self::where(['admin_id' => $adminId])->delete();
}
}
}

View File

@ -19,6 +19,8 @@ use app\common\model\BaseModel;
class AdminRole extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 删除用户关联角色
* @param $adminId
@ -30,5 +32,4 @@ class AdminRole extends BaseModel
{
return self::where(['admin_id' => $adminId])->delete();
}
}
}

View File

@ -18,6 +18,8 @@ use app\common\model\BaseModel;
class AdminSession extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 关联管理员表
* @return \think\model\relation\HasOne
@ -29,4 +31,4 @@ class AdminSession extends BaseModel
return $this->hasOne(Admin::class, 'id', 'admin_id')
->field('id,multipoint_login');
}
}
}

View File

@ -25,7 +25,8 @@ use app\common\model\BaseModel;
*/
class SystemMenu extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -25,7 +25,8 @@ use think\model\concern\SoftDelete;
class SystemRole extends BaseModel
{
use SoftDelete;
// 不生成该表的日志
public $doNotRecordLog = true;
protected $deleteTime = 'delete_time';
protected $name = 'system_role';

View File

@ -25,6 +25,7 @@ use app\common\model\BaseModel;
*/
class SystemRoleMenu extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -18,6 +18,7 @@ class BeforehandOrder extends BaseModel
protected $name = 'beforehand_order';
protected $deleteTime = 'delete_time';
protected $json = ['other_data'];
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class BeforehandOrderCartInfo extends BaseModel
use SoftDelete;
protected $name = 'beforehand_order_cart_info';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class BeforehandOrderRecord extends BaseModel
use SoftDelete;
protected $name = 'beforehand_order_record';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,7 +17,8 @@ class Cate extends BaseModel
use SoftDelete;
protected $name = 'store_category';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function getChildrenAttr($value)
{
if($value){

View File

@ -17,6 +17,7 @@ class DeliveryService extends BaseModel
use SoftDelete;
protected $name = 'delivery_service';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -29,7 +29,8 @@ class Dept extends BaseModel
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 状态描述
* @param $value

View File

@ -28,7 +28,8 @@ class Jobs extends BaseModel
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 状态描述
* @param $value

View File

@ -30,7 +30,8 @@ class DictData extends BaseModel
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 状态描述
* @param $value

View File

@ -29,7 +29,8 @@ class DictType extends BaseModel
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 状态描述

View File

@ -17,6 +17,7 @@ class Distribution extends BaseModel
use SoftDelete;
protected $name = 'distribution';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -21,4 +21,6 @@ class File extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -22,4 +22,6 @@ class FileCate extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -9,5 +9,6 @@ class CapitalFlow extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -6,7 +6,8 @@ use app\common\model\BaseModel;
class PayNotifyLog extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
const TYPE_ORDER = 1;
const TYPE_REFUND = 2;

View File

@ -20,7 +20,8 @@ class FinancialTransfers extends BaseModel
use SoftDelete;
protected $name = 'financial_transfers';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function store()
{

View File

@ -12,5 +12,6 @@ class GeoArea extends BaseModel
{
protected $name = 'geo_area';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,5 +12,6 @@ class GeoBrigade extends BaseModel
{
protected $name = 'geo_brigade';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,5 +12,6 @@ class GeoCity extends BaseModel
{
protected $name = 'geo_city';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,5 +12,6 @@ class GeoProvince extends BaseModel
{
protected $name = 'geo_province';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,5 +12,6 @@ class GeoStreet extends BaseModel
{
protected $name = 'geo_street';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -12,5 +12,6 @@ class GeoVillage extends BaseModel
{
protected $name = 'geo_village';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -19,7 +19,8 @@ class Merchant extends BaseModel
protected $ok = 'mer_id';
protected $name = 'merchant';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function realName()
{
return $this->hasOne(User::class,'id','uid')->bind(['mer_real_name'=>'real_name']);

View File

@ -17,6 +17,7 @@ class Cart extends BaseModel
use SoftDelete;
protected $name = 'store_cart';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -11,7 +11,8 @@ use app\common\service\FileService;
class PayConfig extends BaseModel
{
protected $name = 'dev_pay_config';
// 不生成该表的日志
public $doNotRecordLog = true;
// 设置json类型字段
protected $json = ['config'];

View File

@ -7,4 +7,6 @@ use app\common\model\BaseModel;
class PayNotify extends BaseModel
{
protected $name = 'pay_notify_log';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -22,7 +22,8 @@ use app\common\service\FileService;
class PayWay extends BaseModel
{
protected $name = 'dev_pay_way';
// 不生成该表的日志
public $doNotRecordLog = true;
public function getIconAttr($value,$data)
{
return FileService::getFileUrl($value);

View File

@ -17,6 +17,7 @@ class PurchaseOrder extends BaseModel
use SoftDelete;
protected $name = 'purchase_order';
protected $deleteTime = 'delete_time';
protected $json = ['order_arr','store_arr'];
}
protected $json = ['order_arr', 'store_arr'];
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class PurchaseOrderInfo extends BaseModel
use SoftDelete;
protected $name = 'purchase_order_info';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -18,7 +18,8 @@ class PurchaseProductOffer extends BaseModel
use SoftDelete;
protected $name = 'purchase_product_offer';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
protected $json = ['source_order_info'];
protected $jsonAssoc = true;

View File

@ -17,6 +17,7 @@ class Category extends BaseModel
use SoftDelete;
protected $name = 'category';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -19,7 +19,8 @@ class StoreBranchProductAttrValue extends BaseModel
use SoftDelete;
protected $name = 'store_branch_product_attr_value';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function attr()
{
return $this->hasOne(StoreBranchProduct::class, 'product_id', 'product_id')->bind(['image']);

View File

@ -20,5 +20,6 @@ class StoreBranchProductExchange extends BaseModel
use SoftDelete;
protected $name = 'store_branch_product_exchange';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -18,5 +18,6 @@ class StoreCashFinanceFlow extends BaseModel
protected $name = 'store_cash_finance_flow';
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -21,5 +21,6 @@ class StoreCategory extends BaseModel
protected $json = ['price_rate'];
protected $jsonAssoc = true;
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class StoreExtract extends BaseModel
use SoftDelete;
protected $name = 'store_extract';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -21,7 +21,8 @@ class StoreFinanceFlow extends BaseModel
use SoftDelete;
protected $name = 'store_finance_flow';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function store()
{
return $this->hasOne(SystemStore::class, 'id','store_id')

View File

@ -18,4 +18,6 @@ class StoreFinanceFlowProduct extends BaseModel
use SoftDelete;
protected $name = 'store_finance_flow_product';
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -23,6 +23,8 @@ class StoreOrder extends BaseModel
use SoftDelete;
protected $name = 'store_order';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
// public function getPayTimeAttr($value)
// {
// return $value?date('Y-m-d H:i:s', $value):'';
@ -40,9 +42,9 @@ class StoreOrder extends BaseModel
}
public function getSystemStoreNameTextAttr($value, $data)
{
if($data['store_id']>0){
$name = SystemStore::where('id',$data['store_id'])->value('name');
}else{
if ($data['store_id'] > 0) {
$name = SystemStore::where('id', $data['store_id'])->value('name');
} else {
$name = '无';
}
return $name;
@ -50,9 +52,9 @@ class StoreOrder extends BaseModel
public function getStatusNameTextAttr($value, $data)
{
if($data['status']==-1){
if ($data['status'] == -1) {
$status = OrderEnum::refundStatus($data['refund_status']) ?? '';
}else{
} else {
$status = OrderEnum::getOrderType($data['status']) ?? '';
}
return $status;
@ -72,7 +74,7 @@ class StoreOrder extends BaseModel
{
return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']);
}
/**
/**
* 总销售额
* @param $time
* @return float
@ -92,7 +94,7 @@ class StoreOrder extends BaseModel
{
return $this->where($where)->where('paid', 1)->where('refund_status', '=', 0)->where(function ($query) use ($time) {
if ($time[0] == $time[1]) {
$query->whereDay('create_time', date('Y-m-d',$time[0]));
$query->whereDay('create_time', date('Y-m-d', $time[0]));
} else {
$time[1] = $time[1] + 86400;
$query->whereTime('create_time', 'between', $time);
@ -105,10 +107,10 @@ class StoreOrder extends BaseModel
{
try {
$where = $data->getWhere();
if($data){
if ($data) {
$find = self::where($where)->field(array_keys($data->toArray()))->find();
if($find){
channelLog(array_merge($find->toArray(), $where),'store_order','更新前');
if ($find) {
channelLog(array_merge($find->toArray(), $where), 'store_order', '更新前');
}
}
} catch (Throwable $e) {
@ -116,11 +118,12 @@ class StoreOrder extends BaseModel
}
}
public static function onAfterWrite($data){
try{
channelLog($data->toArray(),'store_order','更新后');
}catch(Throwable $e){
Log::error('store_order:更新后'.$e->getMessage());
public static function onAfterWrite($data)
{
try {
channelLog($data->toArray(), 'store_order', '更新后');
} catch (Throwable $e) {
Log::error('store_order:更新后' . $e->getMessage());
}
}
}

View File

@ -15,7 +15,8 @@ class StoreOrderCartInfo extends BaseModel
protected $deleteTime = 'delete_time';
protected $json = ['cart_info'];
protected $jsonAssoc = true;
// 不生成该表的日志
public $doNotRecordLog = true;
public function goodsName()
{
return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);

View File

@ -16,7 +16,5 @@ class StoreOrderTransshipmentInfo extends BaseModel
{
use SoftDelete;
protected $name = 'store_order_transshipment_info';
protected $deleteTime = 'delete_time';
protected $deleteTime = 'delete_time';
}

View File

@ -18,7 +18,8 @@ class StoreProductAttrValue extends BaseModel
use SoftDelete;
protected $name = 'store_product_attr_value';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function storeName()
{
return $this->belongsTo(StoreProduct::class, 'product_id', 'id')

View File

@ -10,5 +10,6 @@ class StoreProductCate extends BaseModel
use SoftDelete;
protected $name = 'store_product_cate';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -14,7 +14,8 @@ class StoreProductGift extends BaseModel
use SoftDelete;
protected $name = 'store_product_gift';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function store()
{
return $this->hasOne(SystemStore::class, 'id', 'store_id')

View File

@ -17,7 +17,8 @@ class StoreProductGroupPrice extends BaseModel
use SoftDelete;
protected $name = 'store_product_group_price';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public static function resetProductsPrice($productList, $userShip)
{
$productIds = array_column($productList, 'product_id');

View File

@ -18,7 +18,8 @@ class StoreProductLog extends BaseModel
use SoftDelete;
protected $name = 'store_product_log';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function store()
{
return $this->hasOne(SystemStore::class, 'id', 'store_id')

View File

@ -20,5 +20,6 @@ class StoreProductPrice extends BaseModel
protected $json = ['price_config'];
protected $jsonAssoc = true;
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class StoreProductUnit extends BaseModel
use SoftDelete;
protected $name = 'store_product_unit';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class StoreVisit extends BaseModel
use SoftDelete;
protected $name = 'store_visit';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class Supplier extends BaseModel
use SoftDelete;
protected $name = 'supplier';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,7 +17,8 @@ class DeliveryService extends BaseModel
protected $name = 'delivery_service';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 头像获取器 - 头像路径添加域名
* @param $value

View File

@ -18,7 +18,8 @@ class SystemStore extends BaseModel
use SoftDelete;
protected $name = 'system_store';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public static function onBeforeWrite($data)
{
try {

View File

@ -28,6 +28,7 @@ class SystemStoreMenu extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -18,7 +18,8 @@ class SystemStoreStaff extends BaseModel
use SoftDelete;
protected $name = 'system_store_staff';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 头像获取器 - 头像路径添加域名
* @param $value

View File

@ -10,5 +10,6 @@ class SystemStoreStaffSession extends BaseModel
protected $name = 'system_store_staff_session';
protected $createTime = false;
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -25,7 +25,8 @@ use app\common\model\BaseModel;
*/
class GenerateColumn extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 关联table表
* @return \think\model\relation\BelongsTo

View File

@ -29,7 +29,8 @@ class GenerateTable extends BaseModel
protected $json = ['menu', 'tree', 'relations', 'delete'];
protected $jsonAssoc = true;
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* @notes 关联数据表字段
* @return \think\model\relation\HasMany

View File

@ -23,7 +23,8 @@ class User extends BaseModel
use SoftDelete;
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
//会员类型
public function userShip()
{

View File

@ -22,7 +22,8 @@ class UserAddress extends BaseModel
protected $pk = 'id';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public static function getDefaultAddress($uid)
{
$address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid, 'is_default' => 1])->find();

View File

@ -13,5 +13,6 @@ use app\common\model\BaseModel;
*/
class UserAuth extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,7 +17,8 @@ class UserFeedback extends BaseModel
use SoftDelete;
protected $name = 'user_feedback';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function getImagesAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}

View File

@ -17,5 +17,6 @@ class UserRecharge extends BaseModel
use SoftDelete;
protected $pk = 'id';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -11,5 +11,6 @@ use app\common\model\BaseModel;
*/
class UserSession extends BaseModel
{
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -18,7 +18,8 @@ class UserVisit extends BaseModel
protected $pk = 'id';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* 用户趋势数据
* @param $time

View File

@ -17,6 +17,7 @@ class UserBill extends BaseModel
use SoftDelete;
protected $name = 'user_bill';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class UserCreateLog extends BaseModel
use SoftDelete;
protected $name = 'user_create_log';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class UserLabel extends BaseModel
use SoftDelete;
protected $name = 'user_label';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,4 +17,6 @@ class UserProductStorage extends BaseModel
use SoftDelete;
protected $name = 'user_product_storage';
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -16,5 +16,7 @@ class UserProductStorageLog extends BaseModel
{
use SoftDelete;
protected $name = 'user_product_storage_log';
protected $deleteTime = 'delete_time';
}
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,7 +17,8 @@ class UserRecharge extends BaseModel
use SoftDelete;
protected $name = 'user_recharge';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
/**
* 获取充值统计曲线
* @param $time

View File

@ -10,4 +10,6 @@ class UserShip extends BaseModel
use SoftDelete;
protected $name = 'user_ship';
protected $deleteTime = 'delete_time';
}
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,5 +17,6 @@ class UserSign extends BaseModel
use SoftDelete;
protected $name = 'user_sign';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,5 +17,6 @@ class UserSignLog extends BaseModel
use SoftDelete;
protected $name = 'user_sign_log';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -17,6 +17,7 @@ class UserSpreadLog extends BaseModel
use SoftDelete;
protected $name = 'user_spread_log';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

View File

@ -11,7 +11,8 @@ class VipFlow extends BaseModel
use SoftDelete;
protected $name = 'vip_flow';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public function store()
{
return $this->hasOne(SystemStore::class, 'id','store_id')

View File

@ -17,6 +17,7 @@ class Warehouse extends BaseModel
use SoftDelete;
protected $name = 'warehouse';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
}

Some files were not shown because too many files have changed in this diff Show More