rabin 2 years ago
parent
commit
49e0303a11

+ 19 - 0
app/cash/database/order.php

@@ -4,6 +4,14 @@ $jstype = array
 (
     1 => '订货结算',
     2 => '退款结算',
+    3 => '零售结算',
+);
+
+$pay_type = array
+(
+    1 => '在线支付',
+    2 => '礼品卡支付',
+    3 => '钱包支付',
 );
 
 $status = array
@@ -284,6 +292,16 @@ return array
             'option'    => $audit_type,
         ),
 
+        'pay_type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '支付类型',
+            'default'   => '1',
+            'desc'      => '支付类型',
+            'match'     => 'is_numeric',
+            'option'    => $pay_type,
+        ),
+
         'fdate'     => array
         (
             'type'      => 'int-11',
@@ -349,6 +367,7 @@ return array
 
     'manage' => array
     (
+        'list_table' => 'html',
         'delete' => false,
         'edit' => false,
         'insert' => false,

+ 3 - 3
app/cash/lib/Order.php

@@ -18,10 +18,10 @@ class Order
         } else {
             $status = 1;
         }
-        if ($jstype == 1) {
-            $audit_type = 1;
-        } else {
+        if ($jstype == 2) {
             $audit_type = 2;
+        } else {
+            $audit_type = 1;
         }
         $where['source_order_id'] = $order['id'];
         $where['jstype'] = $jstype;

+ 25 - 3
app/shop/lib/Sell.php

@@ -973,7 +973,7 @@ class Sell
                 $this->dropCart($cart, $uid, $goods, $shop['id']);
             }
             # 使用优惠券
-            $this->useCoupon($coupon_id, $user_coupon_id, $card, $wallet_cash);
+            $this->useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash);
 
             /*
             if ($card) {
@@ -1038,7 +1038,7 @@ class Sell
             $this->dropCart($cart, $uid, $goods, $shop['id']);
         }
         # 使用优惠券
-        $this->useCoupon($coupon_id, $user_coupon_id, $card, $wallet_cash);
+        $this->useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash);
         $result['order_num'] = $order_data['order_num'];
         $result['order_id'] = $id;
         return $result;
@@ -1059,14 +1059,36 @@ class Sell
         }
     }
 
-    public function useCoupon($coupon_id, $user_coupon_id, $card, $wallet_cash)
+    public function useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash)
     {
         if ($user_coupon_id) {
             Dever::db('shop/user_coupon')->update(array('where_id' => $user_coupon_id, 'status' => 2));
         }
 
+        # 使用礼品卡
         if ($card) {
             $state = Dever::db('card/code')->incUseCash(array('where_id' => $card['id'], 'set_use_cash' => $card['cash']));
+            # 生成结算单
+            $code = Dever::db('card/code')->find($card['id']);
+            if ($code) {
+                $card_info = Dever::db('card/info')->find($code['card_id']);
+                if ($card_info) {
+                    if ($code['type'] == 2) {
+                        $zhe = 0.9;
+                    } else {
+                        $zhe = $card_info['price']/$card_info['value'];
+                    }
+                    $price = round($card['cash']*$zhe);
+                    $order_data['type'] = 1;
+                    $order_data['type_id'] = $order_data['shop_id'];
+                    $order_data['source_type'] = 4;
+                    $order_data['source_id'] = -1;
+                    $order_data['price'] = $price;
+                    $order_data['p_price'] = $card['cash'];
+                    Dever::load('cash/lib/order')->up($order_data, 3, 1);
+                }
+            }
+            
         } elseif ($wallet_cash) {
 
         }

+ 1 - 0
service/agent/database/import_cash_log.php

@@ -4,6 +4,7 @@ $type = array
 (
 	1 => '余额',
 	2 => '团队业绩',
+    3 => '直推创客数量',
 );
 
 $role = function()

+ 18 - 1
service/agent/lib/Import.php

@@ -734,7 +734,7 @@ class Import
     public function get_cash_api()
     {
         # 获取已审核通过、权益已发放的用户
-
+        /*
         # 团队业绩
         $data = $this->db->fetchAll('select a.*,b.credit3 as bcredit3 from ims_ewei_shop_member as a left join ims_mc_members as b on b.uid = a.uid where a.status = 1 and a.prestatus = 1 and a.isagent = 1 and (b.credit3 > 0 || a.credit3 > 0) order by a.id asc ');
 
@@ -770,6 +770,23 @@ class Import
             echo $v['id'];
             echo "\r\n";
         }
+        */
+
+        $data = $this->db->fetchAll('select * from `churen_agent_member` where  left(concat(`area`,","), 14)=in(150000,150100,) and `state` = "1"');
+
+        if (!$data) {
+            return false;
+        }
+
+        foreach ($data as $k => $v) {
+            $num = Dever::db('agent/member')->total(array('parent_mid' => $v['id'], 'role' => 6));
+            if ($num > 0) {
+                $this->cash_log($v['id'], 3, $num);
+            }
+            
+            echo $v['id'];
+            echo "\r\n";
+        }
 
         return 'ok';
     }

+ 2 - 1
service/option/lib/Agreement.php

@@ -226,7 +226,7 @@ class Agreement
             $agreement = Dever::db('setting/agreement')->find($info['agreement_id']);
 
             if ($agreement) {
-                $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3));
+                $state = Dever::db('option/agreement')->update(array('where_id' => $info['id'], 'status' => 3, 'audit' => 4));
                 if ($state) {
                     # 生成新的合同
                     unset($info['id']);
@@ -244,6 +244,7 @@ class Agreement
 
                     $info['sign'] = '';
                     $info['status'] = 1;
+                    $info['audit'] = 2;
                     Dever::db('option/agreement')->insert($info);
                 }
             }