|
@@ -20,7 +20,8 @@ class send_manager
|
|
|
{
|
|
|
public static $stInstance;
|
|
|
private $mGoodsBlock;
|
|
|
- private $mAmountGoods;
|
|
|
+ private $mConfirmGoods; //确认收获后赠送的F码商品。
|
|
|
+ private $mPayGoods; //支付后送的F码商品。
|
|
|
|
|
|
private function __construct()
|
|
|
{
|
|
@@ -41,11 +42,11 @@ class send_manager
|
|
|
|
|
|
private function init()
|
|
|
{
|
|
|
- $this->mAmountGoods = [];
|
|
|
+ $this->mConfirmGoods = [];
|
|
|
$this->mGoodsBlock = [];
|
|
|
|
|
|
global $config;
|
|
|
- $fcodes_id = $config['paysuccess_fcodes']['fcodes_id'];
|
|
|
+ $fcodes_id = $config['autosend_fcodes']['fcodes_specialid'];
|
|
|
$blocks = special_manager::instance()->special($fcodes_id,$goods_ids);
|
|
|
|
|
|
foreach ($blocks as $block)
|
|
@@ -66,28 +67,66 @@ class send_manager
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- krsort($this->mAmountGoods);
|
|
|
+ krsort($this->mConfirmGoods);
|
|
|
}
|
|
|
|
|
|
private function add($amount,$item,$block)
|
|
|
{
|
|
|
+ global $config;
|
|
|
+ $pay_gids = $config['autosend_fcodes']['pay_goodsids'];
|
|
|
+
|
|
|
$goods_id = intval($item['data']);
|
|
|
if($goods_id <= 0) return;
|
|
|
|
|
|
- if(array_key_exists($amount,$this->mAmountGoods) == false) {
|
|
|
- $this->mAmountGoods[$amount] = [];
|
|
|
+ if(!empty($pay_gids) && is_array($pay_gids) && in_array($goods_id,$pay_gids))
|
|
|
+ {
|
|
|
+ if(array_key_exists($amount,$this->mConfirmGoods) == false) {
|
|
|
+ $this->mPayGoods[$amount] = [];
|
|
|
+ }
|
|
|
+ $this->mPayGoods[$amount][] = $goods_id;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(array_key_exists($amount,$this->mConfirmGoods) == false) {
|
|
|
+ $this->mConfirmGoods[$amount] = [];
|
|
|
+ }
|
|
|
+ $this->mConfirmGoods[$amount][] = $goods_id;
|
|
|
}
|
|
|
- $this->mAmountGoods[$amount][] = $goods_id;
|
|
|
$this->mGoodsBlock[$goods_id] = $block;
|
|
|
}
|
|
|
|
|
|
- public function fetch($amount)
|
|
|
+ public function fetch_pay($amount)
|
|
|
{
|
|
|
$amount = intval($amount);
|
|
|
if($amount <= 0) return false;
|
|
|
|
|
|
$gids = [];
|
|
|
- foreach ($this->mAmountGoods as $key => $goods_ids)
|
|
|
+ foreach ($this->mPayGoods 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);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetch_confirm($amount)
|
|
|
+ {
|
|
|
+ $amount = intval($amount);
|
|
|
+ if($amount <= 0) return false;
|
|
|
+
|
|
|
+ $gids = [];
|
|
|
+ foreach ($this->mConfirmGoods as $key => $goods_ids)
|
|
|
{
|
|
|
if(empty($goods_ids)) continue;
|
|
|
|
|
@@ -118,7 +157,6 @@ class send_manager
|
|
|
$all_goods[$gid] = $goods;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
foreach ($gids as $gid)
|
|
|
{
|
|
|
if(array_key_exists($gid,$all_goods))
|
|
@@ -128,10 +166,9 @@ class send_manager
|
|
|
|
|
|
$block = $this->mGoodsBlock[$gid];
|
|
|
$batch_code = $block['items'][0]['title'];
|
|
|
-
|
|
|
$oper = new operator($commonid,$batch_code);
|
|
|
- //todo 测试完成之后需要关闭掉
|
|
|
- //if($oper->grabed()) continue;
|
|
|
+
|
|
|
+ if($oper->grabed()) continue;
|
|
|
$fcode = $oper->grab();
|
|
|
if($fcode != false) {
|
|
|
return ['fcode' => $fcode,'banner' => $block];
|