feat: 更新了用户商品存储逻辑和支付通知逻辑
This commit is contained in:
parent
f330790647
commit
30cbd5eafe
@ -52,8 +52,10 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
->select()->each(function($item){
|
||||
$user=User::where('id',$item['uid'])->field('nickname,real_name')->find();
|
||||
$item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid'];
|
||||
$item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name');
|
||||
$item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name');
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,price')->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
$item['price']=$find['price'];
|
||||
if($item['status']==1){
|
||||
$item['status_name']='正常';
|
||||
}else{
|
||||
|
@ -251,7 +251,7 @@ class UserController extends BaseApiController
|
||||
public function other_user_info(){
|
||||
$mobile=$this->request->get('mobile');
|
||||
if($mobile){
|
||||
$user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds')->find();
|
||||
$user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds,label_id')->find();
|
||||
if($user){
|
||||
$user['address_info']=UserAddress::where('uid',$user['id'])->where('is_default',1)->find();
|
||||
}
|
||||
|
@ -99,7 +99,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
// self::descStock($order['id']);
|
||||
// }
|
||||
self::afterPay($order);
|
||||
UserProductStorageLogic::add($order);
|
||||
if ($extra && $extra['store_id']) {
|
||||
$params = [
|
||||
'verify_code' => $order['verify_code'],
|
||||
@ -200,7 +199,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
// }
|
||||
// self::addUserSing($order);
|
||||
self::afterPay($order);
|
||||
UserProductStorageLogic::add($order);
|
||||
if ($extra && $extra['store_id']) {
|
||||
$params = [
|
||||
'verify_code' => $order['verify_code'],
|
||||
@ -403,7 +401,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
$order->save();
|
||||
self::afterPay($order, $extra['transaction_id']);
|
||||
UserProductStorageLogic::add($order);
|
||||
// self::addUserSing($order);
|
||||
self::dealProductLog($order);
|
||||
if ($order['shipping_type'] == 3) {
|
||||
@ -705,7 +702,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
throw new \Exception('订单保存出错');
|
||||
}
|
||||
self::afterPay($order);
|
||||
UserProductStorageLogic::add($order);
|
||||
if($order['is_storage']==1){
|
||||
UserProductStorageLogic::add($order);
|
||||
}
|
||||
$cashFlowLogic = new CashFlowLogic();
|
||||
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
||||
self::dealProductLog($order);
|
||||
|
@ -150,6 +150,11 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
if($deposit){
|
||||
SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update();
|
||||
}
|
||||
$find=StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>16])->find();
|
||||
if($find){
|
||||
$find->update(['status' => 1]);
|
||||
SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ 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;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 用户商品储存逻辑
|
||||
@ -36,4 +36,36 @@ class UserProductStorageLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库
|
||||
*/
|
||||
public static function supply($data,$uid,$store_id){
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data_log=[];
|
||||
foreach ($data as $k=>$v){
|
||||
$find=UserProductStorage::where('uid',$uid)->where('product_id',$v['product_id'])->find();
|
||||
if($find){
|
||||
if($find['nums']<$v['nums']){
|
||||
self::setError('库存不足');
|
||||
return false;
|
||||
}
|
||||
$find->nums=bcsub($find['nums'],$v['nums']);
|
||||
$find->saver();
|
||||
$data_log[$k]['uid']=$uid;
|
||||
$data_log[$k]['oid']=$find['oid'];
|
||||
$data_log[$k]['product_id']=$find['product_id'];
|
||||
$data_log[$k]['store_id']=$store_id;
|
||||
$data_log[$k]['financial_pm']=0;
|
||||
$data_log[$k]['nums']=$v['nums'];
|
||||
}
|
||||
}
|
||||
(new UserProductStorageLog())->saveAll($data_log);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\controller\user_product_storage;
|
||||
|
||||
|
||||
use app\store\controller\BaseAdminController;
|
||||
use app\admin\lists\user_product_storage\UserProductStorageLists;
|
||||
use app\common\logic\user_product_storage\UserProductStorageLogic;
|
||||
|
||||
/**
|
||||
* 用户商品储存控制器
|
||||
* Class UserProductStorageController
|
||||
* @package app\admin\controller\user_product_storage
|
||||
*/
|
||||
class UserProductStorageController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户商品储存列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/28 11:05
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new UserProductStorageLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库
|
||||
*/
|
||||
public function supply(){
|
||||
|
||||
$params=$this->request->post();
|
||||
$info=$params['info'];
|
||||
$uid=$params['uid'];
|
||||
$store_id=$this->adminInfo['store_id'];
|
||||
d($params);
|
||||
UserProductStorageLogic::supply($info,$uid,$store_id);
|
||||
if(UserProductStorageLogic::hasError()){
|
||||
return $this->fail(UserProductStorageLogic::getError());
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
}
|
@ -58,12 +58,14 @@ class WorkbenchLogic extends BaseLogic
|
||||
$cashFinanceWhere = [];
|
||||
$storeFinanceWhere = ['financial_type'=>2,'financial_pm'=>1];
|
||||
$storeFinanceWhereTwo = ['financial_type'=>11,'financial_pm'=>0];
|
||||
$attritionWhere=[];
|
||||
if ($params['store_id'] != 0) {
|
||||
$where['store_id'] = $params['store_id'];
|
||||
$userRechargeWhere['store_id'] = $params['store_id'];
|
||||
$cashFinanceWhere = ['store_id' => $params['store_id']];
|
||||
$storeFinanceWhere['store_id'] = $params['store_id'];
|
||||
$storeFinanceWhereTwo['store_id'] = $params['store_id'];
|
||||
$attritionWhere['store_id'] = $params['store_id'];
|
||||
}
|
||||
$orderLogic = new StoreOrderLogic();
|
||||
//订单总金额
|
||||
@ -89,6 +91,8 @@ class WorkbenchLogic extends BaseLogic
|
||||
// $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price');
|
||||
//保证金金额
|
||||
$data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');
|
||||
/**门店损耗金 */
|
||||
$data['attrition_amount'] = SystemStore::where($attritionWhere)->sum('attrition');
|
||||
//门店成交用户数
|
||||
$data['user_number'] = StoreOrder::where($where)
|
||||
->whereBetweenTime('pay_time', $startTime, $endTime)
|
||||
|
Loading…
x
Reference in New Issue
Block a user