|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
- /**
- * 数据库表类 fx_user_account
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm LoginController.php
- * Create By 2017/06/16 10:22 $
- */
-
- namespace common\models;
-
- use yii\db\ActiveRecord;
-
- /**
- * 数据库表类 fx_user_account.
- * @property integer $id
- * @property integer $fx_uid
- * @property string $available_commission
- * @property string $closed_commission
- * @property string $total_commission
- * @property string $apply_commission
- * @property integer $remaining_sum
- * @property string $create_time
- * @property string $update_time
- * @property integer $status
- * @property integer $delete_flag
- */
- class FxUserAccount extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'fx_user_account';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['fx_uid'], 'required'],
- [['fx_uid', 'status', 'delete_flag'], 'integer'],
- [['available_commission', 'closed_commission', 'total_commission', 'apply_commission', 'remaining_sum'], 'number'],
- [['create_time', 'update_time'], 'safe'],
- [['fx_uid'], 'unique'],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'fx_uid' => 'Fx Uid',
- 'available_commission' => 'Available Commission',
- 'closed_commission' => 'Closed Commission',
- 'total_commission' => 'Total Commission',
- 'apply_commission' => 'Apply Commission',
- 'remaining_sum' => 'Remaining Sum',
- 'create_time' => 'Create Time',
- 'update_time' => 'Update Time',
- 'status' => 'Status',
- 'delete_flag' => 'Delete Flag',
- ];
- }
-
- /**
- * Function Description:获取账户信息
- * Function Name: getMyCommission
- * @param $fx_uid
- * @return array
- *
- * @author 娄梦宁
- */
- public function getMyCommission($fx_uid)
- {
- $select = [
- 'a.headimgurl',
- 'a.phone',
- 'a.nickname',
- 'b.status as accountStatus',
- 'ifnull(b.available_commission,0) available_commission',
- 'ifnull(b.total_commission,0) total_commission',
- 'ifnull(b.apply_commission,0) apply_commission',
- 'FORMAT(ifnull(b.remaining_sum,0),0) remaining_sum_s',
- 'b.remaining_sum'
- ];
- $result = self::find()->select($select)
- ->from('fx_user as a')
- ->leftJoin(self::tableName() . ' as b', 'a.uid=b.fx_uid')
- ->where(['=', 'a.uid', $fx_uid])
- ->asArray()
- ->one();
- return $result;
- }
-
- /**
- * Des:扣除用户余额
- * Name: changeStatus
- * @param $fx_uid
- * @param $money
- * @return bool
- * @author 倪宗锋
- */
- public function deductAmount($fx_uid, $money)
- {
- $sql = "UPDATE fx_user_account
- set remaining_sum=remaining_sum - $money
- where fx_uid=$fx_uid
- ";
- $res = $this->getDb()->createCommand($sql)->execute();
- if (!$res) {
- return false;
- }
- return true;
- }
-
- /**
- * Des:用户余额充值
- * Name: changeStatus
- * @param $fx_uid
- * @param $money
- * @return bool
- * @author 倪宗锋
- */
- public function rechargeAmount($fx_uid, $money)
- {
- $sql = "UPDATE fx_user_account
- set remaining_sum=remaining_sum + $money
- where fx_uid=$fx_uid
- ";
- $res = $this->getDb()->createCommand($sql)->execute();
- if (!$res) {
- return false;
- }
- return true;
- }
- }
|