This commit is contained in:
liu 2024-06-24 18:25:46 +08:00
commit 8837310fd6
5 changed files with 73 additions and 44 deletions

View File

@ -12,6 +12,7 @@ use app\api\validate\UserValidate;
use app\common\enum\PayEnum; use app\common\enum\PayEnum;
use app\common\logic\PaymentLogic; use app\common\logic\PaymentLogic;
use app\common\logic\PayNotifyLogic; use app\common\logic\PayNotifyLogic;
use app\common\model\Config;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\model\user_create_log\UserCreateLog; use app\common\model\user_create_log\UserCreateLog;
use app\common\model\user_recharge\UserRecharge; use app\common\model\user_recharge\UserRecharge;
@ -80,7 +81,7 @@ class StoreController extends BaseApiController
'uid'=>$find['id'], 'uid'=>$find['id'],
'staff_id'=>0, 'staff_id'=>0,
'order_id'=>getNewOrderId('CZ'), 'order_id'=>getNewOrderId('CZ'),
'price'=>1000, 'price'=>Config::where('name','recharge')->value('value')??1000,
'recharge_type'=>'INDUSTRYMEMBERS', 'recharge_type'=>'INDUSTRYMEMBERS',
]; ];
$order = UserRecharge::create($data); $order = UserRecharge::create($data);

View File

@ -10,6 +10,7 @@ use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\cate\Cate; use app\common\model\cate\Cate;
use app\common\model\Config;
//use app\common\model\goods\GoodsLabel; //use app\common\model\goods\GoodsLabel;
use think\facade\Db; use think\facade\Db;
@ -102,11 +103,16 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
$this->searchWhere[] = ['cate_id','=',$class_all]; $this->searchWhere[] = ['cate_id','=',$class_all];
} }
} }
$off_activity=Config::where('name','off_activity')->value('value');
if($off_activity==1){
$field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch';
}else{
$field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch';
}
$this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['status', '=', 1];
$this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['stock', '>', 0];
return StoreBranchProduct::where($this->searchWhere) return StoreBranchProduct::where($this->searchWhere)
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->field($field)
->with(['className', 'unitName']) ->with(['className', 'unitName'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder) ->order($this->sortOrder)

View File

@ -10,6 +10,7 @@ use app\common\logic\BaseLogic;
use app\common\logic\CapitalFlowLogic; use app\common\logic\CapitalFlowLogic;
use app\common\logic\PayNotifyLogic; use app\common\logic\PayNotifyLogic;
use app\common\logic\StoreFinanceFlowLogic; use app\common\logic\StoreFinanceFlowLogic;
use app\common\model\Config;
use app\common\model\dict\DictData; use app\common\model\dict\DictData;
use app\common\model\dict\DictType; use app\common\model\dict\DictType;
use app\common\model\order\Cart; use app\common\model\order\Cart;
@ -73,9 +74,14 @@ class OrderLogic extends BaseLogic
self::$activity_price = 0; //活动减少 self::$activity_price = 0; //活动减少
self::$store_price = 0; //门店零售价 self::$store_price = 0; //门店零售价
/** 计算价格 */ /** 计算价格 */
$off_activity=Config::where('name','off_activity')->value('value');
if($off_activity==1){
$field='id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
}else{
$field='id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id';
}
foreach ($cart_select as $k => $v) { foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
if (!$find) { if (!$find) {
continue; continue;
} }
@ -86,6 +92,7 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
$cart_select[$k]['vip'] = 0; $cart_select[$k]['vip'] = 0;
if($off_activity!=1){
if ($user && $user['user_ship'] == 1) { if ($user && $user['user_ship'] == 1) {
//更新 会员为1的时候原价减去会员价 //更新 会员为1的时候原价减去会员价
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
@ -99,6 +106,7 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['deduction_price'] =$deduction_price_count; $cart_select[$k]['deduction_price'] =$deduction_price_count;
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
} }
}
//利润 //利润
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润

View File

@ -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\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;
use app\common\model\finance\PayNotifyLog; use app\common\model\finance\PayNotifyLog;
@ -300,7 +301,6 @@ class PayNotifyLogic extends BaseLogic
//退款 //退款
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
} }
} }
//微信日志 user_order_refund //微信日志 user_order_refund
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
@ -333,7 +333,6 @@ class PayNotifyLogic extends BaseLogic
$value['create_time'] = time(); $value['create_time'] = time();
} }
(new StoreFinanceFlow)->saveAll($data); (new StoreFinanceFlow)->saveAll($data);
} }
/** /**
@ -515,6 +514,27 @@ class PayNotifyLogic extends BaseLogic
{ {
$financeLogic = new StoreFinanceFlowLogic(); $financeLogic = new StoreFinanceFlowLogic();
$user_sing = new UserSign(); $user_sing = new UserSign();
$off_activity = Config::where('name', 'off_activity')->value('value');
if ($off_activity == 1) {
//-----活动价结算更改
$financeLogic->order = $order;
$financeLogic->user = ['uid' => $order['uid']];
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
if ($order['uid'] > 0) {
$user_number = bcmul($order['pay_price'], '0.10', 2);
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '购买商品获得兑换券',
'store_id' => $order['store_id'],
'number' => $user_number,
];
$user_sing->save($sing);
}
return false;
}
$vipFen = 0; $vipFen = 0;
if ($order['uid'] > 0) { if ($order['uid'] > 0) {
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去

View File

@ -345,12 +345,6 @@ class StoreOrderController extends BaseAdminController
*/ */
public function rechange_amount() public function rechange_amount()
{ {
// $order = UserRecharge::where('order_id','CZ1719052252643357')->find();
// $order['pay_price'] = $order['price'];
// d(1);
// PayNotifyLogic::handle('recharge', $order['order_id'], $order);
// d(1);
$pay_type = $this->request->post('pay_type'); $pay_type = $this->request->post('pay_type');
$auth_code = $this->request->post('auth_code'); //微信支付条码 $auth_code = $this->request->post('auth_code'); //微信支付条码
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) { if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) {