|
@@ -403,7 +403,7 @@ class StorePink extends BaseModel
|
|
|
$order = StoreOrder::tidyOrder($order, true)->toArray();
|
|
$order = StoreOrder::tidyOrder($order, true)->toArray();
|
|
|
$openid = WechatUser::uidToOpenid($order['uid'], 'openid');
|
|
$openid = WechatUser::uidToOpenid($order['uid'], 'openid');
|
|
|
$routineOpenid = WechatUser::uidToOpenid($order['uid'], 'routine_openid');
|
|
$routineOpenid = WechatUser::uidToOpenid($order['uid'], 'routine_openid');
|
|
|
- $product = StoreCombination::where('id', $order['combination_id'])->field('effective_time,title')->find();
|
|
|
|
|
|
|
+ $product = StoreCombination::where('id', $order['combination_id'])->field('effective_time,title,bingo_people')->find();
|
|
|
if ($product) {
|
|
if ($product) {
|
|
|
if ($order['pink_id']) {//拼团存在
|
|
if ($order['pink_id']) {//拼团存在
|
|
|
$res = false;
|
|
$res = false;
|
|
@@ -545,21 +545,21 @@ class StorePink extends BaseModel
|
|
|
$bingo = [];
|
|
$bingo = [];
|
|
|
for ($i = 0; $i < $bingo_people; $i++) {
|
|
for ($i = 0; $i < $bingo_people; $i++) {
|
|
|
do {
|
|
do {
|
|
|
- $id = rand(0, count($idAll));
|
|
|
|
|
- } while (in_array($id, $bingo));
|
|
|
|
|
|
|
+ $id = $idAll[rand(0, count($idAll) - 1)];
|
|
|
|
|
+ } while (in_array($id, $bingo) || !$id);
|
|
|
$bingo[] = $id;
|
|
$bingo[] = $id;
|
|
|
}
|
|
}
|
|
|
if (in_array($uid, $uidAll)) {
|
|
if (in_array($uid, $uidAll)) {
|
|
|
if (self::isTpl($uidAll, $pinkT['id'])) self::orderPinkAfter($uidAll, $pinkT['id']);
|
|
if (self::isTpl($uidAll, $pinkT['id'])) self::orderPinkAfter($uidAll, $pinkT['id']);
|
|
|
$pinkBool = 1;
|
|
$pinkBool = 1;
|
|
|
} else $pinkBool = 3;
|
|
} else $pinkBool = 3;
|
|
|
- foreach ($idAll as $v) {
|
|
|
|
|
- $pink = self::get($v);
|
|
|
|
|
- var_dump($idAll);
|
|
|
|
|
- if (!in_array($v, $bingo)) {
|
|
|
|
|
- StoreOrder::refundPink($pink['order_id_key']) && self::pinkReturn($pink['order_id_key']);
|
|
|
|
|
|
|
+ foreach ($idAll as $vi) {
|
|
|
|
|
+ $pink_info = self::get($vi);
|
|
|
|
|
+ if (!in_array($vi, $bingo)) {
|
|
|
|
|
+ StoreOrder::refundPink($pink_info['order_id_key']);
|
|
|
|
|
+ self::pinkReturn($pink_info['order_id_key']);
|
|
|
} else {
|
|
} else {
|
|
|
- TreeRecommend::insertTree($pink['uid'], User::where('uid', $pink['uid'])->value('spread_uid'));
|
|
|
|
|
|
|
+ TreeRecommend::insertTree($pink_info['uid'], User::where('uid', $pink_info['uid'])->value('spread_uid'));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -608,19 +608,22 @@ class StorePink extends BaseModel
|
|
|
|
|
|
|
|
public static function pinkReturn($order_id)
|
|
public static function pinkReturn($order_id)
|
|
|
{
|
|
{
|
|
|
- $order = StoreOrder::where('id', $order_id)->find();
|
|
|
|
|
- if (!$order) return self::setErrorInfo('数据不存在');
|
|
|
|
|
- $cart_info = StoreOrderCartInfo::where('oid', $order['id'])->where('cart_id', 'in', $order['cart_id'])->select();
|
|
|
|
|
|
|
+ var_dump($order_id);
|
|
|
|
|
+ $product = StoreOrder::get($order_id);
|
|
|
|
|
+ if (!$product) return self::setErrorInfo('数据不存在');
|
|
|
|
|
+ $cart_info = StoreOrderCartInfo::where('cart_id', 'in', $product['cart_id'])->select();
|
|
|
|
|
+ var_dump($cart_info);
|
|
|
$return = 0;
|
|
$return = 0;
|
|
|
foreach ($cart_info as $v) {
|
|
foreach ($cart_info as $v) {
|
|
|
$info = json_decode($v['cart_info']);
|
|
$info = json_decode($v['cart_info']);
|
|
|
$return += $info['cart_num'] * ($info['productInfo']['attrInfo']['return']);
|
|
$return += $info['cart_num'] * ($info['productInfo']['attrInfo']['return']);
|
|
|
}
|
|
}
|
|
|
|
|
+ var_dump($return);
|
|
|
$res = true;
|
|
$res = true;
|
|
|
if ($return > 0) {
|
|
if ($return > 0) {
|
|
|
- $balance = User::where('uid', $order['uid'])->value('brokerage_price');
|
|
|
|
|
- $res = $res && UserBill::income('拼团佣金', $order['uid'], 'now_money', 'brokerage', $return, $order_id, $balance + $return, '参加拼团未中,获得佣金' . $return);
|
|
|
|
|
- $res = $res && User::where('uid', $order['uid'])->inc('brokerage_price', $return)->update();
|
|
|
|
|
|
|
+ $balance = User::where('uid', $product['uid'])->value('brokerage_price');
|
|
|
|
|
+ $res = $res && UserBill::income('拼团佣金', $product['uid'], 'now_money', 'brokerage', $return, $order_id, $balance + $return, '参加拼团未中,获得佣金' . $return);
|
|
|
|
|
+ $res = $res && User::where('uid', $product['uid'])->inc('brokerage_price', $return)->update();
|
|
|
}
|
|
}
|
|
|
return $res;
|
|
return $res;
|
|
|
}
|
|
}
|