|
- <?php
- /**
- * 数据库表类 fx_commission_info
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm LoginController.php
- * Create By 2017/06/15 14:22 $
- */
-
- namespace common\models;
-
- use yii\db\ActiveRecord;
- use yii\db\Expression;
-
- /**
- * 数据库表类 fx_commission_info.
- * @property integer $id
- * @property integer $fx_uid
- * @property integer $total_money
- * @property integer $order_id
- * @property integer $status
- * @property integer $delete_flag
- * @property string $create_time
- * @property string $update_time
- * @property string $update_user
- */
- class FxCommissionInfo extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'fx_commission_info';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['fx_uid', 'total_money', 'order_id'], 'required'],
- [['fx_uid', 'order_id', 'status', 'delete_flag'], 'integer'],
- [['total_money'], 'number'],
- [['create_time', 'update_time'], 'safe'],
- [['update_user'], 'string', 'max' => 50],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'fx_uid' => 'Fx Uid',
- 'total_money' => 'Total Money',
- 'order_id' => 'Order ID',
- 'status' => 'Status',
- 'delete_flag' => 'Delete Flag',
- 'create_time' => 'Create Time',
- 'update_time' => 'Update Time',
- 'update_user' => 'Update User',
- ];
- }
-
- /**
- * Des:插入记录
- * Name: add
- * @param $fx_uid
- * @param $commission
- * @param $orderId
- * @return bool
- * @author 倪宗锋
- */
- public function add($fx_uid, $commission, $orderId)
- {
- $commissionArray = [
- 'fx_uid' => $fx_uid,
- 'total_money' => $commission,
- 'order_id' => $orderId,
- 'status' => 1,
- 'create_time' => date('Y-m-d H:i:s'),
- 'update_user' => 'system'
- ];
- $this->attributes = $commissionArray;
- $flag = $this->insert();
- return $flag;
- }
-
- /**
- * Des:根据订单ID获取佣金详细
- * Name: getInfoByOrderId
- * @param $oder_id
- * @return array
- * @author 倪宗锋
- */
- public function getInfoByOrderId($oder_id)
- {
- $orderInfo = self::find()
- ->from(static::tableName())
- ->where(['=', 'order_id', $oder_id])
- ->asArray()
- ->one();
- return $orderInfo;
- }
-
- /**
- * Des:修改单状态
- * Name: editStatus
- * @param $oder_id
- * @param $status
- * @return int
- * @author 倪宗锋
- */
- public function editStatus($oder_id, $status)
- {
- $flag = self::updateAll(['status' => $status], ['=', 'order_id', $oder_id]);
- return $flag;
- }
-
- /**
- * Des:获取发送微信信息
- * Name: getSendWxMsg
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function getSendWxMsg($order_id)
- {
- $where = ['=', 'a.order_id', $order_id];
- $select = [
- 'commission' => 'a.total_money',
- 'b.total_money',
- 'b.order_name',
- 'b.order_status',
- 'b.order_id',
- 'b.prod_cnt',
- 'category_name' => new Expression("(SELECT c.category_name from base_category c WHERE c.category_id = b.category_id)"),
- 'open_id' => new Expression("(SELECT d.openid from fx_user d WHERE d.uid = b.fx_uid)")
- ];
- $getInfo = self::find()->select($select)
- ->from(static::tableName() . ' a')
- ->innerJoin(OrderMain::tableName() . ' b', 'a.order_id = b.order_id')
- ->where($where)
- ->asArray()
- ->one();
- return $getInfo;
- }
- }
|