|
|
@@ -481,7 +481,7 @@ class StoreOrder extends BaseModel
|
|
|
//生成门店订单信息
|
|
|
self::createOrderPart($orderInfo); //拆单创建门店订单表
|
|
|
$res5 = true;
|
|
|
-// @file_put_contents('quanju.txt', "-报错点1\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点1\r\n", 8);
|
|
|
|
|
|
foreach ($cartInfo as $cart) {
|
|
|
//减库存加销量
|
|
|
@@ -490,23 +490,23 @@ class StoreOrder extends BaseModel
|
|
|
else if ($bargain_id) $res5 = $res5 && StoreBargain::decBargainStock($cart['cart_num'], $bargain_id, isset($cart['productInfo']['attrInfo']) ? $cart['productInfo']['attrInfo']['unique'] : '');
|
|
|
else $res5 = $res5 && StoreProduct::decProductStock($cart['cart_num'], $cart['productInfo']['id'], isset($cart['productInfo']['attrInfo']) ? $cart['productInfo']['attrInfo']['unique'] : '');
|
|
|
}
|
|
|
-// @file_put_contents('quanju.txt', "-报错点2\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点2\r\n", 8);
|
|
|
|
|
|
//保存购物车商品信息
|
|
|
$res4 = false !== StoreOrderCartInfo::setCartInfo($order['id'], $cartInfo);
|
|
|
-// @file_put_contents('quanju.txt', "-报错点3\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点3\r\n", 8);
|
|
|
|
|
|
//购物车状态修改
|
|
|
$res6 = false !== StoreCart::where('id', 'IN', $cartIds)->update(['is_pay' => 1]);
|
|
|
if (!$res4 || !$res5 || !$res6) return self::setErrorInfo('订单生成失败!', true);
|
|
|
-// @file_put_contents('quanju.txt', "-报错点4\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点4\r\n", 8);
|
|
|
|
|
|
//自动设置默认地址
|
|
|
UserRepository::storeProductOrderCreateEbApi($order, compact('cartInfo', 'addressId'));
|
|
|
-// @file_put_contents('quanju.txt', "-报错点5\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点5\r\n", 8);
|
|
|
|
|
|
self::clearCacheOrderInfo($uid, $key);
|
|
|
-// @file_put_contents('quanju.txt', "-报错点6\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-报错点6\r\n", 8);
|
|
|
|
|
|
self::commitTrans();
|
|
|
StoreOrderStatus::status($order['id'], 'cache_key_create_order', '订单生成');
|
|
|
@@ -516,7 +516,7 @@ class StoreOrder extends BaseModel
|
|
|
return self::setErrorInfo('生成订单时SQL执行错误错误原因:' . $e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
self::rollbackTrans();
|
|
|
- @file_put_contents('quanju.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-会员等级激励奖报错内容\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-会员等级激励奖报错内容\r\n", 8);
|
|
|
|
|
|
return self::setErrorInfo('生成订单时系统错误错误原因:' . $e->getMessage());
|
|
|
}
|
|
|
@@ -524,7 +524,7 @@ class StoreOrder extends BaseModel
|
|
|
|
|
|
public static function createOrderPart($orderInfo)
|
|
|
{
|
|
|
- @file_put_contents('quanju.txt', json_encode($orderInfo['cart_id']) . "-报错的购物车id\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($orderInfo['cart_id']) . "-报错的购物车id\r\n", 8);
|
|
|
|
|
|
$user_info = User::where('uid', $orderInfo['uid'])->find();
|
|
|
// $cart_ids = explode(',', $orderInfo['cart_id']);
|
|
|
@@ -540,27 +540,27 @@ class StoreOrder extends BaseModel
|
|
|
return $item;
|
|
|
})
|
|
|
->toArray();
|
|
|
-// @file_put_contents('quanju.txt', "-测试2\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', "-测试2\r\n", 8);
|
|
|
|
|
|
$grouped = array_column($cartInfo, 'ids', 'mer_id');
|
|
|
foreach ($cartInfo as $k => $v) {
|
|
|
$total_num = 0;
|
|
|
$total_price = 0;
|
|
|
$deduction_price = 0;
|
|
|
- @file_put_contents('quanju.txt', json_encode($v)."-测试1\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($v)."-测试1\r\n", 8);
|
|
|
|
|
|
$cartInfo = StoreCart::where('id', 'in', $v['ids'])->select();
|
|
|
- @file_put_contents('quanju.txt', json_encode($cartInfo)."-测试5\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($cartInfo)."-测试5\r\n", 8);
|
|
|
|
|
|
foreach ($cartInfo as $cart) {
|
|
|
- @file_put_contents('quanju.txt', json_encode($cart['product_id'])."-测试3\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($cart['product_id'])."-测试3\r\n", 8);
|
|
|
|
|
|
$price = StoreProduct::where('id', $cart['product_id'])->value('price');
|
|
|
$product_price = bcmul($price, $cart['cart_num'], 2);
|
|
|
$total_price = bcadd($total_price, $product_price, 2); //商品总价
|
|
|
$total_num = bcadd($total_num, $cart['cart_num'], 2);
|
|
|
}
|
|
|
- @file_put_contents('quanju.txt', "-这里吗\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', "-这里吗\r\n", 8);
|
|
|
|
|
|
if ($user_info['level'] > 0) { //会员折扣
|
|
|
$discount = SystemUserLevel::where('id', $user_info['level'])->value('discount');
|
|
|
@@ -568,7 +568,7 @@ class StoreOrder extends BaseModel
|
|
|
$total_price = bcmul($total_price, bcsub(1, $discount, 2), 2);
|
|
|
$deduction_price = bcsub($moto_price, $total_price, 2); //抵扣金额
|
|
|
}
|
|
|
- @file_put_contents('quanju.txt', "-测试4\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', "-测试4\r\n", 8);
|
|
|
|
|
|
$orderInfo = [
|
|
|
'mer_id' => $v['mer_id'],
|
|
|
@@ -586,7 +586,7 @@ class StoreOrder extends BaseModel
|
|
|
'mark' => $orderInfo['mark'],
|
|
|
'add_time' => time(),
|
|
|
];
|
|
|
- @file_put_contents('quanju.txt', json_encode($orderInfo) . "-咋回事啊\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($orderInfo) . "-咋回事啊\r\n", 8);
|
|
|
|
|
|
$order = StoreOrderPart::create($orderInfo);
|
|
|
}
|
|
|
@@ -917,24 +917,22 @@ class StoreOrder extends BaseModel
|
|
|
{
|
|
|
try {
|
|
|
$userInfo = User::get($uid);
|
|
|
- @file_put_contents('quanju.txt', json_encode($userInfo) . "-会员等级激励奖报错内容3\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($userInfo) . "-会员等级激励奖报错内容3\r\n", 8);
|
|
|
|
|
|
if ($userInfo['level'] > 0) {
|
|
|
$user_radio = SystemUserLevel::where('id', $userInfo['level'])->value('rebate_ratio'); //用户等级返现比例
|
|
|
- @file_put_contents('quanju.txt', json_encode($user_radio) . "-会员等级激励奖报错内容4\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($user_radio) . "-会员等级返利比例\r\n", 8);
|
|
|
|
|
|
$rebate = bcmul($order['pay_price'], bcdiv($user_radio, 100, 2), 2); //用户返现金额
|
|
|
if ($rebate > 0){
|
|
|
$blance = bcadd($userInfo['brokerage_price'], $rebate, 2); //用户佣金
|
|
|
- @file_put_contents('quanju.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
|
|
|
// var_dump($rebate, $order['id'], $blance);
|
|
|
//die();
|
|
|
if ($type == 1) {
|
|
|
UserBill::income('会员返利', $uid, 'brokerage_price', 'level_money', $rebate, $order['id'], $blance, '会员返利佣金');
|
|
|
- if ($userInfo['spread_uid'] > 0) {
|
|
|
- self::userLevelReward($order, $userInfo['spread_uid'], 2);
|
|
|
- }
|
|
|
+
|
|
|
} elseif ($type == 2) { //下级推荐返利
|
|
|
UserBill::income('下级会员返利', $uid, 'brokerage_price', 'level_money', $rebate, $order['id'], $blance, '下级购买商品的会员返利佣金');
|
|
|
return true;
|
|
|
@@ -957,30 +955,33 @@ class StoreOrder extends BaseModel
|
|
|
$product = StoreProduct::where('id', $product_info['product_id'])->find(); //商品返现比例
|
|
|
if (!empty($product)){
|
|
|
$product = $product->toArray();
|
|
|
- $product_radio = $product['rebate_ratio'];
|
|
|
+ $product_radio = intdiv($product['rebate_ratio']);
|
|
|
}
|
|
|
@file_put_contents('quanju4.txt', json_encode($product) . "-商品详情\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', $product_radio . "-会员等级激励奖报错内容4\r\n", 8);
|
|
|
|
|
|
|
|
|
if ($product_radio>0){
|
|
|
- @file_put_contents('quanju4.txt', $user_radio . "-会员等级激励奖报错内容4\r\n", 8);
|
|
|
-
|
|
|
+// if ($user_radio>0){
|
|
|
$rebate = bcmul($order['pay_price'], bcdiv($user_radio, 100, 2), 2); //用户返现金额
|
|
|
- if ($rebate>0){
|
|
|
+
|
|
|
$blance = bcadd($userInfo['brokerage_price'], $rebate, 2); //用户佣金
|
|
|
@file_put_contents('quanju4.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
|
|
|
if ($type == 1) {
|
|
|
UserBill::income('商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '商品返利佣金');
|
|
|
- if ($userInfo['spread_uid'] > 0) {
|
|
|
- self::userLevelReward($order, $userInfo['spread_uid'], 2);
|
|
|
- }
|
|
|
+// if ($userInfo['spread_uid'] > 0) {
|
|
|
+// self::userLevelReward($order, $userInfo['spread_uid'], 2);
|
|
|
+// }
|
|
|
} elseif ($type == 2) { //下级推荐返利
|
|
|
UserBill::income('下级商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '下级购买商品的商品返利佣金');
|
|
|
return true;
|
|
|
}
|
|
|
User::where('uid',$uid)->update(['brokerage_price'=>$blance]);
|
|
|
- }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ if ($userInfo['spread_uid'] > 0) {
|
|
|
+ self::userLevelReward($order, $userInfo['spread_uid'], 2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1061,7 +1062,7 @@ class StoreOrder extends BaseModel
|
|
|
return true;
|
|
|
}catch (\Exception $e) {
|
|
|
// 处理异常
|
|
|
- @file_put_contents('quanju.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-代理等级批发返利报错内容\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-代理等级批发返利报错内容\r\n", 8);
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
@@ -1088,7 +1089,7 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
}catch (\Exception $e) {
|
|
|
// 处理异常
|
|
|
- @file_put_contents('quanju.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-伞下团队批发返利报错内容\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-伞下团队批发返利报错内容\r\n", 8);
|
|
|
|
|
|
return false;
|
|
|
}
|