The implementation technology of the Revenue Expenditure schedule of PHP programming

Source: Internet
Author: User
Tags php programming

The account amount statement is the sum of each amount that the user spends and the amount of money that the user is making in the system, in layman's words, income and expenses. But many programmers at the beginning of the time, do not know how to achieve, often or appear to have an income record but no expenditure records, or the contrary, so for this issue, the following to explain for you to analyze.

1, the customer is in the system consumption of the amount generated by the Commission, written in this record table. The PHP code is as follows:
if (I (' pay_state ') ==2 && I (' state ') ==3) {
$money = $info [' Money ']/100;
$uid = $info [' uid '];
$update [' Authe_uid ']= $info [' uid '];
$user =m (' user ');
$list = $user->where ("uid= $uid")->find ();
$sale _uid= $list [' Sale_uid '];
$update [' Sale_uid ']= $list [' Sale_uid '];
$bili =m (' sys ')->where ("Id=1")->find ();
$bi = $bili [' Sale_rate ']/100;
$put _money= $money $bi/100;
$update [' Money ']= $put _money
100;
$update [' Real_money ']= $put _money ;
$update [' Time ']=time ();
$update [' state ']=1;
$update [' type ']=2;
$sale _user=m (' Sale_user ');
$sale = $sale _user->where ("sale_uid= $sale _uid")->find ();
$up [' Tal_money ']= $sale [' Tal_money ']+ $put _money
100;
$sale _user->where ("sale_uid= $sale _uid")->save ($up);}

2, the platform to the sales agent to release the amount of time, written in this record table. The PHP code is as follows:
Public Function Dopay_money () {
if (I ("bank_card") = = ") {
Error (" The account cannot be empty ");d ie;
}
if (I ("money_num") = = ') {
error ("Cannot be empty");d ie;
}
if (I ("money") = = ') {
error ("Cannot be empty");d ie;
}
if (I ("Money") >i ("Tal_money")) {
Error ("Insufficient total account amount");d ie;
}
$bank _card=i ("Bank_card");
$money _num=i ("Money_num");
$money =i ("money");
$sale _uid=i ("Sale_uid");
$info =m ("sys")->where ("Id=1")->find ();
$min _money= $info [' Min_money ']/100;
if ($money < $min _money) {
Error ("Minimum payment amount is". $min _money. " Yuan ");
}
$sale _user=m ("Sale_user");
$moneyb =m ("money");
$userinfo = $sale _user->where ("sale_uid= $sale _uid")->find ();
$data [' Tal_money ']= $userinfo [' Tal_money ']-$money *100;

if($sale_user->where("sale_uid=$sale_uid")->save($data)){  $da[‘sale_uid‘]=$sale_uid;  $da[‘money‘]=$money*100;  $da[‘real_money‘]=$money*100;  $da[‘time‘]=time();  $da[‘state‘]=2;  $da[‘type‘]=1;  $da[‘bank_card‘]=$bank_card;  $da[‘money_num‘]=$money_num;  if($moneyb->add($da)){    success("成功",U("Oasys/sale"));  }else{    error("失败");  }}

}

Well, see here believe that everyone knows how to do, then if you still have some details of the problem, you can leave a message consultation, we see the first time to reply. This article by the Professional Zhengzhou app development company Brigitte Xuan Science and Technology finishing release, original is not easy, if need reprint please indicate source.

The implementation technology of the Revenue Expenditure schedule of PHP programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.