public function docharge()
 {
     $id = intval($_REQUEST['id']);
     $charge = M("SupplierMoneySubmit")->getById($id);
     if ($charge['status'] == 0) {
         M("SupplierMoneySubmit")->where("id=" . $charge['id'])->setField("status", 1);
         supplier_money_log($charge['supplier_id'], "-" . $charge['money'], "提现成功");
         $this->error("确认提现成功");
     } else {
         $this->error("已提现");
     }
 }
Exemplo n.º 2
0
/**
 * 结算
 * @param unknown_type $rel_ids 结算的数据ID数组
 * @param unknown_type $deal_id 项目编号
 * @param memo 备注 
 */
function do_balance($rel_ids, $deal_id, $memo = "")
{
    $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $deal_id);
    $now = NOW_TIME;
    if ($deal_info['is_coupon'] == 1) {
        $sql = "update " . DB_PREFIX . "deal_coupon set is_balance = 2,balance_time = " . $now . ",balance_memo = '" . $memo . "' where id in (" . implode(",", $rel_ids) . ") and is_balance <> 2";
        $sql_amount = "select sum(balance_price)+sum(add_balance_price) from " . DB_PREFIX . "deal_coupon where id in (" . implode(",", $rel_ids) . ") and is_balance <> 2";
        $amount = $GLOBALS['db']->getOne($sql_amount);
        $GLOBALS['db']->query($sql);
        //同步更新订单商品
        $sql_item = "select doi.* from " . DB_PREFIX . "deal_order_item as doi where doi.id in(select distinct(dc.order_deal_id) as item_id from " . DB_PREFIX . "deal_coupon as dc where dc.id in (" . implode(",", $rel_ids) . "))";
        $item_list = $GLOBALS['db']->getAll($sql_item);
        foreach ($item_list as $k => $v) {
            if ($deal_info['deal_type'] == 1) {
                //按单
                $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set is_balance = 2,balance_time = " . $now . ",balance_memo = '" . $memo . "' where id = " . $v['id'] . " and is_balance <> 2");
            } else {
                if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and is_balance = 2") == $v['number']) {
                    //全部
                    $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set is_balance = 2,balance_time = " . $now . ",balance_memo = '" . $memo . "' where id = " . $v['id'] . " and is_balance <> 2");
                } else {
                    //部份
                    $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set is_balance = 3,balance_time = " . $now . ",balance_memo = '" . $memo . "' where id = " . $v['id'] . " and is_balance <> 2");
                }
            }
        }
    } else {
        $sql_amount = "select sum(balance_total_price)+sum(add_balance_price_total) from " . DB_PREFIX . "deal_order_item where id in (" . implode(",", $rel_ids) . ") and is_balance <> 2";
        $amount = $GLOBALS['db']->getOne($sql_amount);
        $sql = "update " . DB_PREFIX . "deal_order_item set is_balance = 2,balance_time = " . $now . ",balance_memo = '" . $memo . "' where id in (" . implode(",", $rel_ids) . ") and is_balance <> 2";
        $GLOBALS['db']->query($sql);
    }
    supplier_money_log($deal_info['supplier_id'], $amount, $deal_info['sub_name'] . "结算 " . $memo);
}