commit
12e214d8ca
@ -132,49 +132,21 @@ class StoreOrderLogic extends BaseLogic
|
||||
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
|
||||
->refund($params['order_id'], $money, $pay_price);
|
||||
if ($refund) {
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||
if ($find) {
|
||||
$refund_num += $v['cart_num'];
|
||||
$cart_num = bcsub($find['cart_num'], $v['cart_num']);
|
||||
$total_price = bcmul($find['price'], $cart_num);
|
||||
$data = ['cart_num' => $cart_num, 'total_price' => $total_price];
|
||||
StoreOrderCartInfo::where('id', $find['id'])->update($data);
|
||||
$arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$value['cart_num'] = $cart_num;
|
||||
$value['total_price'] = bcmul($cart_num, $value['price'], 2);
|
||||
$value['number'] = bcmul($value['total_price'], $value['rate'], 2);
|
||||
StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]);
|
||||
unset($value['id']);
|
||||
$value['create_time'] = strtotime($value['create_time']);
|
||||
$value['update_time'] = strtotime($value['update_time']);
|
||||
StoreFinanceFlowProduct::create($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
$detail['refund_price']=$refund_price;
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
self::refundProduct($detail, $params);
|
||||
return '退款成功';
|
||||
}
|
||||
}
|
||||
//余额支付 采购款支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
PayNotifyLogic::balance_purchase_refund($detail,0,$params['refund_price']);
|
||||
self::refundProduct($detail, $params);
|
||||
return '退款成功';
|
||||
|
||||
}
|
||||
//现金支付
|
||||
if ($detail['pay_type'] = PayEnum::CASH_PAY) {
|
||||
PayNotifyLogic::cash_refund($params['order_id']);
|
||||
self::refundProduct($detail, $params);
|
||||
return '退款成功';
|
||||
|
||||
}
|
||||
@ -208,7 +180,7 @@ class StoreOrderLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public function refundProduct($detail, $params)
|
||||
public static function refundProduct($detail, $params)
|
||||
{
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
@ -237,9 +209,9 @@ class StoreOrderLogic extends BaseLogic
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
$detail['refund_price']=$refund_price;
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace app\api\controller\branch_product;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\branch_product\BranchProductLists;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
class BranchProductController extends BaseApiController
|
||||
{
|
||||
@ -14,6 +15,8 @@ class BranchProductController extends BaseApiController
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new BranchProductLists());
|
||||
}
|
||||
}
|
||||
|
@ -339,18 +339,12 @@ class OrderController extends BaseApiController
|
||||
public function detail()
|
||||
{
|
||||
$order_id = (int)$this->request->get('order_id');
|
||||
$lat = $this->request->get('lat', '');
|
||||
$lng = $this->request->get('long', '');
|
||||
$where = [
|
||||
'id' => $order_id,
|
||||
'uid' => $this->userId,
|
||||
];
|
||||
$url = 'https://' . $this->request->host(true);
|
||||
$parm = [
|
||||
'lat' => $lat,
|
||||
'long' => $lng
|
||||
];
|
||||
$order = OrderLogic::detail($where, $url, $parm);
|
||||
$order = OrderLogic::detail($where, $url);
|
||||
if ($order) {
|
||||
return $this->data($order);
|
||||
} else {
|
||||
|
@ -13,10 +13,15 @@ use app\common\enum\PayEnum;
|
||||
use app\common\logic\PaymentLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user_create_log\UserCreateLog;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\Curl;
|
||||
use Exception;
|
||||
use support\Cache;
|
||||
@ -210,4 +215,42 @@ class StoreController extends BaseApiController
|
||||
];
|
||||
return $this->success('ok',['menu'=>$menu]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺收支
|
||||
*/
|
||||
public function store_statistics(){
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
if(!$store_id){
|
||||
return $this->fail('请先绑定店铺');
|
||||
}
|
||||
$total_price=WarehouseProduct::where('store_id',$store_id)->where('financial_pm',0)->sum('total_price');
|
||||
$order=StoreOrder::where('store_id',$store_id)->where('refund_status',0)->field('sum(refund_price) as refund_price,sum(pay_price) as pay_price')->find();
|
||||
$pay_price=bcsub($order['pay_price'],$order['refund_price'],2);
|
||||
|
||||
$commission=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',3)->sum('number');
|
||||
$bond=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',11)->sum('number');
|
||||
$vip=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',12)->sum('number');
|
||||
$village=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',14)->sum('number');
|
||||
$brigade=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',15)->sum('number');
|
||||
$attrition=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',16)->sum('number');
|
||||
|
||||
$money=bcadd($commission,$bond,2);
|
||||
$money=bcadd($money,$vip,2);
|
||||
$money=bcadd($money,$village,2);
|
||||
$money=bcadd($money,$brigade,2);
|
||||
$expenditure=bcadd($money,$attrition,2);
|
||||
|
||||
|
||||
$store_money=SystemStore::where('id',$store_id)->value('store_money');
|
||||
|
||||
$list=[
|
||||
['name'=>'手续费','data'=>[$commission]],
|
||||
['name'=>'保证金','data'=>[$bond]],
|
||||
['name'=>'厨师','data'=>[$vip]],
|
||||
['name'=>'村长','data'=>[$village]],
|
||||
['name'=>'队长','data'=>[$brigade]],
|
||||
];
|
||||
return $this->success('ok',['total_price'=>$total_price,'pay_price'=>$pay_price,'list'=>$list,'attrition'=>$attrition,'store_money'=>$store_money,'expenditure'=>$expenditure]);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ namespace app\api\controller\store_order_cart_info;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists;
|
||||
use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
/**
|
||||
* 商品销量控制器
|
||||
@ -22,13 +23,15 @@ class StoreOrderCartInfoController extends BaseApiController
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$this->request->__set('store_id',5);
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new StoreOrderCartInfoLists());
|
||||
}
|
||||
|
||||
public function group_lists()
|
||||
{
|
||||
$this->request->__set('store_id',5);
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new StoreOrderCartInfoGroupLists());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ namespace app\api\controller\system_store_storage;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\system_store_storage\SystemStoreStorageLists;
|
||||
use app\api\lists\system_store_storage\SystemStoreStorageGroupLists;
|
||||
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||
|
||||
/**
|
||||
* 门店入库控制器
|
||||
@ -23,6 +25,11 @@ class SystemStoreStorageController extends BaseApiController
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
if(!$store_id){
|
||||
return $this->fail('请先绑定店铺');
|
||||
}
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new SystemStoreStorageLists());
|
||||
}
|
||||
/**
|
||||
@ -33,7 +40,26 @@ class SystemStoreStorageController extends BaseApiController
|
||||
*/
|
||||
public function group_lists()
|
||||
{
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
|
||||
if(!$store_id){
|
||||
return $this->fail('请先绑定店铺');
|
||||
}
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new SystemStoreStorageGroupLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 门店入库
|
||||
*/
|
||||
public function warehousing_add() {
|
||||
$params = $this->request->post();
|
||||
$find=SystemStoreStorage::where('id',$params['id'])->find();
|
||||
if($find){
|
||||
$find->status=1;
|
||||
$find->save();
|
||||
StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->inc('stock',$find['nums'])->update();
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
return $this->fail('操作失败');
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,11 @@ class SystemStoreStorageGroupLists extends BaseApiDataLists implements ListsSear
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$store_id=$this->request->__get('store_id');
|
||||
if(!$store_id){
|
||||
return [];
|
||||
}
|
||||
$this->searchWhere[] = ['store_id', '=', $store_id];
|
||||
$fields = 'store_id,product_id,sum(nums) as nums,mark';
|
||||
if ($this->request->get('store_name')) {
|
||||
$store_name = $this->request->get('store_name');
|
||||
|
@ -62,6 +62,12 @@ class SystemStoreStorageLists extends BaseApiDataLists implements ListsSearchInt
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$store_id=$this->request->__get('store_id');
|
||||
if(!$store_id){
|
||||
return [];
|
||||
}
|
||||
$this->searchWhere[] = ['store_id', '=', $store_id];
|
||||
|
||||
$fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status';
|
||||
if ($this->request->get('store_name')) {
|
||||
$store_name = $this->request->get('store_name');
|
||||
|
@ -149,7 +149,7 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
//利润
|
||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['total_purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额
|
||||
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价
|
||||
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
|
||||
@ -181,13 +181,14 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||
//理论上每笔都是拆分了
|
||||
$cart_select[$k]['name'] = $find['store_name'];
|
||||
$cart_select[$k]['purchase'] = $find['purchase'];
|
||||
$cart_select[$k]['imgs'] = $find['image'];
|
||||
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
|
||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||
$cart_select[$k]['total_price'] = $cart_select[$k]['pay_price'];
|
||||
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['total_purchase'], 2);
|
||||
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
|
||||
self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额
|
||||
// self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额
|
||||
@ -343,7 +344,6 @@ class OrderLogic extends BaseLogic
|
||||
$goods_list[$k]['oid'] = $order->id;
|
||||
$goods_list[$k]['uid'] = $uid;
|
||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||
}
|
||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||
$where = ['is_pay' => 0];
|
||||
@ -351,7 +351,7 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return $order;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
@ -500,13 +500,11 @@ class OrderLogic extends BaseLogic
|
||||
if ($find) {
|
||||
|
||||
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
|
||||
->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) {
|
||||
->field('product_id,cart_num nums,store_id,price')->select()->each(function ($item) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
|
||||
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['nums'] = floatval($item['nums']);
|
||||
$item['image'] = $find['image'];
|
||||
$item['price'] = $find['price'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
$item['msg'] = '预计48小时发货';
|
||||
return $item;
|
||||
@ -523,22 +521,6 @@ class OrderLogic extends BaseLogic
|
||||
$tmpFilename = $generator->getBarcode($find['verify_code'], $generator::TYPE_CODE_128);
|
||||
$find['verify_base64'] = 'data:image/png;base64,' . base64_encode($tmpFilename);
|
||||
}
|
||||
//处理返回最近的店铺
|
||||
if ($param['lat'] && $param['long']) {
|
||||
$storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray();
|
||||
$nearestStore = null;
|
||||
$minDistance = PHP_FLOAT_MAX;
|
||||
foreach ($storeAll as $value) {
|
||||
$value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $param['lat'], $param['long']);
|
||||
if ($value['distance'] < $minDistance) {
|
||||
$minDistance = $value['distance'];
|
||||
$nearestStore = $value;
|
||||
}
|
||||
}
|
||||
if ($nearestStore) {
|
||||
$find['near_store'] = $nearestStore;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $find;
|
||||
}
|
||||
|
@ -120,9 +120,13 @@ class CommissionProductLogic extends BaseLogic
|
||||
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
|
||||
}
|
||||
} elseif ($user['user_ship'] == 1) {
|
||||
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
|
||||
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
|
||||
$number1 = bcadd($number1, $vip_number, 2);
|
||||
if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){
|
||||
|
||||
}else{
|
||||
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
|
||||
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
|
||||
$number1 = bcadd($number1, $vip_number, 2);
|
||||
}
|
||||
if ($rose >= 12 && $village_uid>0) {
|
||||
$village_number = bcmul($total_price, 0.01, 2); //村长利润
|
||||
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01);
|
||||
@ -156,7 +160,6 @@ class CommissionProductLogic extends BaseLogic
|
||||
if ($rose >= 6) {
|
||||
$data[] = $this->platform('零售平台', $order, $find, $price, $total_price,$platform_number);
|
||||
}
|
||||
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
}
|
||||
|
||||
|
@ -684,7 +684,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
|
||||
try {
|
||||
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,cart_num')->select();
|
||||
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,purchase,cart_num')->select();
|
||||
$comm = new CommissionProductLogic();
|
||||
foreach ($info as $k => $v) {
|
||||
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
|
||||
@ -855,7 +855,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$updateData[] = [
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
'sales' => ['dec', $v['cart_num']]
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
}
|
||||
|
@ -41,10 +41,22 @@ class StoreBranchProduct extends BaseModel
|
||||
{
|
||||
return $this->hasOne(StoreProduct::class,'id','product_id');
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(), $where),'branch_product','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('branch_product:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'branch_product','更新前');
|
||||
channelLog($data->toArray(),'branch_product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('branch_product:'.$e->getMessage());
|
||||
|
@ -101,12 +101,26 @@ class StoreOrder extends BaseModel
|
||||
->group('days')->select()->toArray();
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(), $where),'store_order','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('store_order:更新前' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'store_order','更新前');
|
||||
channelLog($data->toArray(),'store_order','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('store_order:'.$e->getMessage());
|
||||
Log::error('store_order:更新后'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,23 @@ class StoreOrderCartInfo extends BaseModel
|
||||
return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(),$where),'store_order_cart_info','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('store_order_cart_info:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'store_order_cart_info','更新前');
|
||||
channelLog($data->toArray(),'store_order_cart_info','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('store_order_cart_info:'.$e->getMessage());
|
||||
|
@ -33,10 +33,22 @@ class StoreProduct extends BaseModel
|
||||
return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']);
|
||||
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if ($find) {
|
||||
channelLog(array_merge($find->toArray(), $where), 'product', '更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('product:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'product','更新前');
|
||||
channelLog($data->toArray(),'product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('product:'.$e->getMessage());
|
||||
|
@ -197,9 +197,21 @@ class User extends BaseModel
|
||||
})->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray();
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data){
|
||||
try{
|
||||
$where=$data->getWhere();
|
||||
if($data){
|
||||
$find=self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(),$where),'user','更新前');
|
||||
}
|
||||
}
|
||||
}catch(Throwable $e){
|
||||
Log::error('user:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'user','更新前');
|
||||
channelLog($data->toArray(),'user','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('user:'.$e->getMessage());
|
||||
|
@ -19,9 +19,23 @@ class WarehouseProduct extends BaseModel
|
||||
protected $name = 'warehouse_product';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(), $where),'warehouse_product','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'warehouse_product','更新前');
|
||||
channelLog($data->toArray(),'warehouse_product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('warehouse_product:'.$e->getMessage());
|
||||
|
@ -18,10 +18,24 @@ class WarehouseProductStorege extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'warehouse_product_storege';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(), $where), 'warehouse_product_storege', '更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product_storege:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data)
|
||||
{
|
||||
try {
|
||||
channelLog($data->getOrigin(), 'warehouse_product_storege', '更新前');
|
||||
channelLog($data->toArray(), 'warehouse_product_storege', '更新后');
|
||||
} catch (Throwable $e) {
|
||||
Log::error('warehouse_product_storege:' . $e->getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user