|
@@ -6,6 +6,43 @@ use Dever;
|
|
|
class Pay
|
|
|
{
|
|
|
private $key = 'jmss_2018';
|
|
|
+
|
|
|
+ public function go_api()
|
|
|
+ {
|
|
|
+ $where['type'] = 3;
|
|
|
+ $where['status'] = 2;
|
|
|
+ $data = Dever::db('journal/order')->getUnCode($where);
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ print_r($data);die;
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ # 购买兑换码
|
|
|
+ $order = $v;
|
|
|
+ $product_num = 1;
|
|
|
+ $code_num = 1;
|
|
|
+ $uid = $order['uid'];
|
|
|
+ if ($order['buy_id'] > 0) {
|
|
|
+ $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
|
|
|
+ $product_num = $buy['num'];
|
|
|
+ $code_num = $buy['code'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($code_num > 1) {
|
|
|
+ $product_num = intval($product_num/$code_num);
|
|
|
+ for ($i = 0; $i < $code_num; $i++) {
|
|
|
+ $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $update['where_id'] = $order['id'];
|
|
|
+ Dever::db('journal/order')->update($update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public function test_api()
|
|
|
{
|
|
|
$data['status'] = 1;
|