Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
# Conflicts: # app/common/logic/PayNotifyLogic.php
This commit is contained in:
commit
c7c7bb9831
@ -37,4 +37,12 @@ class IndexController extends BaseAdminController
|
|||||||
$res=DemoLogic::test3($id,$warehouse_id);
|
$res=DemoLogic::test3($id,$warehouse_id);
|
||||||
return $this->success('成功');
|
return $this->success('成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function demo4()
|
||||||
|
{
|
||||||
|
$params=$this->request->get();
|
||||||
|
$is_vip=$this->request->get('is_vip',0);
|
||||||
|
$res=DemoLogic::syncPrice($params,$is_vip);
|
||||||
|
return $this->success('成功');
|
||||||
|
}
|
||||||
}
|
}
|
@ -86,9 +86,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
$exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id');
|
$exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id');
|
||||||
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
|
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
|
||||||
}
|
}
|
||||||
|
$storeId = $this->params['store_id'] ?? 0;
|
||||||
|
$is_true = true;
|
||||||
|
if ($storeId > 0) {
|
||||||
|
$is_true = SystemStore::isSelfOperate($storeId);
|
||||||
|
}
|
||||||
$list = $query->limit($this->limitOffset, $this->limitLength)
|
$list = $query->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) use($is_warehouse, $userShip,$order_type) {
|
->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) {
|
||||||
$item['product_id'] = $item['id'];
|
$item['product_id'] = $item['id'];
|
||||||
$item['bar_code_two'] = '';
|
$item['bar_code_two'] = '';
|
||||||
if (in_array($item['unit'], [2, 21])) {
|
if (in_array($item['unit'], [2, 21])) {
|
||||||
@ -149,14 +154,15 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
$item['price'] = $price;
|
$item['price'] = $price;
|
||||||
$item['store_name'] = $item['store_name'] . '|活动价';
|
$item['store_name'] = $item['store_name'] . '|活动价';
|
||||||
}
|
}
|
||||||
|
}elseif($is_true == true && $userShip>0){
|
||||||
|
$item['price'] = $item['vip_price'];
|
||||||
|
$item['store_name'] = $item['store_name'] . '|会员价';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
})?->toArray();
|
})?->toArray();
|
||||||
if ($userShip > 0 && $userShip != 4) {
|
// if ($userShip > 0 && $userShip != 4) {
|
||||||
$list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
// $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
||||||
}
|
// }
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
{
|
{
|
||||||
if ($this->request->get('product_id')) {
|
if ($this->request->get('product_id')) {
|
||||||
$product_id = $this->request->get('product_id');
|
$product_id = $this->request->get('product_id');
|
||||||
$ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id');
|
$ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->column('id');
|
||||||
if ($ids) {
|
if ($ids) {
|
||||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
@ -64,7 +64,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
}
|
}
|
||||||
if ($this->request->get('bar_code')) {
|
if ($this->request->get('bar_code')) {
|
||||||
$bar_code = $this->request->get('bar_code');
|
$bar_code = $this->request->get('bar_code');
|
||||||
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id');
|
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id');
|
||||||
if ($ids) {
|
if ($ids) {
|
||||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
@ -76,7 +76,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay'])
|
->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->withTrashed()
|
// ->withTrashed()
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item->store_name = '';
|
$item->store_name = '';
|
||||||
$item->image = '';
|
$item->image = '';
|
||||||
|
@ -8,6 +8,7 @@ use app\admin\logic\store_product\StoreProductLogic;
|
|||||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
use app\api\logic\order\CartLogic;
|
use app\api\logic\order\CartLogic;
|
||||||
use app\api\logic\order\OrderLogic;
|
use app\api\logic\order\OrderLogic;
|
||||||
|
use app\common\enum\OrderEnum;
|
||||||
use app\common\model\beforehand_order\BeforehandOrder;
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
@ -262,7 +263,7 @@ class BeforehandOrderLogic extends BaseLogic
|
|||||||
'store_id' => $params['store_id'] ?? 0,
|
'store_id' => $params['store_id'] ?? 0,
|
||||||
'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提
|
'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提
|
||||||
'deduction_price' => 0, //抵扣金额
|
'deduction_price' => 0, //抵扣金额
|
||||||
'source' => 2, //后台下单
|
'source' => OrderEnum::SOURCE_20, //来源
|
||||||
'order_type' => $order['order_type'],
|
'order_type' => $order['order_type'],
|
||||||
'is_storage' => 0,
|
'is_storage' => 0,
|
||||||
'verify_code' => createCode($code),
|
'verify_code' => createCode($code),
|
||||||
@ -674,6 +675,15 @@ class BeforehandOrderLogic extends BaseLogic
|
|||||||
$res['examine_name'] = Admin::where('id', $record['check_user_id'])->value('name');
|
$res['examine_name'] = Admin::where('id', $record['check_user_id'])->value('name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$res['is_vip']=0;
|
||||||
|
if($res['uid']>0){
|
||||||
|
$user_ship=User::where('id',$res['uid'])->value('user_ship');
|
||||||
|
if($user_ship>0){
|
||||||
|
$res['is_vip']=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +61,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
public static function appendAdd(array $params): bool
|
public static function appendAdd(array $params): bool
|
||||||
{
|
{
|
||||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||||
if ((!empty($order) && $order->is_confirm == 1 && empty($params['admin_id'])) || $order['is_outbound'] > 0) {
|
if(empty($params['admin_id'])){
|
||||||
|
if ((!empty($order) && $order->is_confirm == 1 ) || $order['is_outbound'] > 0) {
|
||||||
throw new BusinessException('该订单已确认,不能追加商品');
|
throw new BusinessException('该订单已确认,不能追加商品');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$datas = [];
|
$datas = [];
|
||||||
@ -109,6 +111,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
||||||
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
|
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
|
||||||
}
|
}
|
||||||
|
$bhoid = $params['bhoid'];
|
||||||
|
$order=BeforehandOrder::where('id', $bhoid)->find();
|
||||||
|
if($order['outbound_id']>0){
|
||||||
|
throw new BusinessException('该订单已出库,不能修改');
|
||||||
|
}
|
||||||
if($params['total_price']<=0){
|
if($params['total_price']<=0){
|
||||||
$total_price=bcmul($params['purchases'],$params['nums'],2);
|
$total_price=bcmul($params['purchases'],$params['nums'],2);
|
||||||
}else{
|
}else{
|
||||||
@ -122,12 +129,10 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
'accept_num' => $params['nums'],
|
'accept_num' => $params['nums'],
|
||||||
'mark' => $params['mark']??'',
|
'mark' => $params['mark']??'',
|
||||||
]);
|
]);
|
||||||
$bhoid = $params['bhoid'];
|
|
||||||
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price,sum(pay_price) as pay_price')->find();
|
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price,sum(pay_price) as pay_price')->find();
|
||||||
if($find['is_buyer']==1){
|
if($find['is_buyer']==1){
|
||||||
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
|
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
|
||||||
}
|
}
|
||||||
$order=BeforehandOrder::where('id', $bhoid)->find();
|
|
||||||
$order->save(['total_price' => $info['total_price'],'pay_price' => $info['pay_price'], 'total_num' => $info['cart_num']]);
|
$order->save(['total_price' => $info['total_price'],'pay_price' => $info['pay_price'], 'total_num' => $info['cart_num']]);
|
||||||
|
|
||||||
if($order['outbound_id']>0){
|
if($order['outbound_id']>0){
|
||||||
@ -315,7 +320,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
|
|
||||||
public static function syncPrice($params)
|
public static function syncPrice($params)
|
||||||
{
|
{
|
||||||
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('price', 0)->select()->toArray();
|
$outbound_id=BeforehandOrder::where('id', $params['bhoid'])->value('outbound_id');
|
||||||
|
if($outbound_id>0){
|
||||||
|
throw new BusinessException('该订单已出库,不能修改');
|
||||||
|
}
|
||||||
|
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray();
|
||||||
$productIds = array_column($cartInfo, 'product_id');
|
$productIds = array_column($cartInfo, 'product_id');
|
||||||
$products = StoreProduct::whereIn('id', $productIds)->select()->toArray();
|
$products = StoreProduct::whereIn('id', $productIds)->select()->toArray();
|
||||||
$products = reset_index($products, 'id');
|
$products = reset_index($products, 'id');
|
||||||
|
@ -8,6 +8,8 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\model\warehouse\Warehouse;
|
||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -31,6 +33,7 @@ class InventoryTransferOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function add(array $params,$admin_id): bool
|
public static function add(array $params,$admin_id): bool
|
||||||
{
|
{
|
||||||
|
$types=$params['types']??0;
|
||||||
if (empty($params['product_arr'])) {
|
if (empty($params['product_arr'])) {
|
||||||
throw new BusinessException('请选择商品');
|
throw new BusinessException('请选择商品');
|
||||||
}
|
}
|
||||||
@ -78,13 +81,17 @@ class InventoryTransferOrderLogic extends BaseLogic
|
|||||||
'two_type' => $params['two_type'],
|
'two_type' => $params['two_type'],
|
||||||
'one_id' => $params['one_id'],
|
'one_id' => $params['one_id'],
|
||||||
'two_id' => $params['two_id'],
|
'two_id' => $params['two_id'],
|
||||||
'types' => $params['types']??0,
|
'types' => $types,
|
||||||
'mark' => $params['mark']??'',
|
'mark' => $params['mark']??'',
|
||||||
]);
|
]);
|
||||||
foreach ($insert as $k => $v) {
|
foreach ($insert as $k => $v) {
|
||||||
$insert[$k]['oid'] = $order['id'];
|
$insert[$k]['oid'] = $order['id'];
|
||||||
}
|
}
|
||||||
InventoryTransfer::insertAll($insert);
|
InventoryTransfer::insertAll($insert);
|
||||||
|
if($types==1){
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
foreach ($insert as $v) {
|
foreach ($insert as $v) {
|
||||||
if($params['one_type']==1){
|
if($params['one_type']==1){
|
||||||
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find();
|
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find();
|
||||||
@ -185,6 +192,28 @@ class InventoryTransferOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return InventoryTransferOrder::findOrEmpty($params['id'])->toArray();
|
$data= InventoryTransferOrder::findOrEmpty($params['id']);
|
||||||
|
$type_name='';
|
||||||
|
if($data->one_type==1){
|
||||||
|
$data->one_name=SystemStore::where('id',$data->one_id)->value('name');
|
||||||
|
$type_name='门店转';
|
||||||
|
}else{
|
||||||
|
$data->one_name=Warehouse::where('id',$data->one_id)->value('name');
|
||||||
|
$type_name='仓库转';
|
||||||
|
}
|
||||||
|
if($data->two_type==1){
|
||||||
|
$type_name.='门店';
|
||||||
|
$data->two_name=SystemStore::where('id',$data->two_id)->value('name');
|
||||||
|
}else{
|
||||||
|
$type_name.='仓库';
|
||||||
|
$data->two_name=Warehouse::where('id',$data->two_id)->value('name');
|
||||||
|
}
|
||||||
|
$data->type_name=$type_name;
|
||||||
|
$data['product_list']=InventoryTransfer::where('oid',$params['id'])->select()->each(function ($item) {
|
||||||
|
$find= StoreProduct::where('id',$item->product_id)->withTrashed()->field('store_name')->find();
|
||||||
|
$item->store_name=$find['store_name'];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
return $data->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -60,7 +60,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
if ($mark == '') {
|
if ($mark == '') {
|
||||||
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
|
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
|
||||||
}
|
}
|
||||||
$find = StoreProduct::where('id', $params['product_id'])->find();
|
$find = StoreProduct::where('id', $params['product_id'])->withTrashed()->find();
|
||||||
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
||||||
if ($purchaseProductOffer) {
|
if ($purchaseProductOffer) {
|
||||||
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
||||||
@ -104,6 +104,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,12 @@
|
|||||||
namespace app\api\logic;
|
namespace app\api\logic;
|
||||||
|
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
|
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||||
|
use app\common\model\warehouse_order\WarehouseOrder;
|
||||||
use app\common\model\warehouse_product\WarehouseProduct;
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -111,4 +114,49 @@ class DemoLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function syncPrice($params,$is_vip=0)
|
||||||
|
{
|
||||||
|
$outbound_id=BeforehandOrder::where('id', $params['id'])->value('outbound_id');
|
||||||
|
|
||||||
|
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray();
|
||||||
|
$productIds = array_column($cartInfo, 'product_id');
|
||||||
|
$products = StoreProduct::whereIn('id', $productIds)->withTrashed()->select()->toArray();
|
||||||
|
$products = reset_index($products, 'id');
|
||||||
|
$update = [];
|
||||||
|
foreach ($cartInfo as $v) {
|
||||||
|
$product = $products[$v['product_id']];
|
||||||
|
if (empty($product)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($is_vip == 1) {
|
||||||
|
$price = $product['vip_price'];
|
||||||
|
} else {
|
||||||
|
$price = $product['price'];
|
||||||
|
}
|
||||||
|
$update[] = [
|
||||||
|
'id' => $v['id'],
|
||||||
|
'price' => $price,
|
||||||
|
'total_price' => $price * $v['cart_num'],
|
||||||
|
'pay_price' => $price * $v['cart_num'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
(new BeforehandOrderCartInfo())->saveAll($update);
|
||||||
|
$totalPrice = array_sum(array_column($update, 'total_price'));
|
||||||
|
BeforehandOrder::where('id', $params['id'])->update(['total_price' => $totalPrice,'pay_price' => $totalPrice]);
|
||||||
|
if($outbound_id){
|
||||||
|
WarehouseProduct::where('oid', $outbound_id)->select()->each(function ($item) use($is_vip) {
|
||||||
|
if($is_vip==0){
|
||||||
|
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->field('purchase,vip_price,price')->find();
|
||||||
|
$item->save(['price' => $find['price'], 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'],'total_price' => $find['price'] * $item['nums']]);
|
||||||
|
}else{
|
||||||
|
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->field('purchase,vip_price,price')->find();
|
||||||
|
$item->save(['price' => $find['vip_price'], 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'],'total_price' => $find['vip_price'] * $item['nums']]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$total_price=WarehouseProduct::where('oid', $outbound_id)->sum('total_price');
|
||||||
|
WarehouseOrder::where('id', $outbound_id)->update(['total_price' => $total_price]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,18 @@ class OrderEnum
|
|||||||
const USER_ORDER_REFUND = 19;//订单返还
|
const USER_ORDER_REFUND = 19;//订单返还
|
||||||
const PAY_BACK =-1;
|
const PAY_BACK =-1;
|
||||||
|
|
||||||
|
//-----------------------订单来源-----------------------//
|
||||||
|
/**
|
||||||
|
* @SOURCE_0 小程序
|
||||||
|
* @SOURCE_1 收银台
|
||||||
|
* @SOURCE_2 后台下单
|
||||||
|
* @SOURCE_20 预订单转订单
|
||||||
|
*/
|
||||||
|
const SOURCE_0 =0;//小程序
|
||||||
|
const SOURCE_1 =1;//收银台
|
||||||
|
const SOURCE_2 =2;//后台下单
|
||||||
|
const SOURCE_20 =20;//预订单转订单
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收入支出类型
|
* 收入支出类型
|
||||||
|
@ -351,7 +351,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// $user = User::where('id', $order['uid'])->findOrEmpty();
|
// $user = User::where('id', $order['uid'])->findOrEmpty();
|
||||||
// $capitalFlowDao = new CapitalFlowLogic($user);
|
// $capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
// $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1);
|
// $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1);
|
||||||
// self::addStock($order['id']); //微信
|
self::addStock($order['id'], $order);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id']);
|
self::addStock($order['id'], $order);
|
||||||
}
|
}
|
||||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
||||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||||
@ -389,7 +389,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id']);
|
self::addStock($order['id'], $order);
|
||||||
}
|
}
|
||||||
UserSignLogic::RefundOrder($order);
|
UserSignLogic::RefundOrder($order);
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$model->status = YesNoEnum::YES;
|
$model->status = YesNoEnum::YES;
|
||||||
$model->save();
|
$model->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id']);
|
self::addStock($order['id'], $order);
|
||||||
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
||||||
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
||||||
|
|
||||||
@ -630,6 +630,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($order['source'] != OrderEnum::SOURCE_20) {
|
||||||
if ($branchProduct) {
|
if ($branchProduct) {
|
||||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||||
StoreBranchProduct::update([
|
StoreBranchProduct::update([
|
||||||
@ -647,6 +648,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('订单库存更新失败:' . $e->getMessage());
|
Log::error('订单库存更新失败:' . $e->getMessage());
|
||||||
// 异常处理代码,例如记录日志或发送通知等。
|
// 异常处理代码,例如记录日志或发送通知等。
|
||||||
@ -868,8 +870,11 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function addStock($oid)
|
public static function addStock($oid, $order)
|
||||||
{
|
{
|
||||||
|
if ($order && $order['source'] == OrderEnum::SOURCE_20) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
||||||
foreach ($goods_list as $v) {
|
foreach ($goods_list as $v) {
|
||||||
|
@ -39,7 +39,7 @@ class BeforehandOrderController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = $this->request->get();
|
$params = $this->request->get();
|
||||||
$params['store_id'] = $this->request->adminInfo['store_id'] ?? 0;
|
$params['store_id'] = $this->request->adminInfo['store_id'] ?? 0;
|
||||||
$params['store_staff_id'] = $this->request->adminInfo['admin_id'] ?? 0;
|
// $params['store_staff_id'] = $this->request->adminInfo['admin_id'] ?? 0;
|
||||||
$this->request->setGet($params);
|
$this->request->setGet($params);
|
||||||
return $this->dataLists(new BeforehandOrderLists());
|
return $this->dataLists(new BeforehandOrderLists());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user