|
@@ -21,7 +21,6 @@ class send_manager
|
|
|
public static $stInstance;
|
|
|
private $mGoodsBlock;
|
|
|
private $mNormalGoods;
|
|
|
- private $mAdditionGoods;
|
|
|
|
|
|
private function __construct()
|
|
|
{
|
|
@@ -44,7 +43,6 @@ class send_manager
|
|
|
{
|
|
|
$this->mNormalGoods = [];
|
|
|
$this->mGoodsBlock = [];
|
|
|
- $this->mAdditionGoods = [];
|
|
|
|
|
|
global $config;
|
|
|
$fcodes_id = $config['autosend_fcodes']['fcodes_spid'];
|
|
@@ -73,72 +71,30 @@ class send_manager
|
|
|
|
|
|
private function add($amount,$item,$block)
|
|
|
{
|
|
|
- global $config;
|
|
|
- $add_gids = $config['autosend_fcodes']['additional_gids'];
|
|
|
-
|
|
|
$goods_id = intval($item['data']);
|
|
|
if($goods_id <= 0) return;
|
|
|
|
|
|
- if(!empty($add_gids) && is_array($add_gids) && in_array($goods_id,$add_gids))
|
|
|
- {
|
|
|
- if(array_key_exists($amount,$this->mNormalGoods) == false) {
|
|
|
- $this->mAdditionGoods[$amount] = [];
|
|
|
- }
|
|
|
- $this->mAdditionGoods[$amount][] = $goods_id;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(array_key_exists($amount,$this->mNormalGoods) == false) {
|
|
|
- $this->mNormalGoods[$amount] = [];
|
|
|
- }
|
|
|
- $this->mNormalGoods[$amount][] = $goods_id;
|
|
|
+
|
|
|
+ if(array_key_exists($amount,$this->mNormalGoods) == false) {
|
|
|
+ $this->mNormalGoods[$amount] = [];
|
|
|
}
|
|
|
+ $this->mNormalGoods[$amount][] = $goods_id;
|
|
|
$this->mGoodsBlock[$goods_id] = $block;
|
|
|
}
|
|
|
|
|
|
public function fetch($amount,$pay_sn)
|
|
|
{
|
|
|
$normal = $this->fetch_normal($amount,$pay_sn);
|
|
|
- $addition = $this->fetch_addition($amount,$pay_sn);
|
|
|
|
|
|
$result = [];
|
|
|
if(!empty($normal)) {
|
|
|
$result['fcode'][] = $normal['fcode'];
|
|
|
$result['banner'][] = $normal['banner'];
|
|
|
}
|
|
|
- if(!empty($addition)) {
|
|
|
- $result['fcode'][] = $addition['fcode'];
|
|
|
- $result['banner'][] = $addition['banner'];
|
|
|
- }
|
|
|
|
|
|
return empty($result) ? false : $result;
|
|
|
}
|
|
|
|
|
|
- public function fetch_addition($amount,$pay_sn)
|
|
|
- {
|
|
|
- $amount = intval($amount);
|
|
|
- if($amount <= 0) return false;
|
|
|
-
|
|
|
- $gids = [];
|
|
|
- foreach ($this->mAdditionGoods as $key => $goods_ids)
|
|
|
- {
|
|
|
- if(empty($goods_ids)) continue;
|
|
|
-
|
|
|
- if($key <= $amount)
|
|
|
- {
|
|
|
- foreach ($goods_ids as $gid) {
|
|
|
- $gids[] = $gid;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(empty($gids)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- $result = $this->validate_one($gids,$pay_sn);
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
public function fetch_normal($amount,$pay_sn)
|
|
|
{
|
|
|
$amount = intval($amount);
|
|
@@ -187,10 +143,12 @@ class send_manager
|
|
|
$batch_code = $block['items'][0]['title'];
|
|
|
$oper = new operator($commonid,$batch_code);
|
|
|
|
|
|
- if($oper->grabed()) continue;
|
|
|
- $fcode = $oper->lock($pay_sn);
|
|
|
- if($fcode != false) {
|
|
|
- return ['fcode' => $fcode,'banner' => $block];
|
|
|
+ if($oper->grabed() == false)
|
|
|
+ {
|
|
|
+ $fcode = $oper->lock($pay_sn);
|
|
|
+ if($fcode != false) {
|
|
|
+ return ['fcode' => $fcode,'banner' => $block];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|