|
@@ -44,5 +44,37 @@ class TestThirdRefill extends TestCase
|
|
|
refill\RefillFactory::instance()->notify('sctongqian', $params);
|
|
|
}
|
|
|
|
|
|
+ public function testMerchantGoods()
|
|
|
+ {
|
|
|
+ $goods_list = refill\RefillFactory::instance()->goods();
|
|
|
+
|
|
|
+ $sorter = function (array $items) {
|
|
|
+ $ret = [];
|
|
|
+ foreach ($items as $key => $val) {
|
|
|
+ sort($val);
|
|
|
+ $ret[$key] = $val;
|
|
|
+ }
|
|
|
+ return $ret;
|
|
|
+ };
|
|
|
+
|
|
|
+ $goods_list = $sorter($goods_list);
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+ $mchid = 10254;
|
|
|
+ $merchant_goods = rcache('merchant_goods', 'refill-', $mchid);
|
|
|
+ $goods = $merchant_goods[$mchid] ?? serialize([]);
|
|
|
+ $goods = unserialize($goods);
|
|
|
+ foreach ($goods_list as $card_type => $value) {
|
|
|
+ $key = mtopcard\scard_type($card_type);
|
|
|
+ if (array_key_exists($key, $goods)) {
|
|
|
+ $result[$key] = $goods[$key];
|
|
|
+ } else {
|
|
|
+ $result[$key] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $thrid_refill = Model('thrid_refill');
|
|
|
+ $pcode = $thrid_refill->getMerchantPcode($mchid);
|
|
|
+ $result['third'] = $pcode;
|
|
|
+ }
|
|
|
|
|
|
}
|