修改库存调拨商品列表,预订单添加同步价格
This commit is contained in:
parent
88bb49563b
commit
ed9ffc8d8c
@ -166,7 +166,14 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = $this->request->get();
|
$params = $this->request->get();
|
||||||
BeforehandOrderCartInfoLogic::fixAcceptNum($params);
|
BeforehandOrderCartInfoLogic::fixAcceptNum($params);
|
||||||
return $this->data([]);
|
return $this->success('操作成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function syncPrice()
|
||||||
|
{
|
||||||
|
$params = $this->request->get();
|
||||||
|
BeforehandOrderCartInfoLogic::syncPrice($params);
|
||||||
|
return $this->success('操作成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ namespace app\admin\lists\store_order;
|
|||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\enum\OrderEnum;
|
use app\common\enum\OrderEnum;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
@ -31,7 +32,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id', 'paid', 'status', 'is_writeoff', 'is_merge', 'uid', 'source'],
|
'=' => ['store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id', 'paid', 'status', 'is_writeoff', 'is_merge', 'uid'],
|
||||||
'between_time' => 'create_time',
|
'between_time' => 'create_time',
|
||||||
'%like%' => ['order_id'],
|
'%like%' => ['order_id'],
|
||||||
];
|
];
|
||||||
@ -52,6 +53,14 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
if ($this->request->get('is_delivery') >= 1) {
|
if ($this->request->get('is_delivery') >= 1) {
|
||||||
$this->searchWhere[] = ['delivery_uid', '>', 0];
|
$this->searchWhere[] = ['delivery_uid', '>', 0];
|
||||||
}
|
}
|
||||||
|
if (!empty($this->params['source'])) {
|
||||||
|
if ($this->params['source'] < 10) {
|
||||||
|
$this->searchWhere[] = ['source', $this->params['source']];
|
||||||
|
} else {
|
||||||
|
$orderType = substr($this->params['source'], 1);
|
||||||
|
$this->searchWhere[] = ['order_type', $orderType];
|
||||||
|
}
|
||||||
|
}
|
||||||
return StoreOrder::with(['staff', 'store'])->where($this->searchWhere)
|
return StoreOrder::with(['staff', 'store'])->where($this->searchWhere)
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
@ -64,7 +73,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
$query->whereIn('status', $status);
|
$query->whereIn('status', $status);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'source', 'pay_price', 'total_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'create_time', 'delivery_name', 'delivery_id', 'refund_price'])
|
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'source', 'pay_price', 'total_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'create_time', 'delivery_name', 'delivery_id', 'refund_price', 'order_type'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
@ -91,6 +100,9 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
} else {
|
} else {
|
||||||
$item['source_name'] = '普通订单';
|
$item['source_name'] = '普通订单';
|
||||||
}
|
}
|
||||||
|
if (!empty($item['order_type'])) {
|
||||||
|
$item['source_name'] = BeforehandOrder::getOrderTypeName($item['order_type']);
|
||||||
|
}
|
||||||
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
|
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
|
||||||
->limit(3)->select();
|
->limit(3)->select();
|
||||||
foreach ($product as &$items) {
|
foreach ($product as &$items) {
|
||||||
|
@ -260,6 +260,7 @@ class BeforehandOrderLogic extends BaseLogic
|
|||||||
'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提
|
'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提
|
||||||
'deduction_price' => 0, //抵扣金额
|
'deduction_price' => 0, //抵扣金额
|
||||||
'source' => 2, //后台下单
|
'source' => 2, //后台下单
|
||||||
|
'order_type' => $order['order_type'],
|
||||||
'is_storage' => 0,
|
'is_storage' => 0,
|
||||||
'verify_code' => createCode($code),
|
'verify_code' => createCode($code),
|
||||||
];
|
];
|
||||||
|
@ -317,4 +317,26 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function syncPrice($params)
|
||||||
|
{
|
||||||
|
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('price', 0)->select()->toArray();
|
||||||
|
$productIds = array_column($cartInfo, 'product_id');
|
||||||
|
$products = StoreProduct::whereIn('id', $productIds)->select()->toArray();
|
||||||
|
$products = reset_index($products, 'id');
|
||||||
|
$update = [];
|
||||||
|
foreach ($cartInfo as $v) {
|
||||||
|
$product = $products[$v['product_id']];
|
||||||
|
if (empty($product) || empty($product['price'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$update[] = [
|
||||||
|
'id' => $v['id'],
|
||||||
|
'price' => $product['price'],
|
||||||
|
'total_price' => $product['price'] * $v['cart_num'],
|
||||||
|
'pay_price' => $product['price'] * $v['cart_num'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
(new BeforehandOrderCartInfo())->saveAll($update);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ namespace app\admin\logic\warehouse_product_storege;
|
|||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use Webman\Exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库商品存储逻辑
|
* 仓库商品存储逻辑
|
||||||
@ -39,12 +39,15 @@ class WarehouseProductStoregeLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function edit(array $params,$admin_id=0): bool
|
public static function edit(array $params,$admin_id=0): bool
|
||||||
{
|
{
|
||||||
|
if (empty($params['remark'])) {
|
||||||
|
throw new BusinessException('请输入备注');
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$find=WarehouseProductStorege::where('id',$params['id'])->find();
|
$find=WarehouseProductStorege::where('id',$params['id'])->find();
|
||||||
if($find){
|
if($find){
|
||||||
$find->save(['nums'=>$params['nums']]);
|
$find->save(['nums'=>$params['nums']]);
|
||||||
SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url(),$admin_id);
|
SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url(),$admin_id, $params['remark']);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,7 +7,7 @@ use app\common\model\change_log\ChangeLog;
|
|||||||
class ChangeLogLogic extends BaseLogic
|
class ChangeLogLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public function insert($model='',$link_id=0,$nums=0,$pm=0,$url='',$admin_id=0):void
|
public function insert($model='',$link_id=0,$nums=0,$pm=0,$url='',$admin_id=0, $remark = ''):void
|
||||||
{
|
{
|
||||||
$info=\Chance\Log\facades\OperationLog::getLog();
|
$info=\Chance\Log\facades\OperationLog::getLog();
|
||||||
ChangeLog::create([
|
ChangeLog::create([
|
||||||
@ -16,6 +16,7 @@ class ChangeLogLogic extends BaseLogic
|
|||||||
'nums' => $nums,
|
'nums' => $nums,
|
||||||
'pm' => $pm,
|
'pm' => $pm,
|
||||||
'mark' => $info,
|
'mark' => $info,
|
||||||
|
'remark' => $remark,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'admin_id' => $admin_id,
|
'admin_id' => $admin_id,
|
||||||
'create_time' => time()
|
'create_time' => time()
|
||||||
|
@ -20,5 +20,19 @@ class BeforehandOrder extends BaseModel
|
|||||||
protected $json = ['other_data'];
|
protected $json = ['other_data'];
|
||||||
// 不生成该表的日志
|
// 不生成该表的日志
|
||||||
public $doNotRecordLog = true;
|
public $doNotRecordLog = true;
|
||||||
|
|
||||||
|
public static function getOrderTypeName($type)
|
||||||
|
{
|
||||||
|
$typeMap = [
|
||||||
|
1 => '铺货订单',
|
||||||
|
2 => '摊贩订单',
|
||||||
|
3 => '一条龙订单',
|
||||||
|
4 => '线上订单',
|
||||||
|
5 => '仓库补货',
|
||||||
|
6 => '采购订单',
|
||||||
|
7 => '其他订单',
|
||||||
|
];
|
||||||
|
return $typeMap[$type] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user