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);
|
||||
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('成功');
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['cate_id', 'is_show', 'bar_code','id'],
|
||||
'=' => ['cate_id', 'is_show', 'bar_code', 'id'],
|
||||
'in' => ['product_type'],
|
||||
'<=' => ['stock'],
|
||||
'%like%' => ['store_name'],
|
||||
@ -65,8 +65,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
$is_warehouse=$this->request->get('is_warehouse',0);
|
||||
$order_type=$this->request->get('order_type',0);
|
||||
$is_warehouse = $this->request->get('is_warehouse', 0);
|
||||
$order_type = $this->request->get('order_type', 0);
|
||||
$userShip = 0;
|
||||
if (!empty($this->params['user_id'])) {
|
||||
$userShip = User::where('id', $this->params['user_id'])->value('user_ship');
|
||||
@ -86,9 +86,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$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);
|
||||
}
|
||||
$storeId = $this->params['store_id'] ?? 0;
|
||||
$is_true = true;
|
||||
if ($storeId > 0) {
|
||||
$is_true = SystemStore::isSelfOperate($storeId);
|
||||
}
|
||||
$list = $query->limit($this->limitOffset, $this->limitLength)
|
||||
->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['bar_code_two'] = '';
|
||||
if (in_array($item['unit'], [2, 21])) {
|
||||
@ -106,7 +111,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$item['bar_code'] = '';
|
||||
}
|
||||
}
|
||||
switch($item['product_type']){
|
||||
switch ($item['product_type']) {
|
||||
case 2:
|
||||
$item['product_type_name'] = '兑换产品';
|
||||
break;
|
||||
@ -119,7 +124,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
case 5:
|
||||
$item['product_type_name'] = '批发产品';
|
||||
break;
|
||||
case 6:
|
||||
case 6:
|
||||
$item['product_type_name'] = '零采商品';
|
||||
break;
|
||||
default:
|
||||
@ -127,36 +132,37 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
}
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||
$stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock');
|
||||
$category = StoreCategory::where('id','in',[$item['top_cate_id'],$item['two_cate_id'],$item['cate_id']])->column('name');
|
||||
$item['cate_name'] =implode('/', $category);
|
||||
if($is_warehouse==1){
|
||||
$category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name');
|
||||
$item['cate_name'] = implode('/', $category);
|
||||
if ($is_warehouse == 1) {
|
||||
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||
}else{
|
||||
} else {
|
||||
$nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||
$item['stock'] = bcadd($nums, $stock);
|
||||
}
|
||||
if ($userShip == 4) {
|
||||
$item['price'] = $item['cost'];
|
||||
}
|
||||
if($item['is_show']==1){
|
||||
$item['status_msg']='上架|常用';
|
||||
}else{
|
||||
$item['status_msg']='下架|不常用|是否有替换';
|
||||
if ($item['is_show'] == 1) {
|
||||
$item['status_msg'] = '上架|常用';
|
||||
} else {
|
||||
$item['status_msg'] = '下架|不常用|是否有替换';
|
||||
}
|
||||
if ($order_type == 2) {
|
||||
$price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price');
|
||||
if($price>0){
|
||||
$price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price');
|
||||
if ($price > 0) {
|
||||
$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;
|
||||
})?->toArray();
|
||||
if ($userShip > 0 && $userShip != 4) {
|
||||
$list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
||||
}
|
||||
// if ($userShip > 0 && $userShip != 4) {
|
||||
// $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
||||
// }
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
{
|
||||
if ($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) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
@ -64,7 +64,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
}
|
||||
if ($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) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $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'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withTrashed()
|
||||
// ->withTrashed()
|
||||
->select()->each(function ($item) {
|
||||
$item->store_name = '';
|
||||
$item->image = '';
|
||||
|
@ -8,6 +8,7 @@ use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\api\logic\order\CartLogic;
|
||||
use app\api\logic\order\OrderLogic;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
@ -262,7 +263,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
'store_id' => $params['store_id'] ?? 0,
|
||||
'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提
|
||||
'deduction_price' => 0, //抵扣金额
|
||||
'source' => 2, //后台下单
|
||||
'source' => OrderEnum::SOURCE_20, //来源
|
||||
'order_type' => $order['order_type'],
|
||||
'is_storage' => 0,
|
||||
'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['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;
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,10 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
public static function appendAdd(array $params): bool
|
||||
{
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
if ((!empty($order) && $order->is_confirm == 1 && empty($params['admin_id'])) || $order['is_outbound'] > 0) {
|
||||
throw new BusinessException('该订单已确认,不能追加商品');
|
||||
if(empty($params['admin_id'])){
|
||||
if ((!empty($order) && $order->is_confirm == 1 ) || $order['is_outbound'] > 0) {
|
||||
throw new BusinessException('该订单已确认,不能追加商品');
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
@ -109,6 +111,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
||||
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){
|
||||
$total_price=bcmul($params['purchases'],$params['nums'],2);
|
||||
}else{
|
||||
@ -122,12 +129,10 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
'accept_num' => $params['nums'],
|
||||
'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();
|
||||
if($find['is_buyer']==1){
|
||||
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']]);
|
||||
|
||||
if($order['outbound_id']>0){
|
||||
@ -315,7 +320,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
|
||||
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');
|
||||
$products = StoreProduct::whereIn('id', $productIds)->select()->toArray();
|
||||
$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\store_branch_product\StoreBranchProduct;
|
||||
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 support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
@ -31,6 +33,7 @@ class InventoryTransferOrderLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params,$admin_id): bool
|
||||
{
|
||||
$types=$params['types']??0;
|
||||
if (empty($params['product_arr'])) {
|
||||
throw new BusinessException('请选择商品');
|
||||
}
|
||||
@ -78,22 +81,26 @@ class InventoryTransferOrderLogic extends BaseLogic
|
||||
'two_type' => $params['two_type'],
|
||||
'one_id' => $params['one_id'],
|
||||
'two_id' => $params['two_id'],
|
||||
'types' => $params['types']??0,
|
||||
'types' => $types,
|
||||
'mark' => $params['mark']??'',
|
||||
]);
|
||||
foreach ($insert as $k => $v) {
|
||||
$insert[$k]['oid'] = $order['id'];
|
||||
}
|
||||
InventoryTransfer::insertAll($insert);
|
||||
if($types==1){
|
||||
Db::commit();
|
||||
return true;
|
||||
}
|
||||
foreach ($insert as $v) {
|
||||
if($params['one_type']==1){
|
||||
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find();
|
||||
$find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]);
|
||||
SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id);
|
||||
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find();
|
||||
$find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]);
|
||||
SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id);
|
||||
} elseif ($params['one_type'] == 2) {
|
||||
$find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find();
|
||||
$find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]);
|
||||
SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id);
|
||||
$find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find();
|
||||
$find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]);
|
||||
SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id);
|
||||
}
|
||||
if($params['two_type']==1){
|
||||
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['two_id'])->find();
|
||||
@ -185,6 +192,28 @@ class InventoryTransferOrderLogic extends BaseLogic
|
||||
*/
|
||||
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 == '') {
|
||||
$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();
|
||||
if ($purchaseProductOffer) {
|
||||
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
||||
@ -104,6 +104,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@
|
||||
namespace app\api\logic;
|
||||
|
||||
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_product\StoreProduct;
|
||||
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_storege\WarehouseProductStorege;
|
||||
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 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;//预订单转订单
|
||||
|
||||
|
||||
/**
|
||||
* 收入支出类型
|
||||
|
@ -284,8 +284,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
// self::dealProductLog($order);
|
||||
|
||||
if ($order->pay_type == 7) {
|
||||
$openid=UserAuth::where('user_id',$order['uid'])->value('openid');
|
||||
if($openid){
|
||||
$openid = UserAuth::where('user_id', $order['uid'])->value('openid');
|
||||
if ($openid) {
|
||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $openid, 'logistics_type' => 4]);
|
||||
}
|
||||
}
|
||||
@ -326,8 +326,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
UserSignLogic::RefundRecharge($orderRe);
|
||||
return true;
|
||||
}
|
||||
$refund=bcdiv($extra['amount']['refund'], 100, 2);
|
||||
if($refund==$order['pay_price']){
|
||||
$refund = bcdiv($extra['amount']['refund'], 100, 2);
|
||||
if ($refund == $order['pay_price']) {
|
||||
$order->status = OrderEnum::REFUND_PAY;
|
||||
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
|
||||
$order->refund_price = $refund;
|
||||
@ -351,7 +351,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
// $user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
// $capitalFlowDao = new CapitalFlowLogic($user);
|
||||
// $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1);
|
||||
// self::addStock($order['id']); //微信
|
||||
self::addStock($order['id'], $order);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
self::addStock($order['id'], $order);
|
||||
}
|
||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
@ -389,7 +389,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
self::addStock($order['id'], $order);
|
||||
}
|
||||
UserSignLogic::RefundOrder($order);
|
||||
|
||||
@ -427,7 +427,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$model->status = YesNoEnum::YES;
|
||||
$model->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
self::addStock($order['id'], $order);
|
||||
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
||||
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
||||
|
||||
@ -503,7 +503,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
if ($type == 'wechat') {
|
||||
$cashFlowLogic = new CashFlowLogic();
|
||||
$cashFlowLogic->insert($order['store_id'], $order['price'],$orderSn);
|
||||
$cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn);
|
||||
}
|
||||
|
||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||
@ -626,25 +626,27 @@ class PayNotifyLogic extends BaseLogic
|
||||
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
||||
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
||||
], ['id' => $v['product_id']]);
|
||||
if($storeProduct['product_type']==5){
|
||||
continue;
|
||||
if ($storeProduct['product_type'] == 5) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($branchProduct) {
|
||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||
StoreBranchProduct::update([
|
||||
'stock' => $stock,
|
||||
'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());
|
||||
if ($order['source'] != OrderEnum::SOURCE_20) {
|
||||
if ($branchProduct) {
|
||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||
StoreBranchProduct::update([
|
||||
'stock' => $stock,
|
||||
'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) {
|
||||
@ -662,8 +664,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
if ($order['uid'] != 1) {
|
||||
Redis::send('order_wetcha_push_send', ['order' => $order]);
|
||||
}
|
||||
$xprinter=DictData::where('type_value','xprinter')->where('name','xprinter_'.$order['store_id'])->where('status',1)->find();
|
||||
if($xprinter){
|
||||
$xprinter = DictData::where('type_value', 'xprinter')->where('name', 'xprinter_' . $order['store_id'])->where('status', 1)->find();
|
||||
if ($xprinter) {
|
||||
Redis::send('order_xprinter_push_send', ['order' => $order]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@ -868,8 +870,11 @@ class PayNotifyLogic extends BaseLogic
|
||||
* @throws \think\db\exception\DbException
|
||||
* @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 = [];
|
||||
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
|
||||
foreach ($goods_list as $v) {
|
||||
@ -883,14 +888,14 @@ class PayNotifyLogic extends BaseLogic
|
||||
$updateData[] = [
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||
'sales' => ['dec', $v['cart_num']]
|
||||
'sales' => ['dec', $v['cart_num']]
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
(new StoreBranchProduct())->saveAll($updateData);
|
||||
SqlChannelLog('StoreBranchProduct',0,0,1,Request()->url());
|
||||
SqlChannelLog('StoreBranchProduct', 0, 0, 1, Request()->url());
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ class BeforehandOrderController extends BaseAdminController
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$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);
|
||||
return $this->dataLists(new BeforehandOrderLists());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user