1
This commit is contained in:
parent
7326ef78e3
commit
975c5b232f
@ -117,7 +117,7 @@ class StoreOrderController extends BaseAdminController
|
||||
*/
|
||||
public function refund()
|
||||
{
|
||||
$params = (new StoreOrderValidate())->goCheck('refund');
|
||||
$params = $this->request->post();
|
||||
$detail = StoreOrder::where('order_id', $params['order_id'])->findOrEmpty();
|
||||
if (empty($detail)) {
|
||||
return $this->fail('无该订单请检查');
|
||||
|
@ -9,8 +9,11 @@ use app\api\logic\order\OrderLogic;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CommissionnLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user\User;
|
||||
@ -53,7 +56,6 @@ class StoreOrderLogic extends BaseLogic
|
||||
$params['pay_type'] = 7;
|
||||
$order = OrderLogic::createOrder($cartId, null, $user, $params);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -112,6 +114,61 @@ class StoreOrderLogic extends BaseLogic
|
||||
|
||||
public static function refund($detail, $params)
|
||||
{
|
||||
if (isset($params['product_arr']) && count($params['product_arr']) > 0) {
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||
if ($find) {
|
||||
$refund_num += $v['cart_num'];
|
||||
$cart_num = bcsub($find['cart_num'], $v['cart_num']);
|
||||
$total_price = bcmul($find['price'], $cart_num);
|
||||
$data = ['cart_num' => $cart_num, 'total_price' => $total_price];
|
||||
StoreOrderCartInfo::where('id', $find['id'])->update($data);
|
||||
$arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$value['cart_num'] = $cart_num;
|
||||
$value['total_price'] = bcmul($cart_num, $value['price'], 2);
|
||||
$value['number'] = bcmul($value['total_price'], $value['rate'], 2);
|
||||
StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]);
|
||||
unset($value['id']);
|
||||
$value['create_time'] = strtotime($value['create_time']);
|
||||
$value['update_time'] = strtotime($value['update_time']);
|
||||
StoreFinanceFlowProduct::create($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
//微信支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::WECHAT_PAY_MINI, PayEnum::WECHAT_PAY_BARCODE])) {
|
||||
$money = (int)bcmul($params['refund_price'], 100);
|
||||
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
|
||||
->refund($params['order_id'], $money, $detail['pay_price']);
|
||||
if ($refund) {
|
||||
return '退款成功';
|
||||
}
|
||||
}
|
||||
//余额支付 采购款支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
PayNotifyLogic::balance_purchase_refund($detail,0,$params['refund_price']);
|
||||
return '退款成功';
|
||||
|
||||
}
|
||||
//现金支付
|
||||
if ($detail['pay_type'] = PayEnum::CASH_PAY) {
|
||||
PayNotifyLogic::cash_refund($params['order_id']);
|
||||
return '退款成功';
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
} else {
|
||||
//微信支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::WECHAT_PAY_MINI, PayEnum::WECHAT_PAY_BARCODE])) {
|
||||
$money = (int)bcmul($detail['pay_price'], 100);
|
||||
@ -124,13 +181,6 @@ class StoreOrderLogic extends BaseLogic
|
||||
}
|
||||
//余额支付 采购款支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
$money = bcmul($detail['pay_price'], 100);
|
||||
$arr = [
|
||||
'amount' => [
|
||||
'refund' => $money
|
||||
]
|
||||
];
|
||||
PayNotifyLogic::refund($params['order_id'], $arr);
|
||||
StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]);
|
||||
return '退款成功';
|
||||
}
|
||||
@ -144,3 +194,39 @@ class StoreOrderLogic extends BaseLogic
|
||||
//todo 支付包支付
|
||||
}
|
||||
}
|
||||
|
||||
public function refundProduct($detail, $params)
|
||||
{
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||
if ($find) {
|
||||
$refund_num += $v['cart_num'];
|
||||
$cart_num = bcsub($find['cart_num'], $v['cart_num']);
|
||||
$total_price = bcmul($find['price'], $cart_num);
|
||||
$data = ['cart_num' => $cart_num, 'total_price' => $total_price];
|
||||
StoreOrderCartInfo::where('id', $find['id'])->update($data);
|
||||
$arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$value['cart_num'] = $cart_num;
|
||||
$value['total_price'] = bcmul($cart_num, $value['price'], 2);
|
||||
$value['number'] = bcmul($value['total_price'], $value['rate'], 2);
|
||||
StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]);
|
||||
unset($value['id']);
|
||||
$value['create_time'] = strtotime($value['create_time']);
|
||||
$value['update_time'] = strtotime($value['update_time']);
|
||||
StoreFinanceFlowProduct::create($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]);
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ class IndexController extends BaseApiController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$moeny=$this->request->get('moeny');
|
||||
$a=User::where('id',366)->update(['now_money'=>$moeny]);
|
||||
return json([1]);
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,7 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['imgs'] = $find['image'];
|
||||
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
|
||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||
$cart_select[$k]['total_price'] =$cart_select[$k]['pay_price'];
|
||||
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
|
||||
|
@ -181,6 +181,10 @@ class CapitalFlowLogic extends BaseLogic
|
||||
return "用户减少{$amount}元";
|
||||
case 'user_withdrawal':
|
||||
return "用户提现{$amount}元";
|
||||
case 'now_money_refund':
|
||||
return "订单退回到余额{$amount}元";
|
||||
case 'purchase_refund':
|
||||
return "订单退回到采购款{$amount}元";
|
||||
default:
|
||||
return "订单支付{$amount}元";
|
||||
}
|
||||
|
@ -55,15 +55,22 @@ class CommissionProductLogic extends BaseLogic
|
||||
// $rose = bcdiv($product['rose'], 100, 2);
|
||||
if($user_ship==4){
|
||||
$total_price = bcmul($product['cost'], $find['cart_num']);
|
||||
$price=$product['cost'];
|
||||
}else{
|
||||
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||
$price=$product['price'];
|
||||
}
|
||||
// $Distribution = Distribution::where('rate', $rose)->find();
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.05,
|
||||
'number' => bcmul($total_price, 0.05, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
@ -71,9 +78,14 @@ class CommissionProductLogic extends BaseLogic
|
||||
];
|
||||
//平台
|
||||
$data[] = [
|
||||
'nickname' => '平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => bcmul($total_price, 0.02, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
@ -81,9 +93,14 @@ class CommissionProductLogic extends BaseLogic
|
||||
];
|
||||
//村长
|
||||
$data[] = [
|
||||
'nickname' => '村长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'price' => $price,
|
||||
'other_uid' => $village_uid,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.01,
|
||||
'number' => bcmul($total_price, 0.01, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 3,
|
||||
@ -91,9 +108,14 @@ class CommissionProductLogic extends BaseLogic
|
||||
];
|
||||
//队长
|
||||
$data[] = [
|
||||
'nickname' => '队长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'price' => $price,
|
||||
'other_uid' => $brigade_uid,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.01,
|
||||
'number' => bcmul($total_price, 0.01, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 4,
|
||||
@ -116,12 +138,17 @@ class CommissionProductLogic extends BaseLogic
|
||||
// ];
|
||||
|
||||
//会员
|
||||
if ($order['spread_uid'] > 0) {
|
||||
if ($order['spread_uid'] > 0 ||$user_ship>0) {
|
||||
if (in_array($user_ship, [2, 3])) {
|
||||
$data[] = [
|
||||
'nickname' => '会员',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'price' => $price,
|
||||
'other_uid' => $order['spread_uid'],
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.05,
|
||||
'number' => bcmul($total_price, 0.05, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
@ -129,9 +156,14 @@ class CommissionProductLogic extends BaseLogic
|
||||
];
|
||||
} else {
|
||||
$data[] = [
|
||||
'nickname' => '会员',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $order['spread_uid'],
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.07,
|
||||
'number' => bcmul($total_price, 0.07, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
@ -140,9 +172,14 @@ class CommissionProductLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
$data[] = [
|
||||
'nickname' => '消耗',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.01,
|
||||
'number' => bcmul($total_price, 0.01, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 6,
|
||||
@ -158,11 +195,17 @@ class CommissionProductLogic extends BaseLogic
|
||||
{
|
||||
// $rose = bcdiv($product['rose'], 100, 2);
|
||||
$total_price = bcmul($product['cost'], $find['cart_num']);
|
||||
$price = $product['cost'];
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.05,
|
||||
'number' => bcmul($total_price, 0.05, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
@ -170,18 +213,28 @@ class CommissionProductLogic extends BaseLogic
|
||||
];
|
||||
//平台
|
||||
$data[] = [
|
||||
'nickname' => '平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => bcmul($total_price, 0.02, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
];
|
||||
$data[] = [
|
||||
'nickname' => '消耗',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.01,
|
||||
'number' => bcmul($total_price, 0.01, 2),
|
||||
'oid' => $order['id'],
|
||||
'type' => 6,
|
||||
@ -196,7 +249,7 @@ class CommissionProductLogic extends BaseLogic
|
||||
// $rose = bcdiv($product['rose'], 100, 2);
|
||||
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num']);
|
||||
|
||||
$price=$product['price'];
|
||||
$brigade_number = bcmul($total_price, 0.02, 2);
|
||||
$village_number = bcmul($brigade_number, 0.1, 2);
|
||||
$platform_number = bcmul($total_price, 0.02, 2);
|
||||
@ -212,43 +265,67 @@ class CommissionProductLogic extends BaseLogic
|
||||
|
||||
//队长
|
||||
$data[] = [
|
||||
'nickname' => '活动队长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $brigade_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $total_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $brigade_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 4,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//村长
|
||||
$data[] = [
|
||||
'nickname' => '活动村长',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $village_uid,
|
||||
'price' => $price,
|
||||
'total_price' => $brigade_number,
|
||||
'cart_num' => 0,
|
||||
'rate' => 0.01,
|
||||
'number' => $village_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 3,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//门店
|
||||
$data[] = [
|
||||
'nickname' => '活动门店',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $store_number,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0,
|
||||
'number' => $store_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
//平台
|
||||
$data[] = [
|
||||
'nickname' => '活动平台',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => 0,
|
||||
'price' => $price,
|
||||
'total_price' => $platform_number,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.02,
|
||||
'number' => $platform_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 2,
|
||||
'status' => 1,
|
||||
'is_activity' => 1,
|
||||
];
|
||||
(new StoreFinanceFlowProduct())->saveAll($data);
|
||||
}
|
||||
|
@ -323,34 +323,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
|
||||
//订单购物详情
|
||||
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
||||
|
||||
self::balance_purchase_refund($order);
|
||||
//处理财务流水退还
|
||||
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$user->now_money = bcadd($user['now_money'], $order['pay_price'], 2);
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
//退款
|
||||
$capitalFlowDao->userIncome('system_balance_add', 'system_back', $order['id'], $order['pay_price']);
|
||||
}
|
||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$user->purchase_funds = bcadd($user['purchase_funds'], $order['pay_price'], 2);
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
//退款
|
||||
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $order['pay_price']);
|
||||
}
|
||||
UserSignLogic::RefundOrder($order);
|
||||
|
||||
return true;
|
||||
}
|
||||
//积分
|
||||
UserSignLogic::RefundOrder($order);
|
||||
//微信日志 user_order_refund
|
||||
@ -361,6 +337,46 @@ class PayNotifyLogic extends BaseLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额采购款退款
|
||||
*/
|
||||
public static function balance_purchase_refund($order,$type=1,$money=0)
|
||||
{
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
if($type==1){
|
||||
$capitalFlowDao->userIncome('now_money_refund', 'system_back', $order['id'], $order['pay_price'],'',0);
|
||||
$user->now_money = bcadd($user['now_money'], $order['pay_price'], 2);
|
||||
}else{
|
||||
$capitalFlowDao->userIncome('now_money_refund', 'system_back', $order['id'], $money,'',0);
|
||||
$user->now_money = bcadd($user['now_money'], $money, 2);
|
||||
}
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
}
|
||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
if($type==1){
|
||||
$capitalFlowDao->userIncome('purchase_refund', 'system_back', $order['id'], $order['pay_price'],'',1);
|
||||
$user->purchase_funds = bcadd($user['purchase_funds'], $order['pay_price'], 2);
|
||||
}else{
|
||||
$capitalFlowDao->userIncome('purchase_refund', 'system_back', $order['id'], $money,'',1);
|
||||
$user->purchase_funds = bcadd($user['purchase_funds'], $money, 2);
|
||||
}
|
||||
$user->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
}
|
||||
UserSignLogic::RefundOrder($order);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 现金退款相关
|
||||
* @param $orderSn
|
||||
@ -581,8 +597,11 @@ class PayNotifyLogic extends BaseLogic
|
||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||
onBeforeUpdate($branchProduct->toArray(), 'branch_product');
|
||||
|
||||
StoreBranchProduct::where('id',$branchProduct['id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$branchProduct['purchase'],2),
|
||||
'sales'=>bcadd($branchProduct['sales'],$v['cart_num'],2)]);
|
||||
StoreBranchProduct::where('id', $branchProduct['id'])->update([
|
||||
'stock' => $stock,
|
||||
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
|
||||
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
|
||||
]);
|
||||
|
||||
$branchProduct = $branchProduct->toArray();
|
||||
$branchProduct['stock'] = $stock;
|
||||
@ -595,8 +614,11 @@ class PayNotifyLogic extends BaseLogic
|
||||
$stock = bcsub($storeProduct['stock'], $v['cart_num'], 2);
|
||||
onBeforeUpdate($storeProduct->toArray(), 'product');
|
||||
|
||||
StoreProduct::where('id', $v['product_id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$storeProduct['purchase'],2),
|
||||
'sales'=>bcadd($storeProduct['sales'],$v['cart_num'],2)]);
|
||||
StoreProduct::where('id', $v['product_id'])->update([
|
||||
'stock' => $stock,
|
||||
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
||||
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
||||
]);
|
||||
|
||||
$storeProduct = $storeProduct->toArray();
|
||||
$storeProduct['stock'] = $stock;
|
||||
|
@ -9,6 +9,7 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use support\Log;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ use app\common\model\BaseModel;
|
||||
use app\common\model\user_label\UserLabel;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\service\FileService;
|
||||
use support\Log;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
@ -33,7 +34,6 @@ class User extends BaseModel
|
||||
{
|
||||
return $this->hasOne(UserLabel::class, 'label_id', 'label_id')
|
||||
->bind(['label_name']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,4 +195,21 @@ class User extends BaseModel
|
||||
}
|
||||
})->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray();
|
||||
}
|
||||
|
||||
public static function before_update($data)
|
||||
{
|
||||
Log::error('before_update');
|
||||
}
|
||||
public static function after_update($data)
|
||||
{
|
||||
Log::error('after_update');
|
||||
}
|
||||
public static function before_write($data)
|
||||
{
|
||||
Log::error('before_write');
|
||||
}
|
||||
public static function after_write($data)
|
||||
{
|
||||
Log::error('after_write');
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ trait ModelEvent
|
||||
}
|
||||
|
||||
$call = 'on' . Str::studly($event);
|
||||
|
||||
d($call);
|
||||
try {
|
||||
if (method_exists(static::class, $call)) {
|
||||
$result = call_user_func([static::class, $call], $this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user