目前,我在ecommerece网站上工作,在卖方方面,只要用户生成订单,订单金额应添加到钱包中 (例如,如果供应商钱包中的金额为1500,并且用户生成的订单为500,那么钱包的更新值应该为2000),但在我的情况下,它变为500。如果有人知道解决方案,请帮忙。以下是我的controller.php代码
Public function clone_job()
{
$sellerData = $this->Mdl_admin_login->seller_list();
foreach ($sellerData as $seller)
{
$wallet = 0;
$payment = $this->Mdl_admin_login->get_payment_list($seller['id']);
foreach ($payment as $payments){
$wallet = $wallet + $payments['settlement_price']*$payments['qty'];
$wallets = $this->Mdl_admin_login->add_wallet($wallet,$seller['id']);
$is_pay = $this->Mdl_admin_login->is_pay($payments['id']);
}
}
}
model.php
function add_wallet($wallet,$id)
{
$data = array(
'wallet' => $wallet,
);
$this->db->where('id',$id);
$this->db->update('seller', $data);
}
答案 0 :(得分:1)
function add_wallet($wallet,$id){
$this->db->set('wallet', 'wallet+'. $wallet, false);
$this->db->where('id',$id);
$this->db->update('seller');
}
答案 1 :(得分:0)
请尝试这个。
function add_wallet($wallet,$id){
$this->db->set('wallet', 'wallet+'. $wallet, false);
$this->db->where('id',$id);
$this->db->update('seller');
}