commit
7590d65b49
@ -6,8 +6,10 @@ namespace app\admin\controller\beforehand_order_cart_info;
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists;
|
||||
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
|
||||
/**
|
||||
* 预订单购物详情表控制器
|
||||
@ -65,11 +67,34 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
||||
|
||||
$res=BeforehandOrderCartInfo::where('id',$id)->find();
|
||||
$find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find();
|
||||
if (empty($find)) {
|
||||
$rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$res['bhoid']}}')";
|
||||
$find = PurchaseProductOffer::where(['product_id' => $res['product_id']])->whereRaw($rawSql)->find();
|
||||
}
|
||||
if($find){
|
||||
if($find['buyer_confirm']==1){
|
||||
return $this->fail('该商品已采购完成,无法更改状态');
|
||||
}else{
|
||||
PurchaseProductOffer::where('id',$find['id'])->update(['delete_time'=>time()]);
|
||||
if (!empty($find['source_order_info'])) {
|
||||
$json = $find['source_order_info'];
|
||||
foreach ($json as $key => $value) {
|
||||
if ($value['source_order_id'] == $res['bhoid']) {
|
||||
$find->need_num = $find->need_num - $value['need_num'];
|
||||
unset($json[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$find->source_order_info = array_values($json);
|
||||
$productPrice = StoreProduct::where('id',$res['product_id'])->value('price');
|
||||
$procurementOrder = BeforehandOrder::where('id', $find['order_id'])->find();
|
||||
$procurementOrder->total_price = bcsub($procurementOrder->total_price, bcmul($productPrice, $res['cart_num'], 2), 2);
|
||||
$procurementOrder->pay_price = $procurementOrder->total_price;
|
||||
$procurementOrder->save();
|
||||
}
|
||||
if ($find->need_num <= 0) {
|
||||
$find->delete_time = time();
|
||||
}
|
||||
$find->save();
|
||||
}
|
||||
}
|
||||
$res->save(['is_buyer'=>-1]);
|
||||
|
@ -81,9 +81,9 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
|
||||
$oid=WarehouseOrder::where('financial_pm',0)->where('code','like','%'.$order_ck)->column('id');
|
||||
$this->searchWhere[] = ['outbound_id','in',$oid];
|
||||
}
|
||||
$file=['id', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file'];
|
||||
$file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file'];
|
||||
if($export==2){
|
||||
$file=['id', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data'];
|
||||
$file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data'];
|
||||
}
|
||||
return BeforehandOrder::where($this->searchWhere)
|
||||
->field($file)
|
||||
|
@ -92,7 +92,11 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
$item['top_cate_id'] = $find['top_cate_id'];
|
||||
$item['top_cate_name'] = StoreCategory::where('id', $item['top_cate_id'])->value('name');
|
||||
if ($item->bhoid) {
|
||||
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
|
||||
$rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$item->bhoid}}')";
|
||||
$status = PurchaseProductOffer::where(['product_id' => $item->product_id])->whereRaw($rawSql)->value('status');
|
||||
if (is_null($status)) {
|
||||
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
|
||||
}
|
||||
if ($status == 1) {
|
||||
$item->status_name = '已完成';
|
||||
} else {
|
||||
|
@ -22,6 +22,7 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\model\warehouse_product_return\WarehouseProductReturn;
|
||||
@ -370,6 +371,9 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
if ($count > 0) {
|
||||
throw new BusinessException('订单中有数量为0的商品,请先处理');
|
||||
}
|
||||
if($order['uid']>0){
|
||||
$user_ship=User::where('id', $order['uid'])->value('user_ship')??0;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr = [
|
||||
@ -386,6 +390,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$arr['delivery_time'] = strtotime($delivery_time);
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($info as $key => $arr) {
|
||||
$price=StoreProductGroupPrice::where('product_id',$arr['product_id'])->where('group_id',$user_ship)->value('price')??0;
|
||||
$data = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'product_id' => $arr['product_id'],
|
||||
@ -398,6 +403,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
'admin_id' => $admin_id,
|
||||
'total_price' => $arr['total_price'],
|
||||
'price' => $arr['price'],
|
||||
'vip_price' => $price==0?$arr['price']:$price,
|
||||
'purchase' => $arr['purchase'],
|
||||
'oid' => $res['id'],
|
||||
'code' => $res['code'],
|
||||
@ -888,6 +894,10 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$order['pay_price'] = $pay_price;
|
||||
$order['total_profit'] = $total_profit;
|
||||
$order['total_price'] = $total_price;
|
||||
$order['group_title'] = '';
|
||||
if($user_ship){
|
||||
$order['group_title'] = UserShip::where('id',$user_ship)->value('title');
|
||||
}
|
||||
$file_path = $order_info->export($data, $order, $other_data, 2);
|
||||
return $file_path;
|
||||
}
|
||||
|
@ -244,7 +244,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
WarehouseProductLogic::add($data);
|
||||
PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]);
|
||||
}
|
||||
BeforehandOrder::where('id', $params['bhoid'])->update(['warehousing_id' => $res['id'],'is_warehousing'=>1]);
|
||||
$attrs = ['warehousing_id' => $res['id'],'is_warehousing'=>1];
|
||||
if ($beforehandOrder['order_type'] == 7) {
|
||||
$attrs['is_buying'] = 1;
|
||||
}
|
||||
BeforehandOrder::where('id', $params['bhoid'])->update($attrs);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
|
@ -41,26 +41,64 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$procurementOrder = BeforehandOrder::where('order_type', 7)->where('is_buying', 0)->where('create_time', '>=', strtotime('-3 days'))->find();
|
||||
if (empty($procurementOrder)) {
|
||||
$beforeOrder = BeforehandOrder::where('id', $params['order_id'])->findOrEmpty()->toArray();
|
||||
unset($beforeOrder['id'], $beforeOrder['create_time'], $beforeOrder['update_time']);
|
||||
$procurementOrder = new BeforehandOrder();
|
||||
$procurementOrder->setAttrs($beforeOrder);
|
||||
$procurementOrder->order_id = getNewOrderId('CG');
|
||||
$procurementOrder->order_type = 7;
|
||||
$procurementOrder->total_price = 0;
|
||||
$procurementOrder->pay_price = 0;
|
||||
$procurementOrder->save();
|
||||
}
|
||||
$mark = $params['mark'] ?? '';
|
||||
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();
|
||||
PurchaseProductOffer::create([
|
||||
'order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'unit' => $params['unit'],
|
||||
'is_buyer' => $params['is_buyer'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
'buyer_id' => $params['buyer_id'],
|
||||
'package' => $find['package'],
|
||||
'store_info' => $find['store_info'],
|
||||
'marques' => $find['marques'],
|
||||
'after_sales' => $find['after_sales'],
|
||||
'status' => 0,
|
||||
|
||||
]);
|
||||
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
||||
$procurementOrder->total_price = bcadd($procurementOrder->total_price, bcmul($find['price'], $params['need_num'], 2), 2);
|
||||
$procurementOrder->pay_price = $procurementOrder->total_price;
|
||||
$procurementOrder->save();
|
||||
if ($purchaseProductOffer) {
|
||||
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
||||
if (!empty($purchaseProductOffer['source_order_info'])) {
|
||||
$sourceOrderInfo = $purchaseProductOffer['source_order_info'];
|
||||
$sourceOrderInfo[] = [
|
||||
'source_order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
];
|
||||
$purchaseProductOffer->source_order_info = $sourceOrderInfo;
|
||||
}
|
||||
$purchaseProductOffer->save();
|
||||
} else {
|
||||
PurchaseProductOffer::create([
|
||||
'order_id' => $procurementOrder['id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'unit' => $params['unit'],
|
||||
'is_buyer' => $params['is_buyer'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
'buyer_id' => $params['buyer_id'],
|
||||
'package' => $find['package'],
|
||||
'store_info' => $find['store_info'],
|
||||
'marques' => $find['marques'],
|
||||
'after_sales' => $find['after_sales'],
|
||||
'status' => 0,
|
||||
'source_order_info' => [
|
||||
[
|
||||
'source_order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
BeforehandOrderCartInfo::where(['bhoid' => $params['order_id'], 'product_id' => $params['product_id']])->update(['is_buyer' => 1]);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -167,6 +167,7 @@ class WarehouseProductLogic extends BaseLogic
|
||||
'after_nums' => $after_nums,
|
||||
'price' => $params['price'] ?? 0,
|
||||
'purchase' => $params['purchase'] ?? 0,
|
||||
'vip_price' => $params['vip_price'] ?? 0,
|
||||
'total_price' => $params['total_price'] ?? 0,
|
||||
'admin_id' => $params['admin_id'],
|
||||
'code' => $params['code'] ?? '',
|
||||
|
@ -18,5 +18,7 @@ class PurchaseProductOffer extends BaseModel
|
||||
protected $name = 'purchase_product_offer';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
protected $json = ['source_order_info'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
}
|
@ -83,6 +83,8 @@ class OrderSupplyOutbound
|
||||
$sheet->setCellValue('A' . ($count + 4),'合计');
|
||||
$sheet->setCellValue('B' . ($count + 4),$count);
|
||||
|
||||
$sheet->setCellValue('J' . ($count + 4),$order['group_title']??'');
|
||||
|
||||
$sheet->setCellValue('A' . ($count + 5),'累计接单:');
|
||||
$sheet->setCellValue('C' . ($count + 5),'预收金额:');
|
||||
$sheet->setCellValue('D' . ($count + 5),0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user