feat: 添加订单存储功能
This commit is contained in:
parent
5d5b2a28ca
commit
af75268604
@ -156,7 +156,6 @@ class OrderLogic extends BaseLogic
|
|||||||
'order_id' => $params['order_id'] ?? getNewOrderId('PF'),
|
'order_id' => $params['order_id'] ?? getNewOrderId('PF'),
|
||||||
'total_price' => self::$total_price, //总价
|
'total_price' => self::$total_price, //总价
|
||||||
'cost' => self::$cost, //成本价1-
|
'cost' => self::$cost, //成本价1-
|
||||||
'profit' =>0, //利润
|
|
||||||
'pay_price' => $pay_price, //后期可能有降价抵扣
|
'pay_price' => $pay_price, //后期可能有降价抵扣
|
||||||
'vip_price' => 0,
|
'vip_price' => 0,
|
||||||
'total_num' => count($cart_select), //总数
|
'total_num' => count($cart_select), //总数
|
||||||
@ -170,6 +169,7 @@ class OrderLogic extends BaseLogic
|
|||||||
'activities' => self::$activity_price>0?1:0,
|
'activities' => self::$activity_price>0?1:0,
|
||||||
'deduction_price' => self::$activity_price,
|
'deduction_price' => self::$activity_price,
|
||||||
'is_vip' => 0,
|
'is_vip' => 0,
|
||||||
|
'is_storage' => $params['is_storage']??0,
|
||||||
];
|
];
|
||||||
$order['default_delivery'] = 0;
|
$order['default_delivery'] = 0;
|
||||||
if ($params['store_id']) {
|
if ($params['store_id']) {
|
||||||
|
@ -7,6 +7,7 @@ use app\common\enum\OrderEnum;
|
|||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
use app\common\enum\user\UserShipEnum;
|
use app\common\enum\user\UserShipEnum;
|
||||||
use app\common\enum\YesNoEnum;
|
use app\common\enum\YesNoEnum;
|
||||||
|
use app\common\logic\user_product_storage\UserProductStorageLogic;
|
||||||
use app\common\model\Config;
|
use app\common\model\Config;
|
||||||
use app\common\model\dict\DictType;
|
use app\common\model\dict\DictType;
|
||||||
use app\common\model\finance\CapitalFlow;
|
use app\common\model\finance\CapitalFlow;
|
||||||
@ -73,6 +74,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if (!$order->save()) {
|
if (!$order->save()) {
|
||||||
throw new \Exception('订单保存出错');
|
throw new \Exception('订单保存出错');
|
||||||
}
|
}
|
||||||
|
if($order['is_storage']==1){
|
||||||
|
$order->status=2;
|
||||||
|
UserProductStorageLogic::add($order);
|
||||||
|
}
|
||||||
// 减去余额
|
// 减去余额
|
||||||
$user->now_money = bcsub($user['now_money'], $order['pay_price'], 2);
|
$user->now_money = bcsub($user['now_money'], $order['pay_price'], 2);
|
||||||
$user->save();
|
$user->save();
|
||||||
@ -166,6 +171,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if (!$order->save()) {
|
if (!$order->save()) {
|
||||||
throw new \Exception('订单保存出错');
|
throw new \Exception('订单保存出错');
|
||||||
}
|
}
|
||||||
|
if($order['is_storage']==1){
|
||||||
|
$order->status=2;
|
||||||
|
UserProductStorageLogic::add($order);
|
||||||
|
}
|
||||||
// 减去采购款
|
// 减去采购款
|
||||||
$user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2);
|
$user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2);
|
||||||
$user->save();
|
$user->save();
|
||||||
@ -219,6 +228,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$user = User::where('id', $order['uid'])->find();
|
$user = User::where('id', $order['uid'])->find();
|
||||||
if ($order->pay_type == OrderEnum::CASHIER_ORDER_PAY || $order->pay_type == OrderEnum::CASHIER_ORDER_ALI_PAY) { //收银台支付
|
if ($order->pay_type == OrderEnum::CASHIER_ORDER_PAY || $order->pay_type == OrderEnum::CASHIER_ORDER_ALI_PAY) { //收银台支付
|
||||||
$order->status = 2;
|
$order->status = 2;
|
||||||
|
$order->save();
|
||||||
self::afterPay($order, $extra['transaction_id']);
|
self::afterPay($order, $extra['transaction_id']);
|
||||||
} else {
|
} else {
|
||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
@ -231,15 +241,6 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
self::descStock($order['id']);
|
self::descStock($order['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($order->pay_type == 9) {
|
|
||||||
// $extra['create_time'] = $order['create_time'];
|
|
||||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
|
||||||
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
|
|
||||||
// }
|
|
||||||
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\logic\user_product_storage;
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
|
use app\common\model\user_product_storage\UserProductStorage;
|
||||||
|
use app\common\model\user_product_storage_log\UserProductStorageLog;
|
||||||
|
|
||||||
|
class UserProductStorageLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
public static function add($order){
|
||||||
|
$arr=StoreOrderCartInfo::where('oid',$order['id'])->field('product_id,cart_num nums')->select();
|
||||||
|
if($arr){
|
||||||
|
$data=$arr;
|
||||||
|
$data_log=$arr;
|
||||||
|
|
||||||
|
foreach ($data as $k=>$v){
|
||||||
|
$data[$k]['uid']=$order['uid'];
|
||||||
|
$data[$k]['oid']=$order['id'];
|
||||||
|
$data[$k]['status']=1;
|
||||||
|
$data_log[$k]['uid']=$order['uid'];
|
||||||
|
$data_log[$k]['oid']=$order['id'];
|
||||||
|
$data_log[$k]['financial_pm']=1;
|
||||||
|
}
|
||||||
|
UserProductStorage::insertAll($data);
|
||||||
|
UserProductStorageLog::insertAll($data_log);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\logic\user_product_storage_log;
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
|
||||||
|
class UserProductStorageLogLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
20
app/common/model/user_product_storage/UserProductStorage.php
Normal file
20
app/common/model/user_product_storage/UserProductStorage.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\user_product_storage;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户商品储存
|
||||||
|
* Class UserProductStorage
|
||||||
|
* @package app\common\model\user_product_storage
|
||||||
|
*/
|
||||||
|
class UserProductStorage extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'user_product_storage';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\user_product_storage_log;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户商品储存操作日志
|
||||||
|
* Class UserProductStorageLog
|
||||||
|
* @package app\common\model\user_product_storage_log
|
||||||
|
*/
|
||||||
|
class UserProductStorageLog extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'user_product_storage_log';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user